def db_etcd_add(**kwargs): """ add etcd to db 添加参数时数据库操作函数 """ group_id_list = kwargs.pop('groups') etcd = Etcd(**kwargs) etcd.save() group_select = [] for group_id in group_id_list: group = EtcdGroup.objects.filter(id=group_id) group_select.extend(group) etcd.group = group_select
except Exception, e: return False else: table = data.sheets()[0] rows = table.nrows for row_num in range(1, rows): row = table.row_values(row_num) if row: group_instance = [] value, name, use_default_auth, group = row if get_object(Etcd, name=name): continue use_default_auth = 1 if use_default_auth == u'默认' else 0 if name: etcd = Etcd(value=value, name=name, use_default_auth=use_default_auth) etcd.save() group_list = group.split('/') for group_name in group_list: group = get_object(EtcdGroup, name=group_name) if group: group_instance.append(group) if group_instance: etcd.group = group_instance etcd.save() return True # def get_ansible_etcd_info(etcd_value, setup_info): # print etcd_value
except Exception, e: return False else: table = data.sheets()[0] rows = table.nrows for row_num in range(1, rows): row = table.row_values(row_num) if row: group_instance = [] value, name, use_default_auth, group = row if get_object(Etcd, name=name): continue use_default_auth = 1 if use_default_auth == u'默认' else 0 if name: etcd = Etcd(value=value, name=name, use_default_auth=use_default_auth ) etcd.save() group_list = group.split('/') for group_name in group_list: group = get_object(EtcdGroup, name=group_name) if group: group_instance.append(group) if group_instance: etcd.group = group_instance etcd.save() return True # def get_ansible_etcd_info(etcd_value, setup_info): # print etcd_value # pre_value = ','.join(pre_value_list) if pre_value_list else ''