def load_system_config(first_time = False): d = None try: if first_time: system_status_path, err = common.get_tmp_path() if err: raise Exception(err) else: system_status_path, err = common.get_system_status_path() if err: raise Exception(err) msfn = "%s/master.status"%system_status_path mmfn = "%s/master.manifest"%system_status_path with open(msfn, "r") as f: ms_nodes = json.load(f) with open(mmfn, "r") as f: mm_nodes = json.load(f) d = {} # First load it with the master node keys for k in mm_nodes.keys(): d[k] = mm_nodes[k] for k in d.keys(): if k not in ms_nodes: continue status_node = ms_nodes[k] for sk in status_node.keys(): if sk not in d[k]: d[k][sk] = status_node[sk] elif sk == "disks": for disk in status_node["disks"].keys(): if disk in d[k]["disks"]: d[k]["disks"][disk].update(status_node["disks"][disk]) ''' else: d[k]["disks"][disk] = status_node["disks"][disk] ''' elif sk == "interfaces": for interface in status_node["interfaces"].keys(): if interface in d[k]["interfaces"]: d[k]["interfaces"][interface].update(status_node["interfaces"][interface]) ''' else: d[k]["interfaces"][interface] = status_node["interfaces"][interface] ''' elif sk == "memory": for mem_key in status_node["memory"].keys(): if mem_key not in d[k]["memory"]: d[k]["memory"][mem_key] = status_node["memory"][mem_key] except Exception, e: return None, 'Error loading system configuration : %s'%str(e)
def load_system_config(first_time = False): if first_time: system_status_path = common.get_tmp_path() else: system_status_path = common.get_system_status_path() msfn = "%s/master.status"%system_status_path mmfn = "%s/master.manifest"%system_status_path with open(msfn, "r") as f: ms_nodes = json.load(f) with open(mmfn, "r") as f: mm_nodes = json.load(f) d = {} # First load it with the master node keys for k in mm_nodes.keys(): d[k] = mm_nodes[k] for k in d.keys(): if k not in ms_nodes: continue status_node = ms_nodes[k] for sk in status_node.keys(): if sk not in d[k]: d[k][sk] = status_node[sk] elif sk == "disks": for disk in status_node["disks"]: if disk in d[k]["disks"]: d[k]["disks"][disk].update(status_node["disks"][disk]) else: d[k]["disks"][disk] = status_node["disks"][disk] elif sk == "interfaces": for interface in status_node["interfaces"]: if interface in d[k]["interfaces"]: d[k]["interfaces"][interface].update(status_node["interfaces"][interface]) else: d[k]["interfaces"][interface] = status_node["interfaces"][interface] return d
def load_system_config(first_time=False): d = None try: if first_time: system_status_path, err = common.get_tmp_path() if err: raise Exception(err) else: system_status_path, err = common.get_system_status_path() if err: raise Exception(err) msfn = "%s/master.status" % system_status_path mmfn = "%s/master.manifest" % system_status_path with open(msfn, "r") as f: ms_nodes = json.load(f) with open(mmfn, "r") as f: mm_nodes = json.load(f) d = {} # First load it with the master node keys for k in mm_nodes.keys(): d[k] = mm_nodes[k] for k in d.keys(): if k not in ms_nodes: continue status_node = ms_nodes[k] for sk in status_node.keys(): if sk not in d[k]: d[k][sk] = status_node[sk] elif sk == "disks": for disk in status_node["disks"].keys(): if disk in d[k]["disks"]: d[k]["disks"][disk].update( status_node["disks"][disk]) pool_list, err = zfs.get_pools() if pool_list: for sn, disk in d[k]['disks'].items(): id = disk['id'] found = False for pool in pool_list: devices_list, err = zfs.get_disks_in_component( pool['config']['pool']['root']) if err: raise Exception(err) if devices_list and id in devices_list: disk['pool'] = pool['pool_name'] ''' else: d[k]["disks"][disk] = status_node["disks"][disk] ''' elif sk == "interfaces": for interface in status_node["interfaces"].keys(): if interface in d[k]["interfaces"]: d[k]["interfaces"][interface].update( status_node["interfaces"][interface]) ''' else: d[k]["interfaces"][interface] = status_node["interfaces"][interface] ''' elif sk == "memory": for mem_key in status_node["memory"].keys(): if mem_key not in d[k]["memory"]: d[k]["memory"][mem_key] = status_node["memory"][ mem_key] except Exception, e: return None, 'Error loading system configuration : %s' % str(e)