Add Attribute api client

Client for list attribute api

Change-Id: I25391f14352658214fa1fef90e8db2c8ce9bbd40
This commit is contained in:
songwenping
2023-05-16 17:47:04 +08:00
parent 491b85e9a6
commit 91cf9d7715
2 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
# 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.
#
"""Cyborg v2 Acceleration accelerator action implementations"""
from osc_lib.command import command
from osc_lib import utils as oscutils
from cyborgclient.i18n import _
class ListAttribute(command.Lister):
"""List all attributes"""
column_headers = (
"uuid",
"deployable_id",
"key",
"value"
)
columns = (
"uuid",
"deployable_id",
"key",
"value"
)
detail_cols = ("created_at", "updated_at")
def get_parser(self, prog_name):
parser = super(ListAttribute, self).get_parser(prog_name)
parser.add_argument(
'--long',
dest='detail',
action='store_true',
default=False,
help=_("List additional fields in output")
)
return parser
def take_action(self, parsed_args):
acc_client = self.app.client_manager.accelerator
if parsed_args.detail:
self.column_headers += self.detail_cols
self.columns += self.detail_cols
data = acc_client.attributes()
if not data:
return (), ()
formatters = {}
return (self.column_headers,
(oscutils.get_item_properties(
s, self.columns, formatters=formatters) for s in data))

View File

@@ -40,6 +40,7 @@ openstack.accelerator.v2 =
accelerator_deployable_show = cyborgclient.osc.v2.deployable:ShowDeployable
accelerator_device_list = cyborgclient.osc.v2.device:ListDevice
accelerator_device_show = cyborgclient.osc.v2.device:ShowDevice
accelerator_device_attribute_list = cyborgclient.osc.v2.attribute:ListAttribute
accelerator_device_profile_list = cyborgclient.osc.v2.device_profile:ListDeviceProfile
accelerator_device_profile_create = cyborgclient.osc.v2.device_profile:CreateDeviceProfile
accelerator_device_profile_delete = cyborgclient.osc.v2.device_profile:DeleteDeviceProfile