Commit 89e63a44 authored by Xavier Thompson's avatar Xavier Thompson

cli/info: Include software-type in output

parent bfe6284c
...@@ -105,6 +105,7 @@ def do_info(logger, conf, local): ...@@ -105,6 +105,7 @@ def do_info(logger, conf, local):
info = { info = {
'software-url': instance._software_release_url, 'software-url': instance._software_release_url,
'software-type': instance._source_reference,
'requested-state': instance._requested_state, 'requested-state': instance._requested_state,
'instance-parameters': instance._parameter_dict, 'instance-parameters': instance._parameter_dict,
'connection-parameters': connection_parameter_dict, 'connection-parameters': connection_parameter_dict,
......
...@@ -1118,6 +1118,11 @@ def hateoas_partitions(partition_reference): ...@@ -1118,6 +1118,11 @@ def hateoas_partitions(partition_reference):
'key': 'software_release', 'key': 'software_release',
'default': partition['software_release'], 'default': partition['software_release'],
}, },
'my_source_reference': {
'type': 'StringField',
'key': 'software_type',
'default': partition['software_type'],
},
}, },
}, },
'_links': { '_links': {
......
...@@ -662,6 +662,7 @@ class TestCliInfo(CliMixin): ...@@ -662,6 +662,7 @@ class TestCliInfo(CliMixin):
conn_params = '<instance>\n <parameter id="_">%s</parameter>\n</instance>' % json.dumps(conn) conn_params = '<instance>\n <parameter id="_">%s</parameter>\n</instance>' % json.dumps(conn)
instance = slapos.slap.SoftwareInstance( instance = slapos.slap.SoftwareInstance(
_software_release_url='SR1', _software_release_url='SR1',
_source_reference='mytype',
_requested_state='mystate', _requested_state='mystate',
_connection_dict=conn_params, _connection_dict=conn_params,
_parameter_dict={'myinstanceparameter': 'value2'}) _parameter_dict={'myinstanceparameter': 'value2'})
...@@ -682,6 +683,7 @@ class TestCliInfo(CliMixin): ...@@ -682,6 +683,7 @@ class TestCliInfo(CliMixin):
if six.PY3: if six.PY3:
expected = { expected = {
"software-url": instance._software_release_url, "software-url": instance._software_release_url,
"software-type": instance._source_reference,
"requested-state": instance._requested_state, "requested-state": instance._requested_state,
"instance-parameters": instance._parameter_dict, "instance-parameters": instance._parameter_dict,
"connection-parameters": { "connection-parameters": {
......
...@@ -1291,13 +1291,14 @@ class TestCliInformation(CliMasterMixin): ...@@ -1291,13 +1291,14 @@ class TestCliInformation(CliMasterMixin):
def test_service_info(self): def test_service_info(self):
self.format_for_number_of_partitions(3) self.format_for_number_of_partitions(3)
self.request('http://sr0//', None, 'MyInstance0', None) self.request('http://sr0//', None, 'MyInstance0', None)
self.request('http://sr1//', None, 'MyInstance1', None, partition_parameter_kw={'couscous': 'hello'}) self.request('http://sr1//', "MyType1", 'MyInstance1', None, partition_parameter_kw={'couscous': 'hello'})
self.request('http://sr2//', None, 'MyInstance2', 'slappart0') self.request('http://sr2//', None, 'MyInstance2', 'slappart0')
output0 = self.cliDoSlapos(('service', 'info', 'MyInstance0'), stderr=subprocess.DEVNULL) output0 = self.cliDoSlapos(('service', 'info', 'MyInstance0'), stderr=subprocess.DEVNULL)
self.assertEqual( self.assertEqual(
json.loads(output0), json.loads(output0),
{ {
"software-url": "http://sr0//", "software-url": "http://sr0//",
"software-type": "default",
"requested-state": "started", "requested-state": "started",
"instance-parameters": {}, "instance-parameters": {},
"connection-parameters": {}, "connection-parameters": {},
...@@ -1309,6 +1310,7 @@ class TestCliInformation(CliMasterMixin): ...@@ -1309,6 +1310,7 @@ class TestCliInformation(CliMasterMixin):
json.loads(output1), json.loads(output1),
{ {
"software-url": "http://sr1//", "software-url": "http://sr1//",
"software-type": "MyType1",
"requested-state": "started", "requested-state": "started",
"instance-parameters": {"couscous": "hello"}, "instance-parameters": {"couscous": "hello"},
"connection-parameters": {}, "connection-parameters": {},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment