def obtain_slotsCounts(): ''' return likes {'winnt': 100, 'linuxG48': 117, 'linux': 145, 'linuxwrk': 0, 'winntG48S60': 100, 'linuxG24': 28} 返回 系统资源数 如 win有100台 ''' resultDict = {'winnt': 0, 'linux': 0} hostInfos = qb.hostinfo(state=HOSTSTATUS) for singleHost in hostInfos: properties = format_properties(singleHost) resultDict[properties.get('properties').get( 'host.os' )] = resultDict.get(properties.get('properties').get('host.os')) + int( properties.get('resources').get('host.processors').split('/')[1]) if properties.get('groups'): groupKey = properties.get('properties').get( 'host.os') + properties.get('groups') if resultDict.get(groupKey): resultDict[groupKey] = resultDict.get(groupKey) + int( properties.get('resources').get('host.processors').split( '/')[1]) else: resultDict[groupKey] = int( properties.get('resources').get('host.processors').split( '/')[1]) return resultDict
def obtain_outOfScopeCounts(): # there is a problem ''' gets the count is no within the scope of PRIORITYRANGE return likes '{'winnt': 0, 'linux': 1}' win linux ''' resultDict = {'winnt': 0, 'linux': 0} hostInfos = qb.hostinfo(state=HOSTSTATUS) for singleHost in hostInfos: properties = format_properties(singleHost) resultDict[properties.get('properties').get( 'host.os' )] = resultDict.get(properties.get('properties').get('host.os')) + int( properties.get('resources').get('host.processors').split('/')[0]) if properties.get('groups'): groupKey = properties.get('properties').get( 'host.os') + properties.get('groups') if resultDict.get(groupKey): resultDict[groupKey] = resultDict.get(groupKey) + int( properties.get('resources').get('host.processors').split( '/')[0]) else: resultDict[groupKey] = int( properties.get('resources').get('host.processors').split( '/')[0]) return resultDict
def btExports(self): # Get the Worker info and print into the twWorkers Tree Widget import qb import os workersinfo = [] workers_list = qb.hostinfo() workers_count = len(workers_list) count = 0 countUnlocked = 0 for workers in xrange(workers_count): count = count + 1 # checkboxName = "CheckBox" + str (count) worker_name = workers_list[workers]['name'] worker_state = workers_list[workers]['state'] worker_locks = workers_list[workers]['locks'] worker_cluster = workers_list[workers]['cluster'] worker_proccesor = workers_list[workers]['resources'] worker_group = workers_list[workers]['groups'] if "host.processors=0/0" in worker_proccesor: isWorkerlocked = "Locked" else: isWorkerlocked = "Unlocked" countUnlocked = countUnlocked + 1 infoToInclude = [worker_name, worker_state, worker_cluster, isWorkerlocked, worker_group] #Sort the items in the treeWidget self.mainWindow.twWorkers.sortItems(0, QtCore.Qt.AscendingOrder) #Include the list into the treeWidget item = QTreeWidgetItem(self.mainWindow.twWorkers, infoToInclude) # Add la lista al QTreeWidget if "Locked" in infoToInclude[3]: item.setBackground(0,QBrush(QColor.fromRgb(253,253,150),Qt.SolidPattern)) item.setBackground(1,QBrush(QColor.fromRgb(253,253,150),Qt.SolidPattern)) item.setBackground(2,QBrush(QColor.fromRgb(253,253,150),Qt.SolidPattern)) item.setBackground(3,QBrush(QColor.fromRgb(253,253,150),Qt.SolidPattern)) item.setBackground(4,QBrush(QColor.fromRgb(253,253,150),Qt.SolidPattern)) if "down" in infoToInclude[1]: item.setBackground(0,QBrush(QColor.fromRgb(207,207,196),Qt.SolidPattern)) item.setBackground(1,QBrush(QColor.fromRgb(207,207,196),Qt.SolidPattern)) item.setBackground(2,QBrush(QColor.fromRgb(207,207,196),Qt.SolidPattern)) item.setBackground(3,QBrush(QColor.fromRgb(207,207,196),Qt.SolidPattern)) item.setBackground(4,QBrush(QColor.fromRgb(207,207,196),Qt.SolidPattern)) # self.mainWindow.twWorkers.insertTopLevelItems(0, [QTreeWidgetItem(self.mainWindow.twWorkers, infoToInclude)],) self.mainWindow.lbWorkers.setText("Workers: " + str(countUnlocked) + "/" + str(workers_count))
def obtain_slotsCounts(): ''' return likes {'winnt': 100, 'linuxG48': 117, 'linux': 145, 'linuxwrk': 0, 'winntG48S60': 100, 'linuxG24': 28} 返回 系统资源数 如 win有100台 ''' resultDict = {'winnt': 0, 'linux': 0} hostInfos = qb.hostinfo(state=HOSTSTATUS) for singleHost in hostInfos: properties = format_properties(singleHost) resultDict[properties.get('properties').get('host.os')] = resultDict.get(properties.get('properties').get('host.os')) + int(properties.get('resources').get('host.processors').split('/')[1]) if properties.get('groups'): groupKey = properties.get('properties').get('host.os') + properties.get('groups') if resultDict.get( groupKey ): resultDict[groupKey] = resultDict.get(groupKey) + int(properties.get('resources').get('host.processors').split('/')[1]) else: resultDict[groupKey] = int(properties.get('resources').get('host.processors').split('/')[1]) return resultDict
def obtain_outOfScopeCounts(): # there is a problem ''' gets the count is no within the scope of PRIORITYRANGE return likes '{'winnt': 0, 'linux': 1}' win linux ''' resultDict = {'winnt': 0, 'linux': 0} hostInfos = qb.hostinfo(state=HOSTSTATUS) for singleHost in hostInfos: properties = format_properties(singleHost) resultDict[properties.get('properties').get('host.os')] = resultDict.get(properties.get('properties').get('host.os')) + int(properties.get('resources').get('host.processors').split('/')[0]) if properties.get('groups'): groupKey = properties.get('properties').get('host.os') + properties.get('groups') if resultDict.get( groupKey ): resultDict[groupKey] = resultDict.get(groupKey) + int(properties.get('resources').get('host.processors').split('/')[0]) else: resultDict[groupKey] = int(properties.get('resources').get('host.processors').split('/')[0]) return resultDict
import platform import pprint from concurrent.futures import as_completed import qb def report(*args): return args, platform.architecture(), platform.processor(), platform.system(), platform.uname(), platform.platform() if __name__ == '__main__': archs = set() for host in qb.hostinfo(): if host['state'] != 'active': continue if 'farm' not in host['groups'].split(','): continue props = host['properties'] props = dict(x.split('=', 1) for x in props.split(',')) archs.add((props['host.architecture'], props['host.os'], props['host.kernel_version'])) from .. import Executor executor = Executor() futures = [] for arch, os_, kernel in sorted(archs):
import os import time ''' print os.getcwd() while True: for i in range(10): print i if i > 6: break time.sleep(1) ''' HOSTSTATUS = 'active' import sys sys.path.append('/usr/local/pfx/qube/api/python') import qb while True: hostInfos = qb.hostinfo(state=HOSTSTATUS) print '[%s]' % time.strftime('%Y-%m-%d %H:%M:%S'), 'server started.' for singlehost in hostInfos: if singlehost['groups'] == '': os.system('qbadmin w --reconfigure') break time.sleep(120)
import pprint from concurrent.futures import as_completed import qb def report(*args): return args, platform.architecture(), platform.processor( ), platform.system(), platform.uname(), platform.platform() if __name__ == '__main__': archs = set() for host in qb.hostinfo(): if host['state'] != 'active': continue if 'farm' not in host['groups'].split(','): continue props = host['properties'] props = dict(x.split('=', 1) for x in props.split(',')) archs.add((props['host.architecture'], props['host.os'], props['host.kernel_version'])) from .. import Executor executor = Executor() futures = []
qb_path = os.environ['QUBE_LOCATION'] else: qb_path = '/usr/local/pfx/qube' if qb_path: qb_api = qb_path+'/api/python' else: qb_api = '/usr/local/pfx/qube/api/python' sys.path.append(qb_api) import qb #get current host info name=socket.gethostname() if name!="qube.xm.base-fx.com": try: hostinfo = qb.hostinfo(name=name)[0] props = dict([x.split('=') for x in hostinfo['properties'].split(',')]) cpus = int(props['host.cpus']) if hostinfo['locks']: locks = dict([x.split('=') for x in hostinfo['locks'].split(',')]) else: locks=None except: print '%s,This Machine Has Been Removed From Qube Render Farm.....'%name locks=None else: locks=None def lock(option,name=''): cmd = '''su qube -c "qblock %s %s"'''%(option,name) #print cmd
# Author: xiangpeng zeng # # Create on: 2015-11-19 09:12:37 # # ******************************** import os import sys try: import qb except: if 'QBDIR' in os.environ: QBDIR = os.environ['QBDIR'] else: if os.name == 'posix': if os.uname()[0] == 'Darwin': QBDIR = '/Applications/pfx/qube' else: QBDIR = '/usr/local/pfx/qube' sys.path.append('%s/api/python' % QBDIR) import qb print qb.QB_API_XML print qb.QB_API_BINARY print qb.QB_TIME_EPOCH_OFFSET print qb.QB_CLIENT_DEFAULT_CONF print qb.hostinfo()[0]
qb_path = os.environ['QUBE_LOCATION'] else: qb_path = '/usr/local/pfx/qube' if qb_path: qb_api = qb_path + '/api/python' else: qb_api = '/usr/local/pfx/qube/api/python' sys.path.append(qb_api) import qb #get current host info name = socket.gethostname() if name != "qube.xm.base-fx.com": try: hostinfo = qb.hostinfo(name=name)[0] props = dict([x.split('=') for x in hostinfo['properties'].split(',')]) cpus = int(props['host.cpus']) if hostinfo['locks']: locks = dict([x.split('=') for x in hostinfo['locks'].split(',')]) else: locks = None except: print '%s,This Machine Has Been Removed From Qube Render Farm.....' % name locks = None else: locks = None def lock(option, name=''): cmd = '''su qube -c "qblock %s %s"''' % (option, name)