def copy_files_from(self, guest_path, host_path, nic_index=0, limit="", verbose=False, timeout=COPY_FILES_TIMEOUT, username=None, password=None): """ Transfer files from the guest. :param host_path: Guest path :param guest_path: Host path :param nic_index: The index of the NIC to connect to. :param limit: Speed limit of file transfer. :param verbose: If True, log some stats using logging.debug (RSS only) :param timeout: Time (seconds) before giving up on doing the remote copy. """ error.context("receiving file(s) from '%s'" % self.name) if not username: username = self.params.get("username", "") if not password: password = self.params.get("password", "") client = self.params.get("file_transfer_client") address = self.get_address(nic_index) port = self.get_port(int(self.params.get("file_transfer_port"))) log_filename = ( "transfer-%s-from-%s-%s.log" % (self.name, address, utils_misc.generate_random_string(4))) remote.copy_files_from(address, client, username, password, port, guest_path, host_path, limit, log_filename, verbose, timeout) utils_misc.close_log_file(log_filename)
def copy_files_from(self, guest_path, host_path, nic_index=0, limit="", verbose=False, timeout=COPY_FILES_TIMEOUT, username=None,password=None): """ Transfer files from the guest. @param host_path: Guest path @param guest_path: Host path @param nic_index: The index of the NIC to connect to. @param limit: Speed limit of file transfer. @param verbose: If True, log some stats using logging.debug (RSS only) @param timeout: Time (seconds) before giving up on doing the remote copy. """ error.context("receiving file(s) from '%s'" % self.name) if not username: username = self.params.get("username", "") if not password: password = self.params.get("password", "") client = self.params.get("file_transfer_client") address = self.get_address(nic_index) port = self.get_port(int(self.params.get("file_transfer_port"))) log_filename = ("transfer-%s-from-%s-%s.log" % (self.name, address, utils_misc.generate_random_string(4))) remote.copy_files_from(address, client, username, password, port, guest_path, host_path, limit, log_filename, verbose, timeout) utils_misc.close_log_file(log_filename)
def copy_files_to(self, host_path, guest_path, nic_index=0, limit="", verbose=False, timeout=COPY_FILES_TIMEOUT, username=None, password=None): """ Transfer files to the remote host(guest). :param host_path: Host path :param guest_path: Guest path :param nic_index: The index of the NIC to connect to. :param limit: Speed limit of file transfer. :param verbose: If True, log some stats using logging.debug (RSS only) :param timeout: Time (seconds) before giving up on doing the remote copy. """ error.context("sending file(s) to '%s'" % self.name) if not username: username = self.params.get("username", "") if not password: password = self.params.get("password", "") client = self.params.get("file_transfer_client") address = self.get_address(nic_index) neigh_attach_if = "" if address.lower().startswith("fe80"): neigh_attach_if = utils_net.get_neigh_attch_interface(address) port = self.get_port(int(self.params.get("file_transfer_port"))) log_filename = ("transfer-%s-to-%s-%s.log" % (self.name, address, utils_misc.generate_random_string(4))) remote.copy_files_to(address, client, username, password, port, host_path, guest_path, limit, log_filename, verbose, timeout, interface=neigh_attach_if) utils_misc.close_log_file(log_filename)
def __del__(self): # Automatically close the connection when the instance is garbage # collected self._close_sock() utils_misc.close_log_file(self.log_file)