elif line.startswith('SwapTotal'): memory.VirtualSize = int(line.split()[-2]) / 1024 + ramsize # override with specific values for key in ('RAMSize', 'VirtualSize'): if config.MainMemory.__dict__[key] is not None: memory.__dict__[key] = config.MainMemory.__dict__[key] if config.OperatingSystem is not None: os_ = lib.OperatingSystem() # do file first if config.OperatingSystem.File is not None: if os.path.isfile(config.OperatingSystem.File): lines = lib.run_command([config.OperatingSystem.File, '-a']) for line in lines: if line.startswith('Distributor'): os_.Release = " ".join(line.split()[2:]) elif line.startswith('Description'): os_.Name = " ".join(line.split()[1:]) elif line.startswith('Release'): os_.Version = " ".join(line.split()[1:]) # override with specific values for key in ('Release', 'Name', 'Version'): if config.OperatingSystem.__dict__[key] is not None: os_.__dict__[key] = config.OperatingSystem.__dict__[key]
# caclculate the number of cpus and free cpus, ie ce.TotalCPUs and ce.FreeCPUs if config.LRMSType == "Torque" or config.LRMSType == "PBSPro": #sys.stderr.write('in the Torque / PBSPro number of cpus section\n') if config.pbsnodes is not None and os.path.isfile(config.pbsnodes): ce.TotalCPUs = 0 ce.FreeCPUs = 0 filterArg = None if hasattr(config, 'nodePropertyFilter'): filterArg = config.nodePropertyFilter node_info = {} lines = lib.run_command([config.pbsnodes, '-a']) for line in lines: if not line: processNodeInfo(node_info, ce, filterArg) node_info = {} continue values = line.split('=') if len(values) == 1: node_info['name'] = values[0] else: node_info[values[0].strip()] = [v.strip() for v in values[1].split(",")] # ANUPBS <=> OpenPBS #elif config.LRMSType == "ANUPBS": elif config.LRMSType == "OpenPBS": #sys.stderr.write('in the ANUPBS number of cpus section\n')
import apac_lib as lib if __name__ == '__main__': c = lib.read_config(sys.argv[3]) lib.assert_contains(c, sys.argv[1]) lib.assert_contains(c[sys.argv[1]], 'StorageElement') lib.assert_contains(c[sys.argv[1]].StorageElement, sys.argv[2]) config = c[sys.argv[1]].StorageElement[sys.argv[2]] # vlad's workaround to the max limit of int32 maxInt32 = 2147483647 if config.RootDirectory is not None and os.path.exists(config.RootDirectory): lines = lib.run_command(['df', '-k', config.RootDirectory]) if len(lines) == 3: free_index = 2 total_index = 0 else: free_index = 3 total_index = 1 if config.SizeTotal is None: total_space = int(lines[-1].split()[total_index]) if total_space > 0: if total_space <= maxInt32: config.SizeTotal = total_space else: config.SizeTotal = maxInt32 if config.SizeFree is None: free_space = int(lines[-1].split()[free_index])
ce.isBlueGene = "isBlueGene" in config.__dict__ and config.isBlueGene == True # caclculate the number of cpus and free cpus, ie ce.TotalCPUs and ce.FreeCPUs if config.LRMSType == "Torque" or config.LRMSType == "PBSPro": #sys.stderr.write('in the Torque / PBSPro number of cpus section\n') if config.pbsnodes is not None and os.path.isfile(config.pbsnodes): ce.TotalCPUs = 0 ce.FreeCPUs = 0 filterArg = None if hasattr(config, 'nodePropertyFilter'): filterArg = config.nodePropertyFilter node_info = {} lines = lib.run_command([config.pbsnodes, '-a']) for line in lines: if not line: processNodeInfo(node_info, ce, filterArg) node_info = {} continue values = line.split('=') if len(values) == 1: node_info['name'] = values[0] else: node_info[values[0].strip()] = [v.strip() for v in values[1].split(",")] elif config.LRMSType == "OpenPBS": #sys.stderr.write('in the ANUPBS number of cpus section\n') if config.qstat is not None and os.path.isfile(config.qstat): # WARNING - this requires config.HostName to be the PBS server (not the grid gateway)