def build(name="autotest", branch="master", provisioner="rackspace", template_path=None, config=None, destroy=False, dry=False, log=None, log_level="INFO"): """ Builds an OpenStack Swift storage cluster """ util.set_log_level(log_level) # provisiong deployment util.config = Config(config) class_name = util.config["provisioners"][provisioner] cprovisioner = util.module_classes(provisioners)[class_name]() deployment = Chef.fromfile(name, branch, cprovisioner, template_path) if dry: # build environment try: deployment.update_environment() except Exception: util.logger.error(traceback.print_exc()) deployment.destroy() sys.exit(1) else: util.logger.info(deployment) # build deployment try: deployment.build() except Exception: util.logger.error(traceback.print_exc()) deployment.destroy() sys.exit(1) util.logger.info(deployment) if destroy: deployment.destroy()
def get_upgrade(self, upgrade): """ This will return an instance of the correct upgrade class :param upgrade: The name of the provisoner :type upgrade: String :rtype: object """ # convert branch into a list of int strings if 'v' in upgrade: branch_i = [int(x) for x in upgrade.strip('v').split('.')] else: branch_i = [int(x) for x in upgrade.split('.')] # convert list of int strings to their english counterpart word_b = [int2word(b) for b in branch_i] # convert list to class name up_class = "".join(word_b).replace(" ", "") up_class_module = "_".join(word_b).replace(" ", "") try: identifier = getattr(sys.modules['monster'].upgrades, up_class_module) except AttributeError: raise NameError("{0} doesn't exist.".format(up_class_module)) return util.module_classes(identifier)[up_class](self)
def add_features(self, features): """ Adds a dictionary of features to deployment :param features: dictionary of features {"monitoring": "default", ...} :type features: dict """ # stringify and lowercase classes in deployment features classes = util.module_classes(deployment_features) for feature, rpcs_feature in features.items(): util.logger.debug("feature: {0}, rpcs_feature: {1}".format( feature, rpcs_feature)) self.features.append(classes[feature](self, rpcs_feature))
def add_features(self, features): """ Adds a list of feature classes """ util.logger.debug("node:{0} feature add:{1}".format(self.name, features)) classes = util.module_classes(node_features) for feature in features: feature_class = classes[feature](self) self.features.append(feature_class) # save features for restore self.save_to_node()
def get_provisioner(provisioner): """ This will return an instance of the correct provisoner class :param provisioner: The name of the provisoner :type provisioner: String :rtype: object """ try: identifier = getattr(sys.modules['monster'].provisioners, provisioner) except AttributeError: raise NameError("{0} doesn't exist.".format(provisioner)) return module_classes(identifier)[provisioner]()
def get_provisioner(provisioner): """ This will return an instance of the correct provisioner class :param provisioner: The name of the provisioner :type provisioner: String :rtype: object """ try: identifier = getattr(sys.modules['monster'].provisioners, provisioner) except AttributeError: print(traceback.print_exc()) util.logger.error("The provisioner \"{0}\" was not found." .format(provisioner)) exit(1) return module_classes(identifier)[provisioner]()
def build(name="precise-swift", branch="master", provisioner="razor", template_path=None, config=None, destroy=False, dry=False, log=None, log_level="INFO"): """ Builds an OpenStack Swift storage cluster """ _set_log(log, log_level) # provisiong deployment util.config = Config(config) class_name = util.config["provisioners"][provisioner] cprovisioner = util.module_classes(provisioners)[class_name]() deployment = ChefDeployment.fromfile(name, branch, cprovisioner, template_path) if dry: # build environment try: deployment.update_environment() except Exception: util.logger.error(traceback.print_exc()) deployment.destroy() sys.exit(1) else: util.logger.info(deployment) # build deployment try: deployment.build() except Exception: util.logger.error(traceback.print_exc()) deployment.destroy() sys.exit(1) util.logger.info(deployment) if destroy: deployment.destroy()
def _load(name="precise-swift", config=None, provisioner="razor"): # load deployment and source openrc util.config = Config(config) class_name = util.config["provisioners"][provisioner] cprovisioner = util.module_classes(provisioners)[class_name]() return ChefDeployment.from_chef_environment(name, provisioner=cprovisioner)
def _load(name="autotest", config=None, provisioner="razor"): # load deployment and source openrc util.config = Config(config) class_name = util.config["provisioners"][provisioner] cprovisioner = util.module_classes(provisioners)[class_name]() return Chef.from_chef_environment(environment=cprovisioner)