Permalink
Browse files

salt.cloud: allow specific per node profile overrides

  • Loading branch information...
1 parent 918d85d commit 9f27fa05d29b812a6c3119c6e6aabeb393611e00 @kiorky kiorky committed Mar 5, 2014
Showing with 13 additions and 6 deletions.
  1. +10 −3 salt/cloud/__init__.py
  2. +2 −2 salt/modules/cloud.py
  3. +1 −1 salt/states/cloud.py
View
13 salt/cloud/__init__.py
@@ -251,15 +251,19 @@ def select_query(self, query_type='list_nodes_select'):
mapper = salt.cloud.Map(self._opts_defaults())
return mapper.map_providers_parallel(query_type)
- def profile(self, profile, names, **kwargs):
+ def profile(self, profile, names, vm_opts=None, **kwargs):
'''
Pass in a profile to create, names is a list of vm names to allocate
+
+ vm_opts is a spetial dict that will be per node options overrides
'''
+ if not vm_opts:
+ vm_opts = {}
mapper = salt.cloud.Map(self._opts_defaults(**kwargs))
if isinstance(names, str):
names = names.split(',')
return salt.utils.cloud.simple_types_filter(
- mapper.run_profile(profile, names))
+ mapper.run_profile(profile, names, vm_opts=vm_opts))
def destroy(self, names):
'''
@@ -1055,7 +1059,7 @@ def create(self, vm_, local_master=True):
output['ret'] = action_out
return output
- def run_profile(self, profile, names):
+ def run_profile(self, profile, names, vm_opts=None):
'''
Parse over the options passed on the command line and determine how to
handle them
@@ -1066,6 +1070,8 @@ def run_profile(self, profile, names):
return {'Error': msg}
ret = {}
+ if not vm_opts:
+ vm_opts = {}
profile_details = self.opts['profiles'][profile]
alias, driver = profile_details['provider'].split(':')
mapped_providers = self.map_providers_parallel()
@@ -1082,6 +1088,7 @@ def run_profile(self, profile, names):
continue
vm_ = profile_details.copy()
+ vm_.update(vm_opts)
vm_['name'] = name
if self.opts['parallel']:
process = multiprocessing.Process(
View
4 salt/modules/cloud.py
@@ -130,7 +130,7 @@ def select_query(query_type='list_nodes_select'):
return query(query_type='list_nodes_select')
-def profile_(profile, names, **kwargs):
+def profile_(profile, names, vm_opts=None, **kwargs):
'''
Spin up an instance using Salt Cloud
@@ -141,7 +141,7 @@ def profile_(profile, names, **kwargs):
salt '*' cloud.profile my-gce-config myinstance
'''
client = _get_client()
- info = client.profile(profile, names, **kwargs)
+ info = client.profile(profile, names, vm_opts=vm_opts, **kwargs)
return info
View
2 salt/states/cloud.py
@@ -234,7 +234,7 @@ def profile(name, profile, onlyif=None, unless=None, **kwargs):
if __opts__['test']:
ret['comment'] = 'Instance {0} needs to be created'.format(name)
return ret
- info = __salt__['cloud.profile'](profile, name, **kwargs)
+ info = __salt__['cloud.profile'](profile, name, vm_opts=kwargs)
if info and not 'Error' in info:
ret['changes'] = info
ret['result'] = True

0 comments on commit 9f27fa0

Please sign in to comment.