def set_restore_path(self): """ set the restore path as CVAutomation in the drive with maximum storage space Exception: if failed to get storage details if failed to create directory """ try: _temp_storage_dict = {} self.client_machine = machine.Machine( self._dest_client_name, self.auto_subclient.auto_commcell.commcell) storage_details = self.client_machine.get_storage_details() _drive_regex = "^[a-zA-Z]$" for _drive, _size in storage_details.items(): if re.match(_drive_regex, _drive): _temp_storage_dict[_drive] = _size["available"] _maximum_storage = max(_temp_storage_dict.values()) results = list( filter(lambda x: x[1] == _maximum_storage, _temp_storage_dict.items())) _dir_path = (results[0])[0] + ":\\CVAutomation" if not self.client_machine.check_directory_exists(_dir_path): self.client_machine.create_directory(_dir_path) self._restore_path = _dir_path except Exception as err: self.log.exception("An Error occurred in PopulateRestorePath ") raise err
def hyperv(): proxy_host_list = [] vm_list = self.auto_subclient.vm_list # setting Virtualization client self.destination_client = self.inputs.get( "DestinationClient", self.auto_subclient.auto_vsaclient.vsa_client_name) dest_auto_vsaclient = VirtualServerHelper.AutoVSAVSClient( self.auto_subclient.auto_commcell, self._destination_client) self.dest_auto_vsa_instance = VirtualServerHelper.AutoVSAVSInstance( dest_auto_vsaclient, self.testcase.agent, self.testcase.instance) self.dest_client_hypervisor = self.dest_auto_vsa_instance.hvobj for each_vm in vm_list: self.dest_client_hypervisor.VMs[ each_vm] = self.auto_subclient.__deepcopy__( (self.auto_subclient.hvobj.VMs[each_vm])) # setting server in the VSA Client if "RestoreHyperVServer" not in self.inputs: host_dict = {} proxy_list = self.dest_auto_vsa_instance.proxy_list for each_proxy in proxy_list: host_name = self.auto_subclient.auto_commcell.get_hostname_for_client( each_proxy) proxy_host_list.append(host_name) host_dict[each_proxy] = host_name self._dest_client_name, datastore = self.dest_client_hypervisor.compute_free_resources( proxy_list, host_dict, vm_list) else: self._dest_client_name = self.inputs["RestoreHyperVServer"] self.dest_machine = machine.Machine( self._dest_client_name, self.auto_subclient.auto_commcell.commcell) # setting Destination path in VSA Client if "DestinationPath" not in self.inputs: _dir_path = os.path.join(datastore, "\\CVAutomation") if not self.dest_machine.check_directory_exists(_dir_path): self.dest_machine.create_directory(_dir_path) self.destination_path = _dir_path else: self.destination_path = self.inputs["DestinationPath"]
def HyperV(): proxy_host_list = [] vm_list = self.auto_subclient.subclient.vm_list #setting Virtualization client self.DestinationClient = self.inputs.get( "DestinationClient", self.auto_subclient.auto_vsaclient.vsa_client_name) dest_auto_vsaclient = self.auto_subclient.auto_vsaclient( self._dest_client_name, self.auto_subclient.auto_vsacommcell) dest_auto_vsa_instance = self.auto_subclient.auto_vsainstance( dest_auto_vsaclient) dest_client_hypervisor = dest_auto_vsa_instance._create_hypervisor_object( dest_auto_vsa_instance.server_name) #setting server in the VSA Client if not self.inputs.has_key("RestoreHyperVServer"): proxy_list = dest_auto_vsa_instance.proxy_list.keys() for each_proxy in proxy_list: proxy_host_list.append( self.auto_subclient.auto_commcell. get_hostname_for_client(each_proxy)) self.DestinationClient, Datastore = dest_client_hypervisor.compute_free_resources( proxy_host_list, vm_list) self.dest_client_hypervisor = dest_auto_vsa_instance._create_hypervisor_object( self._dest_client_name) self.dest_machine = machine.Machine( self._dest_client_name, self.auto_subclient.auto_vsacommcell.commcell) #setting Destination path in VSA Client if not self.inputs.has_key("DestinationPath"): proxy_host_list = [] proxy_host_list.append(self.DestinationClient) dest_host_name, datastore = self.dest_client_hypervisor.compute_free_resources( proxy_host_list, vm_list) _dir_path = os.path.join(datastore, "CVAutomation") if not self.dest_machine.check_directory_exists(_dir_path): self.dest_machine.create_directory(_dir_path) self.DestinationPath = _dir_path