示例#1
0
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
示例#2
0
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
示例#3
0
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)}
示例#4
0
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'}
示例#5
0
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)}
示例#6
0
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}
示例#7
0
def getServer(uid):
    data = db.getData('DHCPServers', ['ip', 'username', 'password'], uid, 'id')
    assert len(data) == 1, 'No server info'
    return data[0]
示例#8
0
def getScriptInfo(scriptId):
    data = db.getData('ScriptMapper',
                      ['id', 'fileName', 'uploadedBy', 'uploadedOn', 'param'],
                      scriptId, 'id')
    assert len(data) == 1, 'No info'
    return data[0]
示例#9
0
def getAllEnvs():
    return db.getData('EnvInfo', ['bootstrap', 'identifier', 'id'])