python-rsdclient/rsdclient/osc/v2/root.py

39 lines
1.3 KiB
Python

# 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)))