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):
info = {
'software-url': instance._software_release_url,
'software-type': instance._source_reference,
'requested-state': instance._requested_state,
'instance-parameters': instance._parameter_dict,
'connection-parameters': connection_parameter_dict,
......
......@@ -1095,29 +1095,34 @@ def hateoas_partitions(partition_reference):
},
'my_reference': {
'type': 'StringField',
'key': 'partition_reference',
'key': 'field_my_reference',
'default': partition['partition_reference'],
},
'my_slap_state': {
'type': 'StringField',
'key': 'slap_state',
'key': 'field_my_slap_state',
'default': partition['requested_state'],
},
'my_text_content': {
'type': 'StringField',
'key': 'xml',
'key': 'field_my_text_content',
'default': partition['xml'],
},
'my_connection_parameter_list': {
'type': 'StringField',
'key': 'connection_xml',
'key': 'field_my_connection_parameter_list',
'default': partition['connection_xml'],
},
'my_url_string': {
'type': 'StringField',
'key': 'software_release',
'key': 'field_my_url_string',
'default': partition['software_release'],
},
'my_source_reference': {
'type': 'StringField',
'key': 'field_my_source_reference',
'default': partition['software_type'],
},
},
},
'_links': {
......
......@@ -662,6 +662,7 @@ class TestCliInfo(CliMixin):
conn_params = '<instance>\n <parameter id="_">%s</parameter>\n</instance>' % json.dumps(conn)
instance = slapos.slap.SoftwareInstance(
_software_release_url='SR1',
_source_reference='mytype',
_requested_state='mystate',
_connection_dict=conn_params,
_parameter_dict={'myinstanceparameter': 'value2'})
......@@ -682,6 +683,7 @@ class TestCliInfo(CliMixin):
if six.PY3:
expected = {
"software-url": instance._software_release_url,
"software-type": instance._source_reference,
"requested-state": instance._requested_state,
"instance-parameters": instance._parameter_dict,
"connection-parameters": {
......
......@@ -1291,13 +1291,14 @@ class TestCliInformation(CliMasterMixin):
def test_service_info(self):
self.format_for_number_of_partitions(3)
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')
output0 = self.cliDoSlapos(('service', 'info', 'MyInstance0'), stderr=subprocess.DEVNULL)
self.assertEqual(
json.loads(output0),
{
"software-url": "http://sr0//",
"software-type": "default",
"requested-state": "started",
"instance-parameters": {},
"connection-parameters": {},
......@@ -1309,6 +1310,7 @@ class TestCliInformation(CliMasterMixin):
json.loads(output1),
{
"software-url": "http://sr1//",
"software-type": "MyType1",
"requested-state": "started",
"instance-parameters": {"couscous": "hello"},
"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