Need admin api advice

77 views
Skip to first unread message

Chris Laprise

unread,
Nov 26, 2017, 5:17:33 PM11/26/17
to qubes...@googlegroups.com
I'm trying to fix issue #3303 (inability to use --verify-only with
qvm-backup-restore) but to do that I need to supply vm objects that are
not actual vms. Otherwise, the tool can't cope with archives containing
vm names not present in the live system.

I'm not sure what is the right approach for instantiating 'dummy' vm
classes (or at least ones that will be useful to the restore tool).

Quick-fix me wants to do: dummyvm = qubesadmin.vm.QubesVM(None, "dummy1")

...but I want it to be correct.

--

Chris Laprise, tas...@posteo.net
https://github.com/tasket
https://twitter.com/ttaskett
PGP: BEE2 20C5 356E 764A 73EB 4AB3 1DC4 D106 F07F 1886

Marek Marczykowski-Górecki

unread,
Nov 26, 2017, 5:56:45 PM11/26/17
to Chris Laprise, qubes...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Sun, Nov 26, 2017 at 05:17:26PM -0500, Chris Laprise wrote:
> I'm trying to fix issue #3303 (inability to use --verify-only with
> qvm-backup-restore) but to do that I need to supply vm objects that are not
> actual vms. Otherwise, the tool can't cope with archives containing vm names
> not present in the live system.
>
> I'm not sure what is the right approach for instantiating 'dummy' vm classes
> (or at least ones that will be useful to the restore tool).
>
> Quick-fix me wants to do: dummyvm = qubesadmin.vm.QubesVM(None, "dummy1")
>
> ...but I want it to be correct.

This will raise NotImplementedError on the first try to call any
AdminAPI method - like getting property. Better create DummyQubes class,
being subclass of QubesBase (see qubesadmin/app.py), and put empty
qubesd_call method there. Then use that instead of None for QubesVM
constructor. Something like this:

class DummyQubes(qubesadmin.app.QubesBase):
def qubesd_call(self, *args, **kwargs):
pass

dummy_app = DummyQubes()

dummyvm = qubesadmin.vm.QubesVM(dummy_app, "dummy1")

- --
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJaFtXwAAoJENuP0xzK19cs8toH/j4uNMpUD1WppF4H87ICvc4c
w7GEhw/7IdsV4sqxsq442LuaXOFnusVfopFAfAL5YRT/nYRiGHuewmiy0eLD7M2t
AwVbIsDHDgroMjFpK5+qCc6EzRndzjdfi/z1nGK8hbMqlUc5SNLiG/V7Sj24FA52
vJKhFapv8q1aWbn0q1EU2FM0DxVbSNd8q8OZCbqfc/13g65j0nRkGh9gbJQrsOz9
qZx/inNsTm+vUKJ/Bfqhk66v5iEZv8v7jCvNUpRHSd2ZeuiA6NkxQehbSojplf8j
xJeO9WXp0FY6PGLY6wn4k+kJspuyqr3iGxM672RMgqvGqGAxImkQ2UWNLHGQLHg=
=dJ/I
-----END PGP SIGNATURE-----

Chris Laprise

unread,
Dec 1, 2017, 5:07:53 PM12/1/17
to Marek Marczykowski-Górecki, qubes...@googlegroups.com
On 11/26/2017 05:56 PM, Marek Marczykowski-Górecki wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On Sun, Nov 26, 2017 at 05:17:26PM -0500, Chris Laprise wrote:
>> I'm trying to fix issue #3303 (inability to use --verify-only with
>> qvm-backup-restore) but to do that I need to supply vm objects that are not
>> actual vms. Otherwise, the tool can't cope with archives containing vm names
>> not present in the live system.
>>
>> I'm not sure what is the right approach for instantiating 'dummy' vm classes
>> (or at least ones that will be useful to the restore tool).
>>
>> Quick-fix me wants to do: dummyvm = qubesadmin.vm.QubesVM(None, "dummy1")
>>
>> ...but I want it to be correct.
> This will raise NotImplementedError on the first try to call any
> AdminAPI method - like getting property. Better create DummyQubes class,
> being subclass of QubesBase (see qubesadmin/app.py), and put empty
> qubesd_call method there. Then use that instead of None for QubesVM
> constructor. Something like this:
>
> class DummyQubes(qubesadmin.app.QubesBase):
> def qubesd_call(self, *args, **kwargs):
> pass
>
> dummy_app = DummyQubes()
>
> dummyvm = qubesadmin.vm.QubesVM(dummy_app, "dummy1")

It works, but this seems to work as well:

new_vm = self.backup_app.domains[vm_name]

This may be preferable to adding a dummy class definition.
Reply all
Reply to author
Forward
0 new messages