[Trivial] change some functions in novaclient/utils.py to public
There are some functions in novaclient/utils.py which have name with prefix `_`, in Python, this means it is a private function which should be only used in its own module. However, these functions are used in other modules such as novaclient/v2/shell.py. This patch removes the prefix _ for these functions. Change-Id: I7bc8a76fd390a7dd30eecbb5c7e641b6ccfb40c0
This commit is contained in:
parent
3bed5446d7
commit
c22cbb6fac
novaclient
@ -137,12 +137,12 @@ class DeprecatedAuthPlugin(object):
|
|||||||
|
|
||||||
def _load_endpoints(self):
|
def _load_endpoints(self):
|
||||||
ep_name = 'openstack.client.auth_url'
|
ep_name = 'openstack.client.auth_url'
|
||||||
fn = utils._load_entry_point(ep_name, name=self.auth_system)
|
fn = utils.load_entry_point(ep_name, name=self.auth_system)
|
||||||
if fn:
|
if fn:
|
||||||
self.get_auth_url = fn
|
self.get_auth_url = fn
|
||||||
|
|
||||||
ep_name = 'openstack.client.authenticate'
|
ep_name = 'openstack.client.authenticate'
|
||||||
fn = utils._load_entry_point(ep_name, name=self.auth_system)
|
fn = utils.load_entry_point(ep_name, name=self.auth_system)
|
||||||
if fn:
|
if fn:
|
||||||
self.authenticate = fn
|
self.authenticate = fn
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ def find_resource(manager, name_or_id, wrap_exception=True, **find_args):
|
|||||||
raise exceptions.NotFound(404, msg)
|
raise exceptions.NotFound(404, msg)
|
||||||
|
|
||||||
|
|
||||||
def _format_servers_list_networks(server):
|
def format_servers_list_networks(server):
|
||||||
output = []
|
output = []
|
||||||
for (network, addresses) in server.networks.items():
|
for (network, addresses) in server.networks.items():
|
||||||
if len(addresses) == 0:
|
if len(addresses) == 0:
|
||||||
@ -344,7 +344,7 @@ def _format_servers_list_networks(server):
|
|||||||
return '; '.join(output)
|
return '; '.join(output)
|
||||||
|
|
||||||
|
|
||||||
def _format_security_groups(groups):
|
def format_security_groups(groups):
|
||||||
return ', '.join(group['name'] for group in groups)
|
return ', '.join(group['name'] for group in groups)
|
||||||
|
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ def _format_field_name(attr):
|
|||||||
return ': '.join(parts)
|
return ': '.join(parts)
|
||||||
|
|
||||||
|
|
||||||
def _make_field_formatter(attr, filters=None):
|
def make_field_formatter(attr, filters=None):
|
||||||
"""
|
"""
|
||||||
Given an object attribute, return a formatted field name and a
|
Given an object attribute, return a formatted field name and a
|
||||||
formatter suitable for passing to print_list.
|
formatter suitable for passing to print_list.
|
||||||
@ -412,7 +412,7 @@ def do_action_on_many(action, resources, success_msg, error_msg):
|
|||||||
raise exceptions.CommandError(error_msg)
|
raise exceptions.CommandError(error_msg)
|
||||||
|
|
||||||
|
|
||||||
def _load_entry_point(ep_name, name=None):
|
def load_entry_point(ep_name, name=None):
|
||||||
"""Try to load the entry point ep_name that matches name."""
|
"""Try to load the entry point ep_name that matches name."""
|
||||||
for ep in pkg_resources.iter_entry_points(ep_name, name=name):
|
for ep in pkg_resources.iter_entry_points(ep_name, name=name):
|
||||||
try:
|
try:
|
||||||
|
@ -972,7 +972,7 @@ def do_network_list(cs, args):
|
|||||||
if network_list and not hasattr(network_list[0], field):
|
if network_list and not hasattr(network_list[0], field):
|
||||||
non_existent_fields.append(field)
|
non_existent_fields.append(field)
|
||||||
continue
|
continue
|
||||||
field_title, formatter = utils._make_field_formatter(field, {})
|
field_title, formatter = utils.make_field_formatter(field, {})
|
||||||
field_titles.append(field_title)
|
field_titles.append(field_title)
|
||||||
formatters[field_title] = formatter
|
formatters[field_title] = formatter
|
||||||
if non_existent_fields:
|
if non_existent_fields:
|
||||||
@ -1504,7 +1504,7 @@ def do_list(cs, args):
|
|||||||
'changes-since': args.changes_since}
|
'changes-since': args.changes_since}
|
||||||
|
|
||||||
filters = {'flavor': lambda f: f['id'],
|
filters = {'flavor': lambda f: f['id'],
|
||||||
'security_groups': utils._format_security_groups}
|
'security_groups': utils.format_security_groups}
|
||||||
|
|
||||||
id_col = 'ID'
|
id_col = 'ID'
|
||||||
|
|
||||||
@ -1552,7 +1552,7 @@ def do_list(cs, args):
|
|||||||
if servers and not hasattr(servers[0], field):
|
if servers and not hasattr(servers[0], field):
|
||||||
non_existent_fields.append(field)
|
non_existent_fields.append(field)
|
||||||
continue
|
continue
|
||||||
field_title, formatter = utils._make_field_formatter(field,
|
field_title, formatter = utils.make_field_formatter(field,
|
||||||
filters)
|
filters)
|
||||||
field_titles.append(field_title)
|
field_titles.append(field_title)
|
||||||
formatters[field_title] = formatter
|
formatters[field_title] = formatter
|
||||||
@ -1582,7 +1582,7 @@ def do_list(cs, args):
|
|||||||
columns.insert(2, 'Tenant ID')
|
columns.insert(2, 'Tenant ID')
|
||||||
if search_opts['changes-since']:
|
if search_opts['changes-since']:
|
||||||
columns.append('Updated')
|
columns.append('Updated')
|
||||||
formatters['Networks'] = utils._format_servers_list_networks
|
formatters['Networks'] = utils.format_servers_list_networks
|
||||||
sortby_index = 1
|
sortby_index = 1
|
||||||
if args.sort:
|
if args.sort:
|
||||||
sortby_index = None
|
sortby_index = None
|
||||||
@ -3699,7 +3699,7 @@ def do_server_migration_list(cs, args):
|
|||||||
"memory_remaining_bytes", "disk_total_bytes",
|
"memory_remaining_bytes", "disk_total_bytes",
|
||||||
"disk_processed_bytes", "disk_remaining_bytes"]
|
"disk_processed_bytes", "disk_remaining_bytes"]
|
||||||
|
|
||||||
formatters = map(lambda field: utils._make_field_formatter(field)[1],
|
formatters = map(lambda field: utils.make_field_formatter(field)[1],
|
||||||
format_key)
|
format_key)
|
||||||
formatters = dict(zip(format_name, formatters))
|
formatters = dict(zip(format_name, formatters))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user