mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Add the ability to filter the map file with salt-cloud
This commit is contained in:
parent
ddba73a4f4
commit
21a6f6f0e7
3 changed files with 20 additions and 2 deletions
|
@ -40,6 +40,10 @@ Provision virtual machines in the cloud with Salt
|
|||
.ft C
|
||||
salt\-cloud \-m /etc/salt/cloud.map
|
||||
|
||||
salt\-cloud \-m /etc/salt/cloud.map NAME
|
||||
|
||||
salt\-cloud \-m /etc/salt/cloud.map NAME1 NAME2
|
||||
|
||||
salt\-cloud \-p PROFILE NAME
|
||||
|
||||
salt\-cloud \-p PROFILE NAME1 NAME2 NAME3 NAME4 NAME5 NAME6
|
||||
|
@ -67,8 +71,9 @@ must be defined in the specified profiles file.
|
|||
.TP
|
||||
.B \-m MAP, \-\-map=MAP
|
||||
Specify a map file to use. If used without any other options, this option
|
||||
will ensure that all of the mapped VMs are created. If the named VM
|
||||
already exists then it will be skipped.
|
||||
will ensure that all of the mapped VMs are created. If VM names are
|
||||
also passed as arguments, they will be used to filter the map file.
|
||||
If the named VM already exists then it will be skipped.
|
||||
.UNINDENT
|
||||
.INDENT 0.0
|
||||
.TP
|
||||
|
|
|
@ -85,6 +85,18 @@ class SaltCloud(parsers.SaltCloudParser):
|
|||
log.info('salt-cloud starting')
|
||||
mapper = salt.cloud.Map(self.config)
|
||||
|
||||
names = self.config.get('names', None)
|
||||
if names != None:
|
||||
filtered_rendered_map = {}
|
||||
for map_profile in mapper.rendered_map:
|
||||
filtered_map_profile = {}
|
||||
for name in mapper.rendered_map[map_profile]:
|
||||
if name in names:
|
||||
filtered_map_profile[name] = mapper.rendered_map[map_profile][name]
|
||||
if filtered_map_profile:
|
||||
filtered_rendered_map[map_profile] = filtered_map_profile
|
||||
mapper.rendered_map = filtered_rendered_map
|
||||
|
||||
ret = {}
|
||||
|
||||
if self.selected_query_option is not None:
|
||||
|
|
|
@ -1127,6 +1127,7 @@ class ExecutionOptionsMixIn(object):
|
|||
default=None,
|
||||
help='Specify a cloud map file to use for deployment. This option '
|
||||
'may be used alone, or in conjunction with -Q, -F, -S or -d.'
|
||||
'The map can also be filtered by a list of VM names.'
|
||||
)
|
||||
group.add_option(
|
||||
'-H', '--hard',
|
||||
|
|
Loading…
Add table
Reference in a new issue