def addServer(s): try: #addEntry(self,mapper,tablename) db.addEntry(s.getAttributes(), targetName) return {'status': 'success', 'data': 'DHCP server added successfully'} except Exception as e: return {'status': 'error', 'data': str(e)}
def addEntry(fileName, subject, description, path, mediaType): db.addEntry( { 'filename': fileName, 'subject': subject, 'desc': description, 'path': path, 'date': str(datetime.datetime.now().date()), 'mediatype': mediaType }, 'Library')
def saveScriptInfo(filename, uploadedBy, param, scriptType): uploadedOn = str(datetime.datetime.now().date()) db.addEntry( { 'fileName': filename, 'uploadedBy': uploadedBy, 'uploadedOn': uploadedOn, 'param': param, 'scriptType': scriptType }, 'ScriptMapper')
def loadToDb(config, ip): envs = getAllEnvs() for subnet in config.subnets: subnetID = 'subnet_' + subnet.subnet + '_' + subnet.netmask row = { 'id': subnetID, 'serverIp': ip, 'subnet': subnet.subnet, 'netmask': subnet.netmask } db.addEntry(row, 'DHCPSubnets') for pool in subnet.pools: poolId = getRandomId() [status, env] = getStatusAndEnvByBootStrap(envs, pool.bootfileName) poolrow = { 'id': poolId, 'subnetId': subnetID, 'serverIp': ip, 'assignedDate': 'No info', 'rangeStart': pool.rangeStart, 'rangeEnd': pool.rangeEnd, 'bootfileName': pool.bootfileName, 'subnetMask': pool.subnetMask, 'assignEndDate': 'No info', 'routers': pool.routers, 'status': status, 'assignedEnv': env, 'devicecount': len(pool.hosts), 'hypervisor': 'Not Mapped' } db.addEntry(poolrow, 'DHCPPools') for host in pool.hosts: hostrow = { 'mac': host.mac, 'name': host.name, 'ip': host.ip, 'poolId': poolId, 'serverIp': ip } db.addEntry(hostrow, 'DHCPHosts')