def fetch_hardware(): '''Autodetect which system we are trying to contact and perform hardware information fetch''' global partition_table global node_state global indexes global system_type # Generate a list of all possible nodecards in all possible partitions system = ComponentProxy('system', defer=True) if system_type is None: # We are self-discovering. Can save this step if we # already know the system type. system_type = system.get_implementation() if system_type in bg_types: partition_table = dict((part['name'], part['node_card_names']) for part in system.get_partitions([{'name': '*', 'node_card_names': '*'}])) node_state = {} elif system_type in cluster_types: partition_table = {} node_state = dict((node[0], node[1]) for node in system.get_node_status()) elif system_type in cray_types: partition_table = {} # Using JSON for speed and avoinding the XML-RPC marshaller. stst = json.loads(system.get_nodes(True, None, alps_system_query_fields, True)) indexes = {} for idx in stst: r = stst[idx] if r['status'] == 'busy': indexes[idx] = r['name'] node_state = dict((k, v['status']) for k, v in stst.iteritems()) else: raise RuntimeError('The %s system implementation is not supported by cweb') return system_type