From edc43c704a7fc71d8feb0fb8ba10087067df2716 Mon Sep 17 00:00:00 2001 From: Thomas S Hatch Date: Tue, 19 Jun 2012 00:30:48 -0600 Subject: [PATCH] Add provider management to Cloud class --- saltcloud/__init__.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/saltcloud/__init__.py b/saltcloud/__init__.py index 05d67d8ff8..c7d0c0a0cd 100644 --- a/saltcloud/__init__.py +++ b/saltcloud/__init__.py @@ -16,9 +16,21 @@ class Cloud(object): self.opts = opts self.clouds = saltcloud.loader.clouds(self.opts) - def run_data(self): + def provider(self, vm_): + ''' + Return the top level module that will be used for the given vm data + set + ''' + if 'provider' in vm_: + if '{0}.create'.format(vm_['provider']) in self.clouds: + return vm_['provider'] + if 'provider' in self.opts: + if '{0}.create'.format(self.opts['provider']) in self.clouds: + return self.opts['provider'] + + def create_all(self): ''' Create/Verify the vms in the vm data ''' for vm_ in self.opts['vm']: - self.create(vm_) + self.clouds['{0}.create'.format(self.provider(vm_))](vm_)