Do not get all resources if ID is passed
Now function get_resource_id getting all resources even if exact ID is passed. And checking if ID is passed and call directly to get exact resource. If direct call failed - try to get ID as it was done before (important for case, when name is generated in UUID format). Change-Id: Ic66d5289afe1f8849e327f9347f9c3de8bb8b595 Story: 2006810 Task: 37365
This commit is contained in:
parent
cd6482966a
commit
16b2de14bd
|
@ -100,11 +100,9 @@ class ShowAmphora(command.ShowOne):
|
|||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
attrs = v2_utils.get_amphora_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
|
||||
data = self.app.client_manager.load_balancer.amphora_show(
|
||||
amphora_id=attrs.pop('amphora_id'),
|
||||
amphora_id=parsed_args.amphora_id,
|
||||
)
|
||||
|
||||
rows = const.AMPHORA_ROWS
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -162,13 +164,21 @@ class ShowFlavor(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.FLAVOR_ROWS
|
||||
attrs = v2_utils.get_flavor_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
flavor_id = attrs.pop('flavor_id')
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.flavor):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.flavor_show(
|
||||
flavor_id=parsed_args.flavor)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_flavor_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
flavor_id = attrs.pop('flavor_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.flavor_show(
|
||||
flavor_id=flavor_id
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.flavor_show(
|
||||
flavor_id=flavor_id
|
||||
)
|
||||
formatters = {'flavorprofiles': v2_utils.format_list}
|
||||
|
||||
return (rows, (utils.get_dict_properties(
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -132,13 +134,22 @@ class ShowFlavorProfile(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.FLAVORPROFILE_ROWS
|
||||
attrs = v2_utils.get_flavorprofile_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
flavorprofile_id = attrs.pop('flavorprofile_id')
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.flavorprofile):
|
||||
try:
|
||||
data = (
|
||||
self.app.client_manager.load_balancer.flavorprofile_show(
|
||||
flavorprofile_id=parsed_args.flavorprofile))
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_flavorprofile_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
flavorprofile_id = attrs.pop('flavorprofile_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.flavorprofile_show(
|
||||
flavorprofile_id=flavorprofile_id
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.flavorprofile_show(
|
||||
flavorprofile_id=flavorprofile_id
|
||||
)
|
||||
|
||||
return (rows, (utils.get_dict_properties(
|
||||
data, rows, formatters={})))
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -212,14 +214,23 @@ class ShowHealthMonitor(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.MONITOR_ROWS
|
||||
attrs = v2_utils.get_health_monitor_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.health_monitor):
|
||||
try:
|
||||
data = (
|
||||
self.app.client_manager.load_balancer.health_monitor_show(
|
||||
health_monitor_id=parsed_args.health_monitor))
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_health_monitor_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
|
||||
health_monitor_id = attrs.pop('health_monitor_id')
|
||||
health_monitor_id = attrs.pop('health_monitor_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.health_monitor_show(
|
||||
health_monitor_id=health_monitor_id,
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.health_monitor_show(
|
||||
health_monitor_id=health_monitor_id,
|
||||
)
|
||||
formatters = {'pools': v2_utils.format_list}
|
||||
|
||||
return (rows,
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -192,14 +194,22 @@ class ShowL7Policy(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.L7POLICY_ROWS
|
||||
attrs = v2_utils.get_l7policy_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.l7policy):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.l7policy_show(
|
||||
l7policy_id=parsed_args.l7policy)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_l7policy_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
|
||||
l7policy_id = attrs.pop('l7policy_id')
|
||||
l7policy_id = attrs.pop('l7policy_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.l7policy_show(
|
||||
l7policy_id=l7policy_id,
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.l7policy_show(
|
||||
l7policy_id=l7policy_id,
|
||||
)
|
||||
formatters = {'rules': v2_utils.format_list}
|
||||
|
||||
return (rows, (utils.get_dict_properties(
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -181,12 +183,22 @@ class ShowL7Rule(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.L7RULE_ROWS
|
||||
|
||||
attrs = v2_utils.get_l7rule_attrs(self.app.client_manager, parsed_args)
|
||||
data = self.app.client_manager.load_balancer.l7rule_show(
|
||||
l7rule_id=attrs['l7rule_id'],
|
||||
l7policy_id=attrs['l7policy_id']
|
||||
)
|
||||
data = None
|
||||
if (uuidutils.is_uuid_like(parsed_args.l7policy) and
|
||||
uuidutils.is_uuid_like(parsed_args.l7rule)):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.l7rule_show(
|
||||
l7rule_id=parsed_args.l7rule,
|
||||
l7policy_id=parsed_args.l7policy)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_l7rule_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
data = self.app.client_manager.load_balancer.l7rule_show(
|
||||
l7rule_id=attrs['l7rule_id'],
|
||||
l7policy_id=attrs['l7policy_id']
|
||||
)
|
||||
|
||||
return (rows, (utils.get_dict_properties(
|
||||
data, rows, formatters={})))
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -277,14 +279,22 @@ class ShowListener(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.LISTENER_ROWS
|
||||
attrs = v2_utils.get_listener_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.listener):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.listener_show(
|
||||
listener_id=parsed_args.listener)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_listener_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
|
||||
listener_id = attrs.pop('listener_id')
|
||||
listener_id = attrs.pop('listener_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.listener_show(
|
||||
listener_id=listener_id,
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.listener_show(
|
||||
listener_id=listener_id,
|
||||
)
|
||||
formatters = {'loadbalancers': v2_utils.format_list,
|
||||
'pools': v2_utils.format_list,
|
||||
'l7policies': v2_utils.format_list,
|
||||
|
|
|
@ -18,6 +18,7 @@ from osc_lib.command import command
|
|||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -304,13 +305,23 @@ class ShowLoadBalancer(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.LOAD_BALANCER_ROWS
|
||||
attrs = v2_utils.get_loadbalancer_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
lb_id = attrs.pop('loadbalancer_id')
|
||||
data = None
|
||||
|
||||
data = self.app.client_manager.load_balancer.load_balancer_show(
|
||||
lb_id=lb_id
|
||||
)
|
||||
if uuidutils.is_uuid_like(parsed_args.loadbalancer):
|
||||
try:
|
||||
data = (
|
||||
self.app.client_manager.load_balancer.load_balancer_show(
|
||||
lb_id=parsed_args.loadbalancer))
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
|
||||
if data is None:
|
||||
attrs = v2_utils.get_loadbalancer_attrs(
|
||||
self.app.client_manager, parsed_args)
|
||||
lb_id = attrs.pop('loadbalancer_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.load_balancer_show(
|
||||
lb_id=lb_id)
|
||||
|
||||
formatters = {
|
||||
'listeners': v2_utils.format_list,
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -75,13 +77,23 @@ class ShowMember(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.MEMBER_ROWS
|
||||
attrs = v2_utils.get_member_attrs(self.app.client_manager, parsed_args)
|
||||
data = None
|
||||
if (uuidutils.is_uuid_like(parsed_args.pool) and
|
||||
uuidutils.is_uuid_like(parsed_args.member)):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.member_show(
|
||||
pool_id=parsed_args.pool, member_id=parsed_args.member)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_member_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
|
||||
member_id = attrs.pop('member_id')
|
||||
pool_id = attrs.pop('pool_id')
|
||||
member_id = attrs.pop('member_id')
|
||||
pool_id = attrs.pop('pool_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.member_show(
|
||||
pool_id=pool_id, member_id=member_id)
|
||||
data = self.app.client_manager.load_balancer.member_show(
|
||||
pool_id=pool_id, member_id=member_id)
|
||||
|
||||
return (rows, (utils.get_dict_properties(
|
||||
data, rows, formatters={})))
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
from cliff import lister
|
||||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -207,13 +209,21 @@ class ShowPool(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.POOL_ROWS
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.pool):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.pool_show(
|
||||
pool_id=parsed_args.pool)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_pool_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
pool_id = attrs.pop('pool_id')
|
||||
|
||||
attrs = v2_utils.get_pool_attrs(self.app.client_manager, parsed_args)
|
||||
pool_id = attrs.pop('pool_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.pool_show(
|
||||
pool_id=pool_id,
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.pool_show(
|
||||
pool_id=pool_id,
|
||||
)
|
||||
formatters = {'loadbalancers': v2_utils.format_list,
|
||||
'members': v2_utils.format_list,
|
||||
'listeners': v2_utils.format_list,
|
||||
|
|
|
@ -20,6 +20,7 @@ from cliff import lister
|
|||
from osc_lib.command import command
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from octaviaclient.osc.v2 import constants as const
|
||||
from octaviaclient.osc.v2 import utils as v2_utils
|
||||
|
@ -66,13 +67,21 @@ class ShowQuota(command.ShowOne):
|
|||
|
||||
def take_action(self, parsed_args):
|
||||
rows = const.QUOTA_ROWS
|
||||
attrs = v2_utils.get_quota_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
project_id = attrs.pop('project_id')
|
||||
data = None
|
||||
if uuidutils.is_uuid_like(parsed_args.project):
|
||||
try:
|
||||
data = self.app.client_manager.load_balancer.quota_show(
|
||||
project_id=parsed_args.project)
|
||||
except exceptions.NotFound:
|
||||
pass
|
||||
if data is None:
|
||||
attrs = v2_utils.get_quota_attrs(self.app.client_manager,
|
||||
parsed_args)
|
||||
project_id = attrs.pop('project_id')
|
||||
|
||||
data = self.app.client_manager.load_balancer.quota_show(
|
||||
project_id=project_id
|
||||
)
|
||||
data = self.app.client_manager.load_balancer.quota_show(
|
||||
project_id=project_id
|
||||
)
|
||||
|
||||
return (rows, (utils.get_dict_properties(data, rows)))
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
If ID of resource is passed to resource show command - call is done
|
||||
directly using passed UUID. If name of resource is in UUID format - list of
|
||||
resources will be still executed to get correct resource ID.
|
Loading…
Reference in New Issue