Add generic get command to retrieve all resources
Change-Id: I530b5ca8a4e6f2ee673f31d0300c75b566f1379d
This commit is contained in:
parent
eab038832d
commit
f8e5ac2e7f
38
rsdclient/osc/v2/root.py
Normal file
38
rsdclient/osc/v2/root.py
Normal 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.
|
||||
#
|
||||
|
||||
import json
|
||||
|
||||
from rsdclient.common import command
|
||||
|
||||
|
||||
class GetResource(command.Command):
|
||||
"""Show the details of one RSD resource."""
|
||||
|
||||
_description = "Display the details of one RSD resource"
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(GetResource, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
"resource", metavar="<resource>", help="ID of the RSD resource."
|
||||
)
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)", parsed_args)
|
||||
rsd_client = self.app.client_manager.rsd
|
||||
resource_detail = rsd_client.root.get(parsed_args.resource)
|
||||
print("{0}".format(json.dumps(resource_detail, indent=2)))
|
@ -17,6 +17,7 @@ import rsd_lib
|
||||
|
||||
from rsdclient.v2 import fabric
|
||||
from rsdclient.v2 import node
|
||||
from rsdclient.v2 import root
|
||||
from rsdclient.v2 import storage_service
|
||||
from rsdclient.v2 import system
|
||||
|
||||
@ -39,6 +40,7 @@ class Client(object):
|
||||
|
||||
self.client = rsd_lib.RSDLib(base_url, username, password,
|
||||
verify=verify).factory()
|
||||
self.root = root.RootManager(self.client)
|
||||
self.node = node.NodeManager(self.client)
|
||||
self.storage_service = \
|
||||
storage_service.StorageServiceManager(self.client)
|
||||
|
30
rsdclient/v2/root.py
Normal file
30
rsdclient/v2/root.py
Normal file
@ -0,0 +1,30 @@
|
||||
# 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 RootManager(base.Manager):
|
||||
_resource_name = "root service"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RootManager, self).__init__(*args, **kwargs)
|
||||
|
||||
def show(self, resource_uri):
|
||||
resource = self.client.get_resource(resource_uri)
|
||||
resource_dict = utils.extract_attr(resource)
|
||||
|
||||
return resource_dict
|
@ -28,6 +28,8 @@ openstack.cli.extension =
|
||||
rsd = rsdclient.osc.plugin
|
||||
|
||||
openstack.rsd.v2 =
|
||||
rsd_get = rsdclient.osc.v2.root:GetResource
|
||||
|
||||
rsd_node_compose = rsdclient.osc.v2.node:ComposeNode
|
||||
rsd_node_delete = rsdclient.osc.v2.node:DeleteNode
|
||||
rsd_node_show = rsdclient.osc.v2.node:ShowNode
|
||||
|
Loading…
x
Reference in New Issue
Block a user