def selectOneHostBy(host): '''获取单个主机资料''' try: return VmServer.objects.get(server_ip=host) except Exception, e: BaseLogging.Logger("[获取主机] 状态:[失败] 失败原因:" + str(e), level='error') return False
def insertVmDhcp(data): try: dhcp = VmDHCP.objects.create(**data) return dhcp except Exception,e: BaseLogging.Logger("[添加DHCP] 状态:[失败] 失败原因:"+str(e), level='error') return False
def updateVmServer(server_id, instance, mem, cpu_total, mem_per): try: return VmServer.objects.filter(id=server_id).update( instance=instance, mem=mem, cpu_total=cpu_total, mem_per=mem_per) except Exception, e: BaseLogging.Logger("[更新主机] 状态:[失败] 失败原因:" + str(e), level='error') return str(e)
def updateVmServerStatus( server_id, status, ): try: server = VmServer.objects.get(id=server_id) server.status = status return server.save() except Exception, e: BaseLogging.Logger("[更新主机] 状态:[失败] 失败原因:" + str(e), level='error') return str(e)
def insertVmServer(server_ip, uri, vm_type, status, hostname): try: server = VmServer(server_ip=server_ip, uri=uri, hostname=hostname, vm_type=vm_type, status=status) server.save() return server except Exception, e: BaseLogging.Logger("[添加主机] 状态:[失败] 失败原因:" + str(e), level='error') return False
def __init__(self, ctx, err): msg = ctx + err[2] BaseLogging.Logger(msg, level='error')