quota: Split up 'quota list' command
This is really three separate commands rolled into one. Split the logic up more to simplify it somewhat. Change-Id: Ief3c3c413f791dda076f90e5ec76a033d3a9e12b Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -241,14 +241,10 @@ class ListQuota(command.Lister):
|
|||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def _list_quota_compute(self, parsed_args, project_ids):
|
||||||
result = []
|
|
||||||
project_ids = [
|
|
||||||
p.id for p in self.app.client_manager.identity.projects.list()
|
|
||||||
]
|
|
||||||
|
|
||||||
if parsed_args.compute:
|
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
|
result = []
|
||||||
|
|
||||||
for p in project_ids:
|
for p in project_ids:
|
||||||
try:
|
try:
|
||||||
data = compute_client.quotas.get(p)
|
data = compute_client.quotas.get(p)
|
||||||
@@ -309,8 +305,10 @@ class ListQuota(command.Lister):
|
|||||||
(utils.get_dict_properties(s, columns) for s in result),
|
(utils.get_dict_properties(s, columns) for s in result),
|
||||||
)
|
)
|
||||||
|
|
||||||
if parsed_args.volume:
|
def _list_quota_volume(self, parsed_args, project_ids):
|
||||||
volume_client = self.app.client_manager.volume
|
volume_client = self.app.client_manager.volume
|
||||||
|
result = []
|
||||||
|
|
||||||
for p in project_ids:
|
for p in project_ids:
|
||||||
try:
|
try:
|
||||||
data = volume_client.quotas.get(p)
|
data = volume_client.quotas.get(p)
|
||||||
@@ -360,8 +358,10 @@ class ListQuota(command.Lister):
|
|||||||
(utils.get_dict_properties(s, columns) for s in result),
|
(utils.get_dict_properties(s, columns) for s in result),
|
||||||
)
|
)
|
||||||
|
|
||||||
if parsed_args.network:
|
def _list_quota_network(self, parsed_args, project_ids):
|
||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
|
result = []
|
||||||
|
|
||||||
for p in project_ids:
|
for p in project_ids:
|
||||||
try:
|
try:
|
||||||
data = client.get_quota(p)
|
data = client.get_quota(p)
|
||||||
@@ -417,6 +417,18 @@ class ListQuota(command.Lister):
|
|||||||
(utils.get_dict_properties(s, columns) for s in result),
|
(utils.get_dict_properties(s, columns) for s in result),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
project_ids = [
|
||||||
|
p.id for p in self.app.client_manager.identity.projects.list()
|
||||||
|
]
|
||||||
|
if parsed_args.compute:
|
||||||
|
return self._list_quota_compute(parsed_args, project_ids)
|
||||||
|
elif parsed_args.volume:
|
||||||
|
return self._list_quota_volume(parsed_args, project_ids)
|
||||||
|
elif parsed_args.network:
|
||||||
|
return self._list_quota_network(parsed_args, project_ids)
|
||||||
|
|
||||||
|
# will never get here
|
||||||
return ((), ())
|
return ((), ())
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user