Support to show System resource details

Change-Id: Id1183cd7803b0e420ad22893bf101b7e6d5a2e0f
This commit is contained in:
Lin Yang 2019-03-18 15:09:51 -07:00
parent e8a24427c6
commit 2bffbbcc45
4 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,51 @@
# Copyright 2019 Intel, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
import json
from rsdclient.common import command
class ListSystem(command.Command):
"""List all systems."""
_description = "List all Systems"
def take_action(self, parsed_args):
self.log.debug("take_action(%s)", parsed_args)
rsd_client = self.app.client_manager.rsd
system_list = rsd_client.system.list()
print(system_list)
class ShowSystem(command.Command):
"""Show system details."""
_description = "Display system details"
def get_parser(self, prog_name):
parser = super(ShowSystem, self).get_parser(prog_name)
parser.add_argument(
'system',
metavar='<system>',
help='ID of the system.')
return parser
def take_action(self, parsed_args):
self.log.debug("take_action(%s)", parsed_args)
rsd_client = self.app.client_manager.rsd
system_detail = rsd_client.system.show(parsed_args.system)
print("{0}".format(json.dumps(system_detail, indent=2)))

View File

@ -18,6 +18,7 @@ import rsd_lib
from rsdclient.v2 import fabric
from rsdclient.v2 import node
from rsdclient.v2 import storage_service
from rsdclient.v2 import system
class Client(object):
@ -42,3 +43,4 @@ class Client(object):
self.storage_service = \
storage_service.StorageServiceManager(self.client)
self.fabric = fabric.FabricManager(self.client)
self.system = system.SystemManager(self.client)

38
rsdclient/v2/system.py Normal file
View File

@ -0,0 +1,38 @@
# Copyright 2019 Intel, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
from rsdclient.common import base
from rsdclient.common import utils
class SystemManager(base.Manager):
_resource_name = 'systems'
def __init__(self, *args, **kwargs):
super(SystemManager, self).__init__(*args, **kwargs)
self.systems_path = self.client._systems_path
def list(self):
system_collection = self.client.get_system_collection()
systems = [utils.extract_attr(self.client.get_system(system_uri))
for system_uri in system_collection.members_identities]
system_info_table = utils.print_dict(
systems, ["Identity", "Name", "Description"])
return system_info_table
def show(self, system_uri):
system = self.client.get_system(system_uri)
system_dict = utils.extract_attr(system)
return system_dict

View File

@ -55,6 +55,9 @@ openstack.rsd.v2 =
rsd_fabric_endpoint_list = rsdclient.osc.v2.fabric:ListEndpoint
rsd_fabric_endpoint_show = rsdclient.osc.v2.fabric:ShowEndpoint
rsd_system_show = rsdclient.osc.v2.system:ShowSystem
rsd_system_list = rsdclient.osc.v2.system:ListSystem
[build_sphinx]
all-files = 1
warning-is-error = 1