
Add new command 'rsd storage list' to allow user to list all storage services brief info like below shows. $ openstack rsd storage list +----------+-----------------+-----------------------------+ | Identity | Name | Description | +----------+-----------------+-----------------------------+ | 1 | Storage Service | Storage Service for Testing | +----------+-----------------+-----------------------------+ Change-Id: Id54e630881de4c79f731ca93e6bf7a3c18fe6589
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
# Copyright 2017 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 os
|
|
|
|
from rsdclient.common import base
|
|
from rsdclient.common import utils
|
|
|
|
|
|
class StorageManager(base.Manager):
|
|
_resource_name = 'storages'
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(StorageManager, self).__init__(*args, **kwargs)
|
|
self.storage_service_path = self.client._storage_service_path
|
|
|
|
def _get_storage_service_uri(self, storage_service_id):
|
|
return os.path.join(self.storage_service_path, storage_service_id)
|
|
|
|
def list(self):
|
|
storage_service_collection = \
|
|
self.client.get_storage_service_collection()
|
|
storages = [utils.extract_attr(self.client.
|
|
get_storage_service(storage_uri))
|
|
for storage_uri in storage_service_collection.
|
|
members_identities]
|
|
storage_info_table = utils.print_dict(
|
|
storages, ["Identity", "Name", "Description"])
|
|
return storage_info_table
|