def create_cluster_template(self, values): # ensure defaults are present for new ClusterTemplates if not values.get('uuid'): values['uuid'] = uuidutils.generate_uuid() cluster_template = models.ClusterTemplate() cluster_template.update(values) try: cluster_template.save() except db_exc.DBDuplicateEntry: raise exception.ClusterTemplateAlreadyExists(uuid=values['uuid']) return cluster_template
def create_baymodel(self, values): # ensure defaults are present for new baymodels if not values.get('uuid'): values['uuid'] = uuidutils.generate_uuid() baymodel = models.BayModel() baymodel.update(values) try: baymodel.save() except db_exc.DBDuplicateEntry: raise exception.ClusterTemplateAlreadyExists(uuid=values['uuid']) return baymodel