Exemplo n.º 1
0
	def crudServerFromInstance(self,instance):
		server = KVMServer.objects.filter(uuid = instance.getUUID())
		if len(server)==1:
			server = server[0]
			return server.updateServer(instance.getName(),
						instance.getOSType(),
						instance.getOSDistribution(),
						instance.getOSVersion(),
						instance.getNumberOfCPUs(),
						instance.getCPUFrequency(),
						instance.getMemory(),
						instance.getDiscSpaceGB(),
						instance.getAgentURL(),
						instance.getAgentPassword(),
						save = True)
		elif len(server)==0:
			return KVMServer.constructor(instance.getName(),
								instance.getOSType(),
								instance.getOSDistribution(),
								instance.getOSVersion(),
								instance.getNumberOfCPUs(),
								instance.getCPUFrequency(),
								instance.getMemory(),
								instance.getDiscSpaceGB(),
								instance.getAgentURL(),
								instance.getAgentPassword(),
								save=True)
		else:
			raise Exception("Trying to create a server failed")
Exemplo n.º 2
0
	def createOrUpdateServerFromPOST(request, instance):
		#return KVMServer.constructor(server.getName(),server.getOSType(),server.getOSDistribution(),server.getOSVersion(),server.getAgentURL(),save=True)
		server = KVMServer.objects.get(uuid = instance.getUUID())
		if server:
			return server.updateServer(HttpUtils.getFieldInPost(request,VTServer, "name"),
				HttpUtils.getFieldInPost(request,VTServer, "operatingSystemType"),
				HttpUtils.getFieldInPost(request,VTServer, "operatingSystemDistribution"),
				HttpUtils.getFieldInPost(request,VTServer, "operatingSystemVersion"),
				HttpUtils.getFieldInPost(request,VTServer, "numberOfCPUs"),
				HttpUtils.getFieldInPost(request,VTServer, "CPUFrequency"),
				HttpUtils.getFieldInPost(request,VTServer, "memory"),
				HttpUtils.getFieldInPost(request,VTServer, "discSpaceGB"),
				HttpUtils.getFieldInPost(request,VTServer, "agentURL"),
				save=True)
		else:
			return KVMServer.constructor(HttpUtils.getFieldInPost(request,VTServer, "name"),
							HttpUtils.getFieldInPost(request,VTServer, "operatingSystemType"),
							HttpUtils.getFieldInPost(request,VTServer, "operatingSystemDistribution"),
							HttpUtils.getFieldInPost(request,VTServer, "operatingSystemVersion"),
							HttpUtils.getFieldInPost(request,VTServer, "numberOfCPUs"),
							HttpUtils.getFieldInPost(request,VTServer, "CPUFrequency"),
							HttpUtils.getFieldInPost(request,VTServer, "memory"),
							HttpUtils.getFieldInPost(request,VTServer, "discSpaceGB"),
							HttpUtils.getFieldInPost(request,VTServer, "agentURL"),
							save=True)