INNER CODE UNIT · Python

_fix_url_for_hosts

ansible-collections/community.vmware · plugins/connection/vmware_tools.py:455

    def _fix_url_for_hosts(self, url):
        """
        Fix url if connection is a host.

        The host part of the URL is returned as '*' if the hostname to be used is the name of the server to which the call was made. For example, if the call is
        made to esx-svr-1.domain1.com and port 443, and the file is available for download from http://esx-svr-1.domain1.com:443/guestFile?id=1&token=1234,
        the URL returned may be http://*:443/guestFile?id=1&token=1234.
        The client replaces the asterisk with the server name on which it invoked the call and 443 with the port number.

        https://code.vmware.com/apis/358/vsphere#/doc/vim.vm.guest.FileManager.FileTransferInformation.html
        """
        return url.replace("*", self.vmware_host).replace("443", str(self.get_option("vmware_port")))

    def _fetch_file_from_vm(self, guestFilePath):
        try:
            fileTransferInformation = self.fileManager.InitiateFileTransferFromGuest(vm=self.vm, auth=self.vm_auth, guestFilePath=guestFilePath)
        except vim.fault.NoPermission as e:
            raise AnsibleError("No Permission Error: %s %s" % (to_native(e.msg), to_native(e.privilegeId)))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…