added various search options to list command. will need a version bump as i changed the 'list' api that nova uses. after version bump, my search nova branch will need pip-requires updated to match
This commit is contained in:
parent
0118cb3161
commit
5e987ffc30
novaclient
@ -210,8 +210,7 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
"""
|
"""
|
||||||
return self._get("/servers/%s" % base.getid(server), "server")
|
return self._get("/servers/%s" % base.getid(server), "server")
|
||||||
|
|
||||||
def list(self, detailed=True, fixed_ip=None, project_id=None,
|
def list(self, detailed=True, search_opts=None):
|
||||||
reservation_id=None, recurse_zones=None):
|
|
||||||
"""
|
"""
|
||||||
Get a list of servers.
|
Get a list of servers.
|
||||||
Optional detailed returns details server info.
|
Optional detailed returns details server info.
|
||||||
@ -220,15 +219,13 @@ class ServerManager(base.BootingManagerWithFind):
|
|||||||
|
|
||||||
:rtype: list of :class:`Server`
|
:rtype: list of :class:`Server`
|
||||||
"""
|
"""
|
||||||
|
if search_opts is None:
|
||||||
|
search_opts = {}
|
||||||
qparams = {}
|
qparams = {}
|
||||||
if reservation_id:
|
# only use values in query string if they are set
|
||||||
qparams['reservation_id'] = reservation_id
|
for opt, val in search_opts.iteritems():
|
||||||
if fixed_ip:
|
if val:
|
||||||
qparams['fixed_ip'] = fixed_ip
|
qparams[opt] = val
|
||||||
if project_id:
|
|
||||||
qparams['project_id'] = project_id
|
|
||||||
if recurse_zones:
|
|
||||||
qparams['recurse_zones'] = recurse_zones
|
|
||||||
|
|
||||||
query_string = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
query_string = "?%s" % urllib.urlencode(qparams) if qparams else ""
|
||||||
|
|
||||||
|
@ -582,18 +582,49 @@ class OpenStackShell(object):
|
|||||||
const=1,
|
const=1,
|
||||||
default=0,
|
default=0,
|
||||||
help='Recurse through all zones if set.')
|
help='Recurse through all zones if set.')
|
||||||
|
@arg('--ip',
|
||||||
|
dest='ip',
|
||||||
|
metavar='<ip_regexp>',
|
||||||
|
default=None,
|
||||||
|
help='Search with regular expression match by IP address')
|
||||||
|
@arg('--ip6',
|
||||||
|
dest='ip6',
|
||||||
|
metavar='<ip6_regexp>',
|
||||||
|
default=None,
|
||||||
|
help='Search with regular expression match by IPv6 address')
|
||||||
|
@arg('--server_name',
|
||||||
|
dest='server_name',
|
||||||
|
metavar='<name_regexp>',
|
||||||
|
default=None,
|
||||||
|
help='Search with regular expression match by server name')
|
||||||
|
@arg('--name',
|
||||||
|
dest='display_name',
|
||||||
|
metavar='<name_regexp>',
|
||||||
|
default=None,
|
||||||
|
help='Search with regular expression match by display name')
|
||||||
|
@arg('--instance_name',
|
||||||
|
dest='name',
|
||||||
|
metavar='<name_regexp>',
|
||||||
|
default=None,
|
||||||
|
help='Search with regular expression match by instance name')
|
||||||
def do_list(self, args):
|
def do_list(self, args):
|
||||||
"""List active servers."""
|
"""List active servers."""
|
||||||
reservation_id = args.reservation_id
|
|
||||||
fixed_ip = args.fixed_ip
|
|
||||||
recurse_zones = args.recurse_zones
|
recurse_zones = args.recurse_zones
|
||||||
|
search_opts = {
|
||||||
|
'reservation_id': args.reservation_id,
|
||||||
|
'fixed_ip': args.fixed_ip,
|
||||||
|
'recurse_zones': recurse_zones,
|
||||||
|
'ip': args.ip,
|
||||||
|
'ip6': args.ip6,
|
||||||
|
'name': args.name,
|
||||||
|
'server_name': args.server_name,
|
||||||
|
'display_name': args.display_name}
|
||||||
if recurse_zones:
|
if recurse_zones:
|
||||||
to_print = ['UUID', 'Name', 'Status', 'Public IP', 'Private IP']
|
to_print = ['UUID', 'Name', 'Status', 'Public IP', 'Private IP']
|
||||||
else:
|
else:
|
||||||
to_print = ['ID', 'Name', 'Status', 'Public IP', 'Private IP']
|
to_print = ['ID', 'Name', 'Status', 'Public IP', 'Private IP']
|
||||||
print_list(self.cs.servers.list(fixed_ip=fixed_ip,
|
print_list(self.cs.servers.list(search_opts=search_opts),
|
||||||
reservation_id=reservation_id,
|
to_print)
|
||||||
recurse_zones=recurse_zones), to_print)
|
|
||||||
|
|
||||||
@arg('--hard',
|
@arg('--hard',
|
||||||
dest='reboot_type',
|
dest='reboot_type',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user