def getServerInfoById(uid): s = Hypervisor() #def getData(self,tablename,keyset,key=None,keyidentifier = ''): data = db.getData('Hypervisors', s.getAttributes().keys(), uid, 'id') assert len(data) == 1, 'No info' data = data[0] return data
def getServer(uid): s = DHCPServer() #def getData(self,tablename,keyset,key=None,keyidentifier = ''): data = db.getData(targetName, s.getAttributes().keys(), uid, 'id') assert len(data) == 1, 'No info' data = data[0] return data
def getAllServers(): try: s = DHCPServer() #def getData(self,tablename,keyset,key=None,keyidentifier = ''): data = db.getData(targetName, s.getAttributes().keys()) return {'status': 'success', 'data': data} except Exception as e: return {'status': 'error', 'data': str(e)}
def getScripts(): #def getData(self,tablename,keyset,key=None,keyidentifier = ''): try: data = db.getData( 'ScriptMapper', ['id', 'fileName', 'uploadedBy', 'uploadedOn', 'param']) return {'status': 'success', 'data': data} except Exception as e: return {'status': 'error', 'data': 'Unexpected excpetion'}
def getServerInfo(uid): try: s = EnvInfo() #def getData(self,tablename,keyset,key=None,keyidentifier = ''): data = db.getData(targetName, s.getAttributes().keys(), uid, 'id') assert len(data) == 1, 'No info' data = data[0] return {'status': 'success', 'data': data} except Exception as e: return {'status': 'error', 'data': str(e)}
def search(keyword): servers = db.getData('DHCPServers', ['id', 'ip']) assert servers, 'No DHCP info found' wholeData = {} ipUid = {} bodyContent = '' for server in servers: data = readFile(server['ip']) wholeData[server['ip']] = data ipUid[server['ip']] = server['id'] assert len(wholeData) > 0, 'There is no configuration to perform search' matchFound = False for ip, data in wholeData.items(): resp = performSearch(data, keyword) if resp: bodyContent += '<h4> Match found in Server <a target="blank" href="/pat/v2/dhcp/manage.htm?ip=%s&uid=%s"> %s</a></h4>' % ( ip, ipUid[ip], ip) bodyContent += resp matchFound = True if not matchFound: bodyContent = '</br>Match not found :(' return {'status': 'success', 'data': bodyContent}
def getServer(uid): data = db.getData('DHCPServers', ['ip', 'username', 'password'], uid, 'id') assert len(data) == 1, 'No server info' return data[0]
def getScriptInfo(scriptId): data = db.getData('ScriptMapper', ['id', 'fileName', 'uploadedBy', 'uploadedOn', 'param'], scriptId, 'id') assert len(data) == 1, 'No info' return data[0]
def getAllEnvs(): return db.getData('EnvInfo', ['bootstrap', 'identifier', 'id'])