def clone_vm(self, src_vm, dest_name, dest_st, to_temp=False, level='high', del_snapshot='yes', cfg=None): params = {} host_name = src_vm.get_hostname() if self.is_name_dupliacted(dest_name, host_name): raise error.CommonError("Create vm: name duplicated!") params.update(vmd_port.CLONE_VMS) m_vm = vm.VMS(dest_name) if cfg: params.update(cfg) else: dest_path = storage.get_storage_path(host_name, dest_st) dest_uuid = storage.get_storage_uuid(host_name, dest_st) params.update({ 'parentUuid': src_vm.get_parentUuid(), 'targetVmdesc': dest_name, 'targetVmuuid': dest_name, 'bsstorage_uuid': src_vm.get_storage_uuid(), 'bsstorage_path': src_vm.get_storage_path(), 'vmUuid': src_vm.get_vmUuid(), 'storage_path': dest_path, 'storageUuid': dest_uuid, 'copy_level': level, 'del_snapshot': del_snapshot, 'to_template': 'yes' if to_temp else 'no' }) action_id = CODE['clone_vms'] m_id = self.executor.run(action_id, params, host_name, 'vm', 'VmnoclusterchangeTask') self.executor.wait_for_done(m_id, host_name, 120) m_vm.initialize(host_name, self.executor) return m_vm
def del_storage(self, name): opt_id = 201 storage_uuid = storage.get_storage_uuid(self.hostname, name) params = {} params.update({'storageUuid': storage_uuid}) m_id = self.exe.run(opt_id, params, self.hostname, 'storage', 'StorageTask') self.exe.wait_for_done(m_id, self.hostname)
def get_storage_uuid(self, host, storage_name): return storage.get_storage_uuid(host, storage_name)