将文件传输到vm

问题描述 投票:2回答:0

我目前正在研究一个脚本,该脚本还将文件从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的参数。 无论如何,如果有人对如何传输文件有更好的主意,那也将是很好的。

python virtualbox
© www.soinside.com 2019 - 2024. All rights reserved.