def run(self): cloud = saltcloud.cli.SaltCloud() if self.profile == 'master': cloud.parse_args = functools.partial( SaltCloudProfile._master_parse_args, cloud.parse_args, self, cloud) else: cloud.parse_args = functools.partial( SaltCloudProfile._minion_parse_args, cloud.parse_args, self, cloud) cloud.run()
def destroy(names=None, cloud_config=None, cloud_providers=None, cloud_profiles=None, master_config=None): cloudseed_args = ['--destroy', '--out', 'quiet'] if cloud_config: cloudseed_args += ['--cloud-config', cloud_config] if cloud_providers: cloudseed_args += ['--providers-config', cloud_providers] if cloud_profiles: cloudseed_args += ['--profiles', cloud_profiles] if master_config: cloudseed_args += ['--master-config', master_config] def parse_args(original_parse_args, self, args=None, values=None): original_parse_args(args=cloudseed_args) # redirect log output self.config['log_file'] = os.devnull # override the initial lookup path for modules. # ensure that our local clouds are searched first, if present # This works with salt.loader.Loader self.config['extension_modules'] = os.path.join( os.path.dirname(cloudseed.__file__)) if not names: cloud = cloudseed.cloud.Cloud(self.config) vm_ = cloud.vm_profile('master') alias, driver = cloud.lookup_providers(vm_['provider']) fun = '%s.list_nodes' % driver data = cloud.clouds[fun]() self.config['names'] = data.keys() #self.config['names'] = ['cloudseed-sample-foo'] else: self.config['names'] = names cloud = saltcloud.cli.SaltCloud() cloud.parse_args = functools.partial(parse_args, cloud.parse_args, cloud) cloud.run()
def destroy(names=None, cloud_config=None, cloud_providers=None, cloud_profiles=None, master_config=None): cloudseed_args = ['--destroy', '--out', 'quiet'] if cloud_config: cloudseed_args += ['--cloud-config', cloud_config] if cloud_providers: cloudseed_args += ['--providers-config', cloud_providers] if cloud_profiles: cloudseed_args += ['--profiles', cloud_profiles] if master_config: cloudseed_args += ['--master-config', master_config] def parse_args(original_parse_args, self, args=None, values=None): original_parse_args(args=cloudseed_args) # redirect log output self.config['log_file'] = os.devnull # override the initial lookup path for modules. # ensure that our local clouds are searched first, if present # This works with salt.loader.Loader self.config['extension_modules'] = os.path.join( os.path.dirname(cloudseed.__file__)) if not names: cloud = cloudseed.cloud.Cloud(self.config) vm_ = cloud.vm_profile('master') alias, driver = cloud.lookup_providers(vm_['provider']) fun = '%s.list_nodes' % driver data = cloud.clouds[fun]() self.config['names'] = data.keys() #self.config['names'] = ['cloudseed-sample-foo'] else: self.config['names'] = names cloud = saltcloud.cli.SaltCloud() cloud.parse_args = functools.partial( parse_args, cloud.parse_args, cloud) cloud.run()