将文件传输到vm

时间:2017-02-27 20:57:42

标签: python virtualbox

我目前正在开发一个脚本,该脚本将文件从Win10发送到运行Win10的Oracle vm。

我必须保持高安全性协议并且不超过脚本的限制,没有选择手动操作。

我对此并不熟悉并且不熟悉不同的方法,但是现在我尝试使用共享文件夹传输文件:

    self.vbox = virtualbox.VirtualBox()

    # The virtual box of the current executor.
    self.machine = self.vbox.find_machine("Windows 10")

    self.session = self.machine.create_session()

    # Create a shared folder. With this folder the client transfers the files of the current request which have
    # received from the server to its virtual machine.
    self.shared_folder_dir = os.path.dirname(os.path.realpath(__file__)) + "/Requests To Execute/"

    # Before any change or modification on the vm, the session must be locked using mutex, in order to make sure
    # that the vm won't be changed by one process while another one isn't aware.
    self.machine.lock_machine(self.session, virtualbox.LockType())
    self.mutable = self.session.getMachine()
    self.mutable.create_shared_folder("Requests", self.shared_folder_dir, True, True)
    self.mutable.saveSettings()
    self.session.unlockMachine()

我无法想象我如何提供一个LockType作为create_shared_folder的参数。无论如何,如果有人对如何传输文件有更好的了解,它也会很棒。

0 个答案:

没有答案