Commit 47ff8c75 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

cli/info: Include software-type in output

See merge request nexedi/slapos.core!505
parents cd88f42e 1e61c969
...@@ -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,
......
...@@ -1095,29 +1095,34 @@ def hateoas_partitions(partition_reference): ...@@ -1095,29 +1095,34 @@ def hateoas_partitions(partition_reference):
}, },
'my_reference': { 'my_reference': {
'type': 'StringField', 'type': 'StringField',
'key': 'partition_reference', 'key': 'field_my_reference',
'default': partition['partition_reference'], 'default': partition['partition_reference'],
}, },
'my_slap_state': { 'my_slap_state': {
'type': 'StringField', 'type': 'StringField',
'key': 'slap_state', 'key': 'field_my_slap_state',
'default': partition['requested_state'], 'default': partition['requested_state'],
}, },
'my_text_content': { 'my_text_content': {
'type': 'StringField', 'type': 'StringField',
'key': 'xml', 'key': 'field_my_text_content',
'default': partition['xml'], 'default': partition['xml'],
}, },
'my_connection_parameter_list': { 'my_connection_parameter_list': {
'type': 'StringField', 'type': 'StringField',
'key': 'connection_xml', 'key': 'field_my_connection_parameter_list',
'default': partition['connection_xml'], 'default': partition['connection_xml'],
}, },
'my_url_string': { 'my_url_string': {
'type': 'StringField', 'type': 'StringField',
'key': 'software_release', 'key': 'field_my_url_string',
'default': partition['software_release'], 'default': partition['software_release'],
}, },
'my_source_reference': {
'type': 'StringField',
'key': 'field_my_source_reference',
'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