예제 #1
0
	def startDomain(vm):
		#Getting connection
		conn = XendManager.__getConnection()

		with open(HdManager.getConfigFilePath(vm),'r') as openConfig: 
			xmlConf = conn.domainXMLFromNative('xen-xm', openConfig.read(), 0) 

		if XendManager.isVmRunning(vm.name) and not  XendManager.isVmRunningByUUID(vm.uuid):
			#Duplicated name; trying to find an Alias
			newVmName = XendManager.__findAliasForDuplicatedVmName(vm)
			subprocess.call(['/usr/sbin/xm','create','name='+newVmName,XendManager.sanitize_arg(HdManager.getConfigFilePath(vm))])
		else:	
			try:
				#Try first using libvirt call
				#conn.createXML(xmlConf,0)
				raise Exception("Skip") #otherwise stop is ridicously slow
			except Exception as e:
				#Fallback solution; workarounds BUG that created wrong .conf files (extra spaces that libvirt cannot parse)
				subprocess.call(['/usr/sbin/xm','create',XendManager.sanitize_arg(HdManager.getConfigFilePath(vm))])
			
		time.sleep(OXA_XEN_CREATE_WAIT_TIME)

		if not XendManager.isVmRunningByUUID(vm.uuid):
			#TODO: add more info to exception
			raise Exception("Could not start VM")
예제 #2
0
    def startDomain(vm):
        #Getting connection
        conn = XendManager.__getConnection()

        with open(HdManager.getConfigFilePath(vm), 'r') as openConfig:
            xmlConf = conn.domainXMLFromNative('xen-xm', openConfig.read(), 0)

        #con = libvirt.open('xen:///')
        #dom = con.createLinux(xmlConf,0)

        if XendManager.isVmRunning(
                vm.name) and not XendManager.isVmRunningByUUID(vm.uuid):
            #Duplicated name; trying to find an Alias
            newVmName = XendManager.__findAliasForDuplicatedVmName(vm)
            command_list = [
                '/usr/sbin/xm', 'create', 'name=' + newVmName,
                XendManager.sanitize_arg(HdManager.getConfigFilePath(vm))
            ]
            process = subprocess.Popen(command_list,
                                       shell=False,
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.PIPE)
            out, err = process.communicate()
        else:
            try:
                #Try first using libvirt call
                #XendManager.logger.warning('creating vm using python-libvirt methods')
                #XendManager.logger.warning(xmlConf)
                #conn.createXML(xmlConf,0)
                #XendManager.logger.warning(XendManager.sanitize_arg(HdManager.getConfigFilePath(vm)))
                #XendManager.logger.warning('created vm?')
                raise Exception("Skip")  #otherwise stop is ridicously slow
            except Exception as e:
                #Fallback solution; workarounds BUG that created wrong .conf files (extra spaces that libvirt cannot parse)
                command_list = [
                    '/usr/sbin/xm', 'create',
                    XendManager.sanitize_arg(HdManager.getConfigFilePath(vm))
                ]
                process = subprocess.Popen(command_list,
                                           shell=False,
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.PIPE)
                out, err = process.communicate()

        time.sleep(OXA_XEN_CREATE_WAIT_TIME)

        if not XendManager.isVmRunningByUUID(vm.uuid):
            # Complete with other types of exceptions
            detailed_error = ""
            if "Not enough free memory" in err:
                detailed_error = " because there is not enough free memory in that server. Try another."
            raise Exception("Could not start VM%s" % detailed_error)
예제 #3
0
	def startDomain(vm):
		#Getting connection
		conn = XendManager.__getConnection()

		with open(HdManager.getConfigFilePath(vm),'r') as openConfig: 
			xmlConf = conn.domainXMLFromNative('xen-xm', openConfig.read(), 0) 

		#con = libvirt.open('xen:///')
		#dom = con.createLinux(xmlConf,0)
				

		if XendManager.isVmRunning(vm.name) and not  XendManager.isVmRunningByUUID(vm.uuid):
			#Duplicated name; trying to find an Alias
			newVmName = XendManager.__findAliasForDuplicatedVmName(vm)
			command_list = ['/usr/sbin/xm', 'create', 'name=' + newVmName, XendManager.sanitize_arg(HdManager.getConfigFilePath(vm))]
			process = subprocess.Popen(command_list, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			out, err = process.communicate()
		else:	
			try:
				#Try first using libvirt call
				#XendManager.logger.warning('creating vm using python-libvirt methods')
                                #XendManager.logger.warning(xmlConf)
				#conn.createXML(xmlConf,0)
				#XendManager.logger.warning(XendManager.sanitize_arg(HdManager.getConfigFilePath(vm)))
                                #XendManager.logger.warning('created vm?')
				raise Exception("Skip") #otherwise stop is ridicously slow
			except Exception as e:
				#Fallback solution; workarounds BUG that created wrong .conf files (extra spaces that libvirt cannot parse)
				command_list = ['/usr/sbin/xm', 'create', XendManager.sanitize_arg(HdManager.getConfigFilePath(vm))]
				process = subprocess.Popen(command_list, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
				out, err = process.communicate()

		time.sleep(OXA_XEN_CREATE_WAIT_TIME)

		if not XendManager.isVmRunningByUUID(vm.uuid):
			# Complete with other types of exceptions
			detailed_error = ""
			if "Not enough free memory" in err:
				detailed_error = " because there is not enough free memory in that server. Try another."
			raise Exception("Could not start VM%s" % detailed_error)
예제 #4
0
    def __createHVMFileHdConfigFile(vm, env):
        template_name = "mediacatHVMFileHd.pt"
        template = env.get_template(template_name)

        #Set vars&render
        output = template.render(kernelImg=OXA_XEN_SERVER_KERNEL,
                                 initrdImg=OXA_XEN_SERVER_INITRD,
                                 vm=vm)

        #write file
        cfile = open(HdManager.getConfigFilePath(vm), 'w')
        cfile.write(output)
        cfile.close()
예제 #5
0
        def __createHVMFileHdConfigFile(vm,env):
                template_name = "mediacatHVMFileHd.pt"
                template = env.get_template(template_name)

                #Set vars&render
                output = template.render(
                kernelImg=OXA_XEN_SERVER_KERNEL,
                initrdImg=OXA_XEN_SERVER_INITRD,
                vm=vm)

                #write file
                cfile = open(HdManager.getConfigFilePath(vm),'w')
                cfile.write(output)
		cfile.close()
예제 #6
0
    def __createParavirtualizationFileHdConfigFile(vm, env):
        template_name = "paraVirtualizedFileHd.pt"
        template = env.get_template(template_name)

        #Set vars&render
        output = template.render(kernelImg=OXA_XEN_SERVER_KERNEL,
                                 initrdImg=OXA_XEN_SERVER_INITRD,
                                 hdFilePath=HdManager.getHdPath(vm),
                                 swapFilePath=HdManager.getSwapPath(vm),
                                 vm=vm)

        #write file
        cfile = open(HdManager.getConfigFilePath(vm), 'w')
        cfile.write(output)
        cfile.close()
예제 #7
0
	def __createFullvirtualizationFileHdConfigFile(vm,env):
                template_name = "fullVirtualizedFileHd.pt"
                template = env.get_template(template_name)	

		#Set vars&render		
		output = template.render(
		kernelImg=OXA_XEN_SERVER_KERNEL,
		initrdImg=OXA_XEN_SERVER_INITRD,
		hdFilePath=HdManager.getHdPath(vm),
		#swapFilePath=HdManager.getSwapPath(vm),
		vm=vm)	
			
		#write file
		cfile = open(HdManager.getConfigFilePath(vm),'w')
		cfile.write(output)
		cfile.close()
예제 #8
0
    def __createConfigFile(vm, env):
        template_name = "spirentSTCVMTemplate.pt"
        template = env.get_template(template_name)

        #Set vars&render
        output = template.render(
            kernelImg=OXA_XEN_SERVER_KERNEL,
            initrdImg=OXA_XEN_SERVER_INITRD,
            hdFilePath=HdManager.getHdPath(vm),
            #swapFilePath=HdManager.getSwapPath(vm),
            vm=vm)

        #write file
        cfile = open(HdManager.getConfigFilePath(vm), 'w')
        cfile.write(output)
        cfile.close()