Add region_name in subcloud show parameters as default

In this commit, the dcmanager subcloud show command was updated
to display region_name as default.

Test Plan:
PASS: run dcmanager subcloud show <subcloud name> and verify that
region name is displayed
PASS: run dcmanager subcloud show <subcloud name> -d and verify that
region name is displayed

Closes-bug: 2054803

Change-Id: I4481b34a9406d84c28f0230385eee79b9cc82753
Signed-off-by: Christopher de Oliveira Souza <Christopher.DeOliveiraSouza@windriver.com>
This commit is contained in:
Christopher de Oliveira Souza 2024-02-23 08:34:08 -03:00 committed by Raphael Lima
parent 76029da32b
commit 0ffdaa3578
4 changed files with 22 additions and 19 deletions

View File

@ -108,8 +108,6 @@ class subcloud_manager(base.ResourceManager):
resource[0].oam_floating_ip = json_object['oam_floating_ip']
resource[0].deploy_config_sync_status = \
json_object['deploy_config_sync_status']
resource[0].region_name = \
json_object['region_name']
return resource
def add_subcloud(self, **kwargs):

View File

@ -82,7 +82,7 @@ def basic_detail_format(subcloud=None):
'backup_status',
'backup_datetime',
'prestage_status',
'prestage_versions'
'prestage_versions',
)
if subcloud:
@ -107,9 +107,8 @@ def basic_detail_format(subcloud=None):
subcloud.backup_status,
subcloud.backup_datetime,
subcloud.prestage_status,
subcloud.prestage_versions
subcloud.prestage_versions,
)
else:
data = (tuple('<none>' for _ in range(len(columns))),)
@ -118,7 +117,6 @@ def basic_detail_format(subcloud=None):
def detail_format(subcloud=None):
columns, data = basic_detail_format(subcloud)
if subcloud:
for _listitem, sync_status in enumerate(subcloud.endpoint_sync_status):
added_field = (sync_status['endpoint_type'] +
@ -135,10 +133,6 @@ def detail_format(subcloud=None):
columns += ('deploy_config_sync_status',)
data += (subcloud.deploy_config_sync_status,)
if subcloud.region_name is not None:
columns += ('region_name',)
data += (subcloud.region_name,)
return columns, data
@ -152,6 +146,14 @@ def detail_prestage_format(subcloud=None):
return columns, data
def detail_show_format(subcloud=None):
columns, data = detail_format(subcloud)
if subcloud:
columns += ('region_name',)
data += (subcloud.region_name,)
return columns, data
def detail_list_format(subcloud=None):
columns, data = basic_detail_format(subcloud)
@ -390,7 +392,7 @@ class ShowSubcloud(base.DCManagerShowOne):
"""Show the details of a subcloud."""
def _get_format_function(self):
return detail_format
return detail_show_format
def get_parser(self, prog_name):
parser = super(ShowSubcloud, self).get_parser(prog_name)

View File

@ -89,7 +89,8 @@ SUBCLOUD_RESOURCE = api_base.Subcloud(
backup_status=BACKUP_STATUS,
backup_datetime=BACKUP_DATETIME,
prestage_status=PRESTAGE_STATUS,
prestage_versions=PRESTAGE_VERSIONS)
prestage_versions=PRESTAGE_VERSIONS,
region_name=REGION_NAME)
# Subcloud CLI resource object with peerid rehome data
SUBCLOUD_RESOURCE_WITH_PEERID = api_base.Subcloud(

View File

@ -77,20 +77,22 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
self.client.subcloud_manager.subcloud_detail.\
return_value = [base.SUBCLOUD_RESOURCE]
actual_call = self.call(subcloud_cmd.ShowSubcloud, app_args=[base.ID])
self.assertEqual(
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID,
actual_call[1])
base.SUBCLOUD_FIELD_RESULT_LIST_WITH_PEERID + (base.REGION_NAME,),
actual_call[1]
)
def test_show_subcloud_with_additional_detail(self):
SUBCLOUD_WITH_ADDITIONAL_DETAIL = copy.copy(base.SUBCLOUD_RESOURCE)
SUBCLOUD_WITH_ADDITIONAL_DETAIL.oam_floating_ip = \
subcloud_with_additional_detail = copy.copy(base.SUBCLOUD_RESOURCE)
subcloud_with_additional_detail.oam_floating_ip = \
base.EXTERNAL_OAM_FLOATING_ADDRESS
SUBCLOUD_WITH_ADDITIONAL_DETAIL.deploy_config_sync_status = \
subcloud_with_additional_detail.deploy_config_sync_status = \
base.DEPLOY_CONFIG_SYNC_STATUS
SUBCLOUD_WITH_ADDITIONAL_DETAIL.region_name = \
subcloud_with_additional_detail.region_name = \
base.REGION_NAME
self.client.subcloud_manager.subcloud_additional_details.\
return_value = [SUBCLOUD_WITH_ADDITIONAL_DETAIL]
return_value = [subcloud_with_additional_detail]
actual_call = self.call(subcloud_cmd.ShowSubcloud,
app_args=[base.ID, '--detail'])
self.assertEqual(