Show OAM Floating IP for Subcloud

Extends the dcmanager subcloud show command to display the floating
OAM IP of the subcloud from the system controller.

Change-Id: If86fcedfa20a1e76faf73fe7ef3f695ca0aebb1e
Story: 2007267
Task: 38898
Depends-On: https://review.opendev.org/#/c/710873/
Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com>
This commit is contained in:
Jessica Castelino 2020-03-06 13:23:18 -05:00
parent 3e321d7310
commit 6d3215fa44
4 changed files with 56 additions and 5 deletions

View File

@ -46,6 +46,7 @@ class Subcloud(base.Resource):
self.management_state = management_state
self.availability_status = availability_status
self.deploy_status = deploy_status
self.oam_floating_ip = "unavailable"
self.management_start_ip = management_start_ip
self.management_end_ip = management_end_ip
self.management_gateway_ip = management_gateway_ip
@ -146,7 +147,7 @@ class subcloud_manager(base.ResourceManager):
endpoint_sync_status=json_object['endpoint_sync_status']))
return resource
def _subcloud_detail(self, url):
def _subcloud_detail(self, url, detail=None):
resp = self.http_client.get(url)
if resp.status_code != 200:
self._raise_api_exception(resp)
@ -172,6 +173,8 @@ class subcloud_manager(base.ResourceManager):
created_at=json_object['created-at'],
updated_at=json_object['updated-at'],
endpoint_sync_status=json_object['endpoint_sync_status']))
if detail is not None:
resource[0].oam_floating_ip = json_object['oam_floating_ip']
return resource
def add_subcloud(self, **kwargs):
@ -183,6 +186,10 @@ class subcloud_manager(base.ResourceManager):
url = '/subclouds/'
return self.subcloud_list(url)
def subcloud_additional_details(self, subcloud_ref):
url = '/subclouds/%s/detail' % subcloud_ref
return self._subcloud_detail(url, True)
def subcloud_detail(self, subcloud_ref):
url = '/subclouds/%s' % subcloud_ref
return self._subcloud_detail(url)

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright (c) 2017-2019 Wind River Systems, Inc.
# Copyright (c) 2017-2020 Wind River Systems, Inc.
#
# The right to copy, distribute, modify, or otherwise make use
# of this software may be licensed only pursuant to the terms
@ -101,6 +101,10 @@ def detail_format(subcloud=None):
added_value = (sync_status['sync_status'],)
columns += tuple(added_field)
data += tuple(added_value)
if subcloud.oam_floating_ip != "unavailable":
columns += ('oam_floating_ip',)
data += (subcloud.oam_floating_ip,)
else:
data = (tuple('<none>' for _ in range(len(columns))),)
@ -283,12 +287,23 @@ class ShowSubcloud(base.DCManagerShowOne):
help='Name or ID of subcloud to view the details.'
)
parser.add_argument(
'-d', '--detail',
action='store_true',
help="Show additional details for a subcloud"
)
return parser
def _get_resources(self, parsed_args):
subcloud_ref = parsed_args.subcloud
dcmanager_client = self.app.client_manager.subcloud_manager
return dcmanager_client.subcloud_manager.subcloud_detail(subcloud_ref)
if parsed_args.detail:
return dcmanager_client.subcloud_manager.\
subcloud_additional_details(subcloud_ref)
else:
return dcmanager_client.subcloud_manager.\
subcloud_detail(subcloud_ref)
class DeleteSubcloud(command.Command):

View File

@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Copyright (c) 2017 Wind River Systems, Inc.
# Copyright (c) 2017-2020 Wind River Systems, Inc.
#
# The right to copy, distribute, modify, or otherwise make use
# of this software may be licensed only pursuant to the terms
# of an applicable Wind River license agreement.
#
import copy
import mock
import os
import tempfile
@ -66,7 +67,8 @@ SUBCLOUD_DICT = {
'MANAGEMENT_GATEWAY_IP': MANAGEMENT_GATEWAY_IP,
'SYSTEMCONTROLLER_GATEWAY_IP': SYSTEMCONTROLLER_GATEWAY_IP,
'CREATED_AT': TIME_NOW,
'UPDATED_AT': TIME_NOW
'UPDATED_AT': TIME_NOW,
'OAM_FLOATING_IP': EXTERNAL_OAM_FLOATING_ADDRESS
}
SUBCLOUD = sm.Subcloud(
@ -132,6 +134,31 @@ class TestCLISubcloudManagerV1(base.BaseCommandTest):
TIME_NOW, TIME_NOW),
actual_call[1])
def test_show_subcloud_with_additional_detail(self):
SUBCLOUD_WITH_ADDITIONAL_DETAIL = copy.copy(SUBCLOUD)
setattr(SUBCLOUD_WITH_ADDITIONAL_DETAIL,
'oam_floating_ip',
SUBCLOUD_DICT['OAM_FLOATING_IP'])
self.client.subcloud_manager.subcloud_additional_details.\
return_value = [SUBCLOUD_WITH_ADDITIONAL_DETAIL]
actual_call = self.call(subcloud_cmd.ShowSubcloud,
app_args=[ID, '--detail'])
self.assertEqual((ID, NAME,
DESCRIPTION,
LOCATION,
SOFTWARE_VERSION,
MANAGEMENT_STATE,
AVAILABILITY_STATUS,
DEPLOY_STATUS,
MANAGEMENT_SUBNET,
MANAGEMENT_START_IP,
MANAGEMENT_END_IP,
MANAGEMENT_GATEWAY_IP,
SYSTEMCONTROLLER_GATEWAY_IP,
TIME_NOW, TIME_NOW,
EXTERNAL_OAM_FLOATING_ADDRESS),
actual_call[1])
def test_show_subcloud_negative(self):
self.client.subcloud_manager.subcloud_detail.return_value = []
actual_call = self.call(subcloud_cmd.ShowSubcloud, app_args=[ID])

View File

@ -3,6 +3,8 @@ minversion = 2.3
envlist = py27,pep8
skipsdist = True
toxworkdir = /tmp/{env:USER}_dc_client_tox
[dcclient]
client_base_dir = .