[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
@ -137,12 +137,12 @@ class DeprecatedAuthPlugin(object):
|
||||
|
||||
def _load_endpoints(self):
|
||||
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:
|
||||
self.get_auth_url = fn
|
||||
|
||||
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:
|
||||
self.authenticate = fn
|
||||
|
||||
|
@ -332,7 +332,7 @@ def find_resource(manager, name_or_id, wrap_exception=True, **find_args):
|
||||
raise exceptions.NotFound(404, msg)
|
||||
|
||||
|
||||
def _format_servers_list_networks(server):
|
||||
def format_servers_list_networks(server):
|
||||
output = []
|
||||
for (network, addresses) in server.networks.items():
|
||||
if len(addresses) == 0:
|
||||
@ -344,7 +344,7 @@ def _format_servers_list_networks(server):
|
||||
return '; '.join(output)
|
||||
|
||||
|
||||
def _format_security_groups(groups):
|
||||
def format_security_groups(groups):
|
||||
return ', '.join(group['name'] for group in groups)
|
||||
|
||||
|
||||
@ -360,7 +360,7 @@ def _format_field_name(attr):
|
||||
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
|
||||
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)
|
||||
|
||||
|
||||
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."""
|
||||
for ep in pkg_resources.iter_entry_points(ep_name, name=name):
|
||||
try:
|
||||
|
@ -972,7 +972,7 @@ def do_network_list(cs, args):
|
||||
if network_list and not hasattr(network_list[0], field):
|
||||
non_existent_fields.append(field)
|
||||
continue
|
||||
field_title, formatter = utils._make_field_formatter(field, {})
|
||||
field_title, formatter = utils.make_field_formatter(field, {})
|
||||
field_titles.append(field_title)
|
||||
formatters[field_title] = formatter
|
||||
if non_existent_fields:
|
||||
@ -1504,7 +1504,7 @@ def do_list(cs, args):
|
||||
'changes-since': args.changes_since}
|
||||
|
||||
filters = {'flavor': lambda f: f['id'],
|
||||
'security_groups': utils._format_security_groups}
|
||||
'security_groups': utils.format_security_groups}
|
||||
|
||||
id_col = 'ID'
|
||||
|
||||
@ -1552,7 +1552,7 @@ def do_list(cs, args):
|
||||
if servers and not hasattr(servers[0], field):
|
||||
non_existent_fields.append(field)
|
||||
continue
|
||||
field_title, formatter = utils._make_field_formatter(field,
|
||||
field_title, formatter = utils.make_field_formatter(field,
|
||||
filters)
|
||||
field_titles.append(field_title)
|
||||
formatters[field_title] = formatter
|
||||
@ -1582,7 +1582,7 @@ def do_list(cs, args):
|
||||
columns.insert(2, 'Tenant ID')
|
||||
if search_opts['changes-since']:
|
||||
columns.append('Updated')
|
||||
formatters['Networks'] = utils._format_servers_list_networks
|
||||
formatters['Networks'] = utils.format_servers_list_networks
|
||||
sortby_index = 1
|
||||
if args.sort:
|
||||
sortby_index = None
|
||||
@ -3699,7 +3699,7 @@ def do_server_migration_list(cs, args):
|
||||
"memory_remaining_bytes", "disk_total_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)
|
||||
formatters = dict(zip(format_name, formatters))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user