Пример #1
0
 def _createFromGivenImage(cls, index, requirement, image1, bootFromNetwork):
     name = cls._nameFromIndex(index)
     image2 = os.path.join(config.DISK_IMAGES_DIRECTORY, name + "_disk2.qcow2")
     serialLog = os.path.join(config.SERIAL_LOGS_DIRECTORY, name + ".serial.txt")
     if not os.path.isdir(os.path.dirname(serialLog)):
         os.makedirs(os.path.dirname(serialLog))
     hardwareConstraints = requirement["hardwareConstraints"]
     imagecommands.create(image=image2, sizeGB=hardwareConstraints["minimumDisk2SizeGB"])
     mani = manifest.Manifest.create(
         name=name,
         memoryMB=int(1024 * hardwareConstraints["minimumRAMGB"]),
         vcpus=hardwareConstraints["minimumCPUs"],
         disk1Image=image1,
         disk2Image=image2,
         primaryMACAddress=network.primaryMACAddressFromVMIndex(index),
         secondaryMACAddress=network.secondMACAddressFromVMIndex(index),
         networkName=network.NAME,
         serialOutputFilename=serialLog,
         bootFromNetwork=bootFromNetwork,
     )
     with libvirtsingleton.it().lock():
         domain = libvirtsingleton.it().libvirt().defineXML(mani.xml())
         domain.create()
     return cls(
         index=index,
         domain=domain,
         requirement=requirement,
         manifest=mani,
         disk1SizeGB=hardwareConstraints["minimumDisk1SizeGB"],
         disk2SizeGB=hardwareConstraints["minimumDisk2SizeGB"],
     )
Пример #2
0
 def _createFromGivenImage(cls, index, requirement, image1,
                           bootFromNetwork):
     name = cls._nameFromIndex(index)
     image2 = os.path.join(config.DISK_IMAGES_DIRECTORY,
                           name + "_disk2.qcow2")
     serialLog = os.path.join(config.SERIAL_LOGS_DIRECTORY,
                              name + ".serial.txt")
     if not os.path.isdir(os.path.dirname(serialLog)):
         os.makedirs(os.path.dirname(serialLog))
     hardwareConstraints = requirement['hardwareConstraints']
     imagecommands.create(image=image2,
                          sizeGB=hardwareConstraints['minimumDisk2SizeGB'])
     mani = manifest.Manifest.create(
         name=name,
         memoryMB=int(1024 * hardwareConstraints['minimumRAMGB']),
         vcpus=hardwareConstraints['minimumCPUs'],
         disk1Image=image1,
         disk2Image=image2,
         primaryMACAddress=network.primaryMACAddressFromVMIndex(index),
         secondaryMACAddress=network.secondMACAddressFromVMIndex(index),
         networkName=network.NAME,
         serialOutputFilename=serialLog,
         bootFromNetwork=bootFromNetwork)
     with libvirtsingleton.it().lock():
         domain = libvirtsingleton.it().libvirt().defineXML(mani.xml())
         domain.create()
     return cls(index=index,
                domain=domain,
                requirement=requirement,
                manifest=mani,
                disk1SizeGB=hardwareConstraints['minimumDisk1SizeGB'],
                disk2SizeGB=hardwareConstraints['minimumDisk2SizeGB'])
Пример #3
0
 def primaryMACAddress(self):
     return network.primaryMACAddressFromVMIndex(self._index)
Пример #4
0
 def primaryMACAddress(self):
     return network.primaryMACAddressFromVMIndex(self._index)