mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Merge pull request #79 from techhat/develop
Add --full-query option to salt-cloud
This commit is contained in:
commit
61decf7464
@ -99,8 +99,16 @@ class SaltCloud(object):
|
||||
dest='query',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help=('Execute a query and return information about the nodes '
|
||||
'running on configured cloud providers'))
|
||||
help=('Execute a query and return some information about the '
|
||||
'nodes running on configured cloud providers'))
|
||||
|
||||
parser.add_option('-F',
|
||||
'--full-query',
|
||||
dest='full_query',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help=('Execute a query and return all information about the '
|
||||
'nodes running on configured cloud providers'))
|
||||
|
||||
parser.add_option('--list-images',
|
||||
dest='list_images',
|
||||
@ -199,7 +207,7 @@ class SaltCloud(object):
|
||||
import saltcloud.cloud
|
||||
mapper = saltcloud.cloud.Map(self.opts)
|
||||
|
||||
if self.opts['query']:
|
||||
if self.opts['query'] or self.opts['full_query']:
|
||||
get_outputter = salt.output.get_outputter
|
||||
if self.opts['raw_out']:
|
||||
printout = get_outputter('raw')
|
||||
@ -212,8 +220,12 @@ class SaltCloud(object):
|
||||
else:
|
||||
printout = get_outputter(None)
|
||||
|
||||
query = 'list_nodes'
|
||||
if self.opts['full_query']:
|
||||
query = 'list_nodes_full'
|
||||
|
||||
color = not bool(self.opts['no_color'])
|
||||
printout(mapper.map_providers(), color=color)
|
||||
printout(mapper.map_providers(query=query), color=color)
|
||||
|
||||
if self.opts['version']:
|
||||
print VERSION
|
||||
|
@ -48,7 +48,7 @@ class Cloud(object):
|
||||
provs.add(fun[:fun.index('.')])
|
||||
return provs
|
||||
|
||||
def map_providers(self):
|
||||
def map_providers(self, query='list_nodes'):
|
||||
'''
|
||||
Return a mapping of what named vms are running on what vm providers
|
||||
based on what providers are defined in the configs and vms
|
||||
@ -56,7 +56,7 @@ class Cloud(object):
|
||||
provs = self.get_providers()
|
||||
pmap = {}
|
||||
for prov in provs:
|
||||
fun = '{0}.list_nodes'.format(prov)
|
||||
fun = '{0}.{1}'.format(prov, query)
|
||||
if not fun in self.clouds:
|
||||
print('Public cloud provider {0} is not available'.format(
|
||||
self.provider(vm_))
|
||||
|
@ -48,6 +48,7 @@ avail_sizes = types.FunctionType(avail_sizes.__code__, globals())
|
||||
script = types.FunctionType(script.__code__, globals())
|
||||
destroy = types.FunctionType(destroy.__code__, globals())
|
||||
list_nodes = types.FunctionType(list_nodes.__code__, globals())
|
||||
list_nodes_full = types.FunctionType(list_nodes_full.__code__, globals())
|
||||
|
||||
|
||||
# Only load in this module if the AWS configurations are in place
|
||||
|
@ -43,6 +43,7 @@ avail_sizes = types.FunctionType(avail_sizes.__code__, globals())
|
||||
script = types.FunctionType(script.__code__, globals())
|
||||
destroy = types.FunctionType(destroy.__code__, globals())
|
||||
list_nodes = types.FunctionType(list_nodes.__code__, globals())
|
||||
list_nodes_full = types.FunctionType(list_nodes_full.__code__, globals())
|
||||
|
||||
|
||||
# Only load in this module is the GOGRID configurations are in place
|
||||
|
@ -42,6 +42,7 @@ avail_sizes = types.FunctionType(avail_sizes.__code__, globals())
|
||||
script = types.FunctionType(script.__code__, globals())
|
||||
destroy = types.FunctionType(destroy.__code__, globals())
|
||||
list_nodes = types.FunctionType(list_nodes.__code__, globals())
|
||||
list_nodes_full = types.FunctionType(list_nodes_full.__code__, globals())
|
||||
|
||||
|
||||
# Only load in this module is the JOYENT configurations are in place
|
||||
|
@ -35,6 +35,7 @@ avail_sizes = types.FunctionType(avail_sizes.__code__, globals())
|
||||
script = types.FunctionType(script.__code__, globals())
|
||||
destroy = types.FunctionType(destroy.__code__, globals())
|
||||
list_nodes = types.FunctionType(list_nodes.__code__, globals())
|
||||
list_nodes_full = types.FunctionType(list_nodes_full.__code__, globals())
|
||||
|
||||
|
||||
# Only load in this module if the LINODE configurations are in place
|
||||
|
@ -42,6 +42,7 @@ avail_sizes = types.FunctionType(avail_sizes.__code__, globals())
|
||||
script = types.FunctionType(script.__code__, globals())
|
||||
destroy = types.FunctionType(destroy.__code__, globals())
|
||||
list_nodes = types.FunctionType(list_nodes.__code__, globals())
|
||||
list_nodes_full = types.FunctionType(list_nodes_full.__code__, globals())
|
||||
|
||||
|
||||
# Only load in this module is the RACKSPACE configurations are in place
|
||||
|
@ -156,3 +156,18 @@ def list_nodes():
|
||||
'size': node.size,
|
||||
'state': node.state}
|
||||
return ret
|
||||
|
||||
def list_nodes_full():
|
||||
'''
|
||||
Return a list of the vms that are on the provider
|
||||
'''
|
||||
conn = get_conn()
|
||||
nodes = conn.list_nodes()
|
||||
ret = {}
|
||||
for node in nodes:
|
||||
pairs = {}
|
||||
for key, value in zip(node.__dict__.keys(), node.__dict__.values()):
|
||||
pairs[key] = value
|
||||
ret[node.name] = pairs
|
||||
return ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user