sethmlarson / virtualbox-python

Complete implementation of VirtualBox's COM API with a Pythonic interface.
https://pypi.org/project/virtualbox
Apache License 2.0
354 stars 75 forks source link

How to use create_unattended_installer() #129

Closed frnode closed 1 year ago

frnode commented 5 years ago
ENVIRONMENT
SUMMARY

Hello, I am currently using your library to create a virtual machine automatically, until then everything works. I want to use the automatic ISO installation, but that does not work, can you explain to me how this is supposed to work?

Here is the code snippet that I tried:

__iso_file = os.getcwd() + "/data/isos/" + cfg['machine']['iso']
__installer = self.vbox.create_unattended_installer()
__installer.iso_path = __iso_file
__installer.machine = IMachine(machine)
__installer.prepare()
__installer.construct_media()
__installer.reconfigure_vm()

And here is what it returns to me:

TypeError: Objects of type 'IMachine' can not be converted to a COM VARIANT (but obtaining the buffer() of this object could)

If someone can help me, thank you!

sethmlarson commented 5 years ago

Have you tried substituting IMachine(machine) for self.vbox.find_machine(machine)?

frnode commented 5 years ago

Hello, thank you for your answer.

The variable "machine" here is the return of the creation of my machine that I do just before:

machine = self.vbox.create_machine

I tried directly with a find_machine but the return is the same as in my previous question. Nevertheless I checked the variable "machine" is well considered as an object "IMachine", otherwise I will have like return "value is not an instance of IMachine".

I have the impression that the problem is located further, here are more logs:

Traceback (most recent call last):
  File "C:/Users/Node/Desktop/git/auto-manage-machine/automanagemachine/run.py", line 30, in <module>
    machine.run_install(vm)
  File "C:\Users\Node\Desktop\git\auto-manage-machine\automanagemachine\components\machine\machine_vbox.py", line 59, in run_install
    __installer.machine = IMachine(machine)
  File "C:\Users\Node\Desktop\git\auto-manage-machine\venv\lib\site-packages\virtualbox\library.py", line 9710, in machine
    return self._set_attr("machine", value)
  File "C:\Users\Node\Desktop\git\auto-manage-machine\venv\lib\site-packages\virtualbox\library_base.py", line 184, in _set_attr
    return setattr(self._i, name, value)
  File "C:\Users\Node\Desktop\git\auto-manage-machine\automanagemachine\vboxapi\__init__.py", line 193, in _CustomSetAttr
    return _g_dCOMForward['setattr'](self, ComifyName(sAttr), oValue)
  File "C:\Users\Node\Desktop\git\auto-manage-machine\venv\lib\site-packages\win32com\client\__init__.py", line 482, in __setattr__
    self._oleobj_.Invoke(*(args + (value,) + defArgs))
TypeError: Objects of type 'IMachine' can not be converted to a COM VARIANT (but obtaining the buffer() of this object could)
frnode commented 5 years ago

Hello, I raise, did you already use this function? Is this a bad use or is this function not implemented? On my side I still have not managed to use it after several tests...

thank you

sethmlarson commented 1 year ago

I no longer have time to maintain this library, so am closing this issue.