def __init__(self, connection=None, conn=None): conn = conn or connection if not isinstance(conn, libvirt.virConnect): raise ValueError(_("Connection must be a 'virConnect' instance.")) self._hyper_conn = conn # original guest name or uuid self._original_guest = None self._original_dom = None self._original_virtual_disks = [] self._original_xml = None # clone guest self._clone_name = None self._clone_devices = [] self._clone_virtual_disks = [] self._clone_bs = 1024 * 1024 * 10 self._clone_mac = [] self._clone_uuid = None self._clone_sparse = True self._clone_xml = None self._force_target = [] self._skip_target = [] self._preserve = True self._clone_running = False # Default clone policy for back compat: don't clone readonly, # shareable, or empty disks self._clone_policy = [ self.CLONE_POLICY_NO_READONLY, self.CLONE_POLICY_NO_SHAREABLE, self.CLONE_POLICY_NO_EMPTYMEDIA ] # Throwaway guest to use for easy validation self._valid_guest = Guest.Guest(conn=conn) # Generate a random UUID at the start while 1: uuid = _util.uuidToString(_util.randomUUID()) if _util.vm_uuid_collision(self._hyper_conn, uuid): continue self.clone_uuid = uuid break
def __init__(self, connection=None, conn=None): conn = conn or connection if not isinstance(conn, libvirt.virConnect): raise ValueError(_("Connection must be a 'virConnect' instance.")) self._hyper_conn = conn # original guest name or uuid self._original_guest = None self._original_dom = None self._original_virtual_disks = [] self._original_xml = None # clone guest self._clone_name = None self._clone_devices = [] self._clone_virtual_disks = [] self._clone_bs = 1024 * 1024 * 10 self._clone_mac = [] self._clone_uuid = None self._clone_sparse = True self._clone_xml = None self._force_target = [] self._skip_target = [] self._preserve = True self._clone_running = False # Default clone policy for back compat: don't clone readonly, # shareable, or empty disks self._clone_policy = [self.CLONE_POLICY_NO_READONLY, self.CLONE_POLICY_NO_SHAREABLE, self.CLONE_POLICY_NO_EMPTYMEDIA] # Throwaway guest to use for easy validation self._valid_guest = Guest.Guest(conn=conn) # Generate a random UUID at the start while 1: uuid = _util.uuidToString(_util.randomUUID()) if _util.vm_uuid_collision(self._hyper_conn, uuid): continue self.clone_uuid = uuid break
def _set_defaults(self, devlist_func): soundtype = VirtualDevice.VIRTUAL_DEV_AUDIO videotype = VirtualDevice.VIRTUAL_DEV_VIDEO inputtype = VirtualDevice.VIRTUAL_DEV_INPUT # Set default input values input_type = self._lookup_device_param(inputtype, "type") input_bus = self._lookup_device_param(inputtype, "bus") for inp in devlist_func(inputtype): if (inp.type == inp.INPUT_TYPE_DEFAULT and inp.bus == inp.INPUT_BUS_DEFAULT): inp.type = input_type inp.bus = input_bus # Generate disk targets, and set preferred disk bus used_targets = [] for disk in devlist_func(VirtualDevice.VIRTUAL_DEV_DISK): if not disk.bus: if disk.device == disk.DEVICE_FLOPPY: disk.bus = "fdc" else: disk.bus = self._diskbus used_targets.append(disk.generate_target(used_targets)) # Set sound device model sound_model = self._lookup_device_param(soundtype, "model") for sound in devlist_func(soundtype): if sound.model == sound.MODEL_DEFAULT: sound.model = sound_model # Set video device model video_model = self._lookup_device_param(videotype, "model_type") for video in devlist_func(videotype): if video.model_type == video.MODEL_DEFAULT: video.model_type = video_model # Generate UUID if self.uuid is None: while 1: self.uuid = _util.uuidToString(_util.randomUUID()) if _util.vm_uuid_collision(self.conn, self.uuid): continue break
def __init__(self, conn, name, type, target_path=None, uuid=None): StorageObject.__init__(self, object_type=StorageObject.TYPE_POOL, name=name, conn=conn) if type not in self.get_pool_types(): raise ValueError, _("Unknown storage pool type: %s" % type) self._type = type self._target_path = None self._host = None self._format = None self._source_path = None self._uuid = None if target_path is None: target_path = self._get_default_target_path() self.target_path = target_path if uuid: self.uuid = uuid # Initialize all optional properties self._host = None self._source_path = None self._random_uuid = _util.uuidToString(_util.randomUUID())
def __init__(self, conn, name, type, target_path=None, uuid=None): StorageObject.__init__(self, object_type=StorageObject.TYPE_POOL, \ name=name, conn=conn) if type not in self.get_pool_types(): raise ValueError, _("Unknown storage pool type: %s" % type) self._type = type self._target_path = None self._host = None self._format = None self._source_path = None self._uuid = None if target_path is None: target_path = self._get_default_target_path() self.target_path = target_path if uuid: self.uuid = uuid # Initialize all optional properties self._host = None self._source_path = None self._random_uuid = _util.uuidToString(_util.randomUUID())