diff --git a/qubesadmin/app.py b/qubesadmin/app.py index aa55ce0..42f3c6a 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -56,7 +56,7 @@ class VMCollection(object): return vm_list_data = self.app.qubesd_call( 'dom0', - 'mgmt.vm.List' + 'admin.vm.List' ) new_vm_list = {} # FIXME: this will probably change @@ -95,7 +95,7 @@ class VMCollection(object): return item in self._vm_list def __delitem__(self, key): - self.app.qubesd_call(key, 'mgmt.vm.Remove') + self.app.qubesd_call(key, 'admin.vm.Remove') self.clear_cache() def __iter__(self): @@ -124,12 +124,12 @@ class QubesBase(qubesadmin.base.PropertyHolder): log = None def __init__(self): - super(QubesBase, self).__init__(self, 'mgmt.property.', 'dom0') + super(QubesBase, self).__init__(self, 'admin.property.', 'dom0') self.domains = VMCollection(self) self.labels = qubesadmin.base.WrapperObjectsCollection( - self, 'mgmt.label.List', qubesadmin.label.Label) + self, 'admin.label.List', qubesadmin.label.Label) self.pools = qubesadmin.base.WrapperObjectsCollection( - self, 'mgmt.pool.List', qubesadmin.storage.Pool) + self, 'admin.pool.List', qubesadmin.storage.Pool) #: cache for available storage pool drivers and options to create them self._pool_drivers = None self.log = logging.getLogger('app') @@ -142,7 +142,7 @@ class QubesBase(qubesadmin.base.PropertyHolder): ''' if self._pool_drivers is None: pool_drivers_data = self.qubesd_call( - 'dom0', 'mgmt.pool.ListDrivers', None, None) + 'dom0', 'admin.pool.ListDrivers', None, None) assert pool_drivers_data.endswith(b'\n') pool_drivers = {} for driver_line in pool_drivers_data.decode('ascii').splitlines(): @@ -176,12 +176,12 @@ class QubesBase(qubesadmin.base.PropertyHolder): payload = 'name={}\n'.format(name) + \ ''.join('{}={}\n'.format(key, value) for key, value in sorted(kwargs.items())) - self.qubesd_call('dom0', 'mgmt.pool.Add', driver, + self.qubesd_call('dom0', 'admin.pool.Add', driver, payload.encode('utf-8')) def remove_pool(self, name): ''' Remove a storage pool ''' - self.qubesd_call('dom0', 'mgmt.pool.Remove', name, None) + self.qubesd_call('dom0', 'admin.pool.Remove', name, None) def get_label(self, label): '''Get label as identified by index or name @@ -253,15 +253,15 @@ class QubesBase(qubesadmin.base.PropertyHolder): if pool and pools: raise ValueError('only one of pool= and pools= can be used') - method_prefix = 'mgmt.vm.Create.' + method_prefix = 'admin.vm.Create.' payload = 'name={} label={}'.format(name, label) if pool: payload += ' pool={}'.format(str(pool)) - method_prefix = 'mgmt.vm.CreateInPool.' + method_prefix = 'admin.vm.CreateInPool.' if pools: payload += ''.join(' pool:{}={}'.format(vol, str(pool)) for vol, pool in sorted(pools.items())) - method_prefix = 'mgmt.vm.CreateInPool.' + method_prefix = 'admin.vm.CreateInPool.' self.qubesd_call('dom0', method_prefix + cls, template, payload.encode('utf-8')) @@ -295,15 +295,15 @@ class QubesBase(qubesadmin.base.PropertyHolder): if not isinstance(src_vm, str): src_vm = str(src_vm) - method = 'mgmt.vm.Clone' + method = 'admin.vm.Clone' payload = 'name={}'.format(new_name) if pool: payload += ' pool={}'.format(str(pool)) - method = 'mgmt.vm.CloneInPool' + method = 'admin.vm.CloneInPool' if pools: payload += ''.join(' pool:{}={}'.format(vol, str(pool)) for vol, pool in sorted(pools.items())) - method = 'mgmt.vm.CloneInPool' + method = 'admin.vm.CloneInPool' self.qubesd_call(src_vm, method, None, payload.encode('utf-8')) @@ -374,7 +374,7 @@ class QubesLocal(QubesBase): if not dest: raise ValueError('Empty destination name allowed only from a VM') try: - self.qubesd_call(dest, 'mgmt.vm.Start') + self.qubesd_call(dest, 'admin.vm.Start') except qubesadmin.exc.QubesVMNotHaltedError: pass qrexec_opts = ['-d', dest] diff --git a/qubesadmin/base.py b/qubesadmin/base.py index f1e2d39..f3d8f3d 100644 --- a/qubesadmin/base.py +++ b/qubesadmin/base.py @@ -52,7 +52,7 @@ class PropertyHolder(object): defined by a subclass. :param dest: Destination VM name - :param method: Full API method name ('mgmt...') + :param method: Full API method name ('admin...') :param arg: Method argument (if any) :param payload: Payload send to the method :return: Data returned by qubesd (string) diff --git a/qubesadmin/devices.py b/qubesadmin/devices.py index ed598f3..1dc14d3 100644 --- a/qubesadmin/devices.py +++ b/qubesadmin/devices.py @@ -127,7 +127,7 @@ class DeviceCollection(object): options_str = ' '.join('{}={}'.format(opt, val) for opt, val in sorted(options.items())) self._vm.qubesd_call(None, - 'mgmt.vm.device.{}.Attach'.format(self._class), + 'admin.vm.device.{}.Attach'.format(self._class), '{!s}+{!s}'.format(device_assignment.backend_domain, device_assignment.ident), options_str.encode('utf-8')) @@ -145,7 +145,7 @@ class DeviceCollection(object): "Trying to detach DeviceAssignment belonging to other domain" self._vm.qubesd_call(None, - 'mgmt.vm.device.{}.Detach'.format(self._class), + 'admin.vm.device.{}.Detach'.format(self._class), '{!s}+{!s}'.format(device_assignment.backend_domain, device_assignment.ident)) @@ -162,7 +162,7 @@ class DeviceCollection(object): ''' assignments_str = self._vm.qubesd_call(None, - 'mgmt.vm.device.{}.List'.format(self._class)).decode() + 'admin.vm.device.{}.List'.format(self._class)).decode() for assignment_str in assignments_str.splitlines(): device, _, options_all = assignment_str.partition(' ') backend_domain, ident = device.split('+', 1) @@ -199,7 +199,7 @@ class DeviceCollection(object): def available(self): '''List devices exposed by this vm''' devices_str = self._vm.qubesd_call(None, - 'mgmt.vm.device.{}.Available'.format(self._class)).decode() + 'admin.vm.device.{}.Available'.format(self._class)).decode() for dev_str in devices_str.splitlines(): ident, _, info = dev_str.partition(' ') # description is special that it can contain spaces diff --git a/qubesadmin/events/__init__.py b/qubesadmin/events/__init__.py index e3f11e0..89c5ae1 100644 --- a/qubesadmin/events/__init__.py +++ b/qubesadmin/events/__init__.py @@ -77,7 +77,7 @@ class EventsDispatcher(object): reader, writer = yield from asyncio.open_unix_connection( qubesadmin.config.QUBESD_SOCKET) writer.write(b'dom0\0') # source - writer.write(b'mgmt.Events\0') # method + writer.write(b'admin.Events\0') # method writer.write(dest.encode('ascii') + b'\0') # dest writer.write(b'\0') # arg writer.write_eof() @@ -87,7 +87,7 @@ class EventsDispatcher(object): writer.close() elif self.app.qubesd_connection_type == 'qrexec': proc = yield from asyncio.create_subprocess_exec( - ['qrexec-client-vm', dest, 'mgmt.Events'], + ['qrexec-client-vm', dest, 'admin.Events'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) proc.stdin.write_eof() diff --git a/qubesadmin/features.py b/qubesadmin/features.py index e421251..8869df4 100644 --- a/qubesadmin/features.py +++ b/qubesadmin/features.py @@ -39,18 +39,18 @@ class Features(object): self.vm = vm def __delitem__(self, key): - self.vm.qubesd_call(self.vm.name, 'mgmt.vm.feature.Remove', key) + self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Remove', key) def __setitem__(self, key, value): - self.vm.qubesd_call(self.vm.name, 'mgmt.vm.feature.Set', key, value) + self.vm.qubesd_call(self.vm.name, 'admin.vm.feature.Set', key, value) def __getitem__(self, item): return self.vm.qubesd_call( - self.vm.name, 'mgmt.vm.feature.Get', item).decode('utf-8') + self.vm.name, 'admin.vm.feature.Get', item).decode('utf-8') def __iter__(self): qubesd_response = self.vm.qubesd_call(self.vm.name, - 'mgmt.vm.feature.List') + 'admin.vm.feature.List') return iter(qubesd_response.decode('utf-8').splitlines()) keys = __iter__ @@ -61,7 +61,7 @@ class Features(object): ''' Check if the vm's template has the specified feature. ''' try: qubesd_response = self.vm.qubesd_call( - self.vm.name, 'mgmt.vm.feature.CheckWithTemplate', feature) + self.vm.name, 'admin.vm.feature.CheckWithTemplate', feature) return qubesd_response.decode('utf-8') except KeyError: if default is self._NO_DEFAULT: diff --git a/qubesadmin/firewall.py b/qubesadmin/firewall.py index 06045cf..252fe7c 100644 --- a/qubesadmin/firewall.py +++ b/qubesadmin/firewall.py @@ -394,7 +394,7 @@ class Firewall(object): def load_rules(self): '''Force (re-)loading firewall rules''' - rules_str = self.vm.qubesd_call(None, 'mgmt.vm.firewall.Get') + rules_str = self.vm.qubesd_call(None, 'admin.vm.firewall.Get') rules = [] for rule_str in rules_str.decode().splitlines(): rules.append(Rule(rule_str)) @@ -425,19 +425,19 @@ class Firewall(object): ''' if rules is None: rules = self._rules - self.vm.qubesd_call(None, 'mgmt.vm.firewall.Set', + self.vm.qubesd_call(None, 'admin.vm.firewall.Set', payload=(''.join('{}\n'.format(rule.rule) for rule in rules)).encode('ascii')) @property def policy(self): '''Default action to take if no rule matches''' - policy_str = self.vm.qubesd_call(None, 'mgmt.vm.firewall.GetPolicy') + policy_str = self.vm.qubesd_call(None, 'admin.vm.firewall.GetPolicy') return Action(policy_str.decode()) @policy.setter def policy(self, value): - self.vm.qubesd_call(None, 'mgmt.vm.firewall.SetPolicy', payload=str( + self.vm.qubesd_call(None, 'admin.vm.firewall.SetPolicy', payload=str( value).encode('ascii')) def reload(self): @@ -445,4 +445,4 @@ class Firewall(object): Can be used for example to force again names resolution. ''' - self.vm.qubesd_call(None, 'mgmt.vm.firewall.Reload') + self.vm.qubesd_call(None, 'admin.vm.firewall.Reload') diff --git a/qubesadmin/label.py b/qubesadmin/label.py index a01d15c..6fab844 100644 --- a/qubesadmin/label.py +++ b/qubesadmin/label.py @@ -44,7 +44,7 @@ class Label(object): if self._color is None: try: qubesd_response = self.app.qubesd_call( - 'dom0', 'mgmt.label.Get', self._name, None) + 'dom0', 'admin.label.Get', self._name, None) except qubesadmin.exc.QubesDaemonNoResponseError: raise AttributeError self._color = qubesd_response.decode() @@ -67,7 +67,7 @@ class Label(object): if self._index is None: try: qubesd_response = self.app.qubesd_call( - 'dom0', 'mgmt.label.Index', self._name, None) + 'dom0', 'admin.label.Index', self._name, None) except qubesadmin.exc.QubesDaemonNoResponseError: raise AttributeError self._index = int(qubesd_response.decode()) diff --git a/qubesadmin/storage.py b/qubesadmin/storage.py index 2cf20d2..b81b9b1 100644 --- a/qubesadmin/storage.py +++ b/qubesadmin/storage.py @@ -54,11 +54,11 @@ class Volume(object): :param bytes payload: Payload to send. ''' if self._vm is not None: - method = 'mgmt.vm.volume.' + func_name + method = 'admin.vm.volume.' + func_name dest = self._vm arg = self._vm_name else: - method = 'mgmt.pool.volume.' + func_name + method = 'admin.pool.volume.' + func_name dest = 'dom0' arg = self._pool if payload is not None: @@ -213,7 +213,7 @@ class Pool(object): ''' Storage pool config ''' if self._config is None: pool_info_data = self.app.qubesd_call( - 'dom0', 'mgmt.pool.Info', self.name, None) + 'dom0', 'admin.pool.Info', self.name, None) pool_info_data = pool_info_data.decode('utf-8') assert pool_info_data.endswith('\n') pool_info_data = pool_info_data[:-1] @@ -230,7 +230,7 @@ class Pool(object): def volumes(self): ''' Volumes managed by this pool ''' volumes_data = self.app.qubesd_call( - 'dom0', 'mgmt.pool.volume.List', self.name, None) + 'dom0', 'admin.pool.volume.List', self.name, None) assert volumes_data.endswith(b'\n') volumes_data = volumes_data[:-1].decode('ascii') for vid in volumes_data.splitlines(): diff --git a/qubesadmin/tests/app.py b/qubesadmin/tests/app.py index 6b8cfbe..02ff4a3 100644 --- a/qubesadmin/tests/app.py +++ b/qubesadmin/tests/app.py @@ -36,7 +36,7 @@ import qubesadmin.tests class TC_00_VMCollection(qubesadmin.tests.QubesTestCase): def test_000_list(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.assertEqual( list(self.app.domains.keys()), @@ -44,7 +44,7 @@ class TC_00_VMCollection(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_001_getitem(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' try: vm = self.app.domains['test-vm'] @@ -58,7 +58,7 @@ class TC_00_VMCollection(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_002_in(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.assertIn('test-vm', self.app.domains) self.assertAllCalled() @@ -67,13 +67,13 @@ class TC_00_VMCollection(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_003_iter(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.assertEqual([vm.name for vm in self.app.domains], ['test-vm']) self.assertAllCalled() def test_004_delitem(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.Remove', None, None)] = \ + self.app.expected_calls[('test-vm', 'admin.vm.Remove', None, None)] = \ b'0\x00' del self.app.domains['test-vm'] self.assertAllCalled() @@ -81,9 +81,9 @@ class TC_00_VMCollection(qubesadmin.tests.QubesTestCase): class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): def test_010_new_simple(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', None, + self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM', None, b'name=new-vm label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Running\n' vm = self.app.add_new_vm('AppVM', 'new-vm', 'red') self.assertEqual(vm.name, 'new-vm') @@ -91,9 +91,9 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_011_new_template(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.TemplateVM', None, + self.app.expected_calls[('dom0', 'admin.vm.Create.TemplateVM', None, b'name=new-template label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-template class=TemplateVM state=Running\n' vm = self.app.add_new_vm('TemplateVM', 'new-template', 'red') self.assertEqual(vm.name, 'new-template') @@ -101,9 +101,9 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_012_new_template_based(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', + self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM', 'some-template', b'name=new-vm label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Running\n' vm = self.app.add_new_vm('AppVM', 'new-vm', 'red', 'some-template') self.assertEqual(vm.name, 'new-vm') @@ -111,11 +111,11 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_013_new_objects_params(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', + self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM', 'some-template', b'name=new-vm label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Running\n' \ b'some-template class=TemplateVM state=Running\n' vm = self.app.add_new_vm(self.app.get_vm_class('AppVM'), 'new-vm', @@ -125,9 +125,9 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_014_new_pool(self): - self.app.expected_calls[('dom0', 'mgmt.vm.CreateInPool.AppVM', None, + self.app.expected_calls[('dom0', 'admin.vm.CreateInPool.AppVM', None, b'name=new-vm label=red pool=some-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Running\n' vm = self.app.add_new_vm('AppVM', 'new-vm', 'red', pool='some-pool') self.assertEqual(vm.name, 'new-vm') @@ -135,10 +135,10 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_015_new_pools(self): - self.app.expected_calls[('dom0', 'mgmt.vm.CreateInPool.AppVM', None, + self.app.expected_calls[('dom0', 'admin.vm.CreateInPool.AppVM', None, b'name=new-vm label=red pool:private=some-pool ' b'pool:volatile=other-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Running\n' vm = self.app.add_new_vm('AppVM', 'new-vm', 'red', pools={'private': 'some-pool', 'volatile': 'other-pool'}) @@ -147,16 +147,16 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_020_get_label(self): - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' label = self.app.get_label('red') self.assertEqual(label.name, 'red') self.assertAllCalled() def test_030_clone(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.Clone', None, + self.app.expected_calls[('test-vm', 'admin.vm.Clone', None, b'name=new-name')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-name class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' new_vm = self.app.clone_vm('test-vm', 'new-name') @@ -164,9 +164,9 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_031_clone_object(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.Clone', None, + self.app.expected_calls[('test-vm', 'admin.vm.Clone', None, b'name=new-name')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-name class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' new_vm = self.app.clone_vm(self.app.domains['test-vm'], 'new-name') @@ -174,9 +174,9 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_032_clone_pool(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.CloneInPool', None, + self.app.expected_calls[('test-vm', 'admin.vm.CloneInPool', None, b'name=new-name pool=some-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-name class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' new_vm = self.app.clone_vm('test-vm', 'new-name', pool='some-pool') @@ -184,10 +184,10 @@ class TC_10_QubesBase(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_033_clone_pools(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.CloneInPool', None, + self.app.expected_calls[('test-vm', 'admin.vm.CloneInPool', None, b'name=new-name pool:private=some-pool ' b'pool:volatile=other-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-name class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' new_vm = self.app.clone_vm('test-vm', 'new-name', @@ -268,7 +268,7 @@ class TC_20_QubesLocal(unittest.TestCase): stderr=subprocess.PIPE) self.assertEqual(self.get_request(), - b'dom0\0mgmt.vm.Start\0some-vm\0\0') + b'dom0\0admin.vm.Start\0some-vm\0\0') def test_011_run_service_filter_esc(self): self.listen_and_send(b'0\0') @@ -282,7 +282,7 @@ class TC_20_QubesLocal(unittest.TestCase): stderr=subprocess.PIPE) self.assertEqual(self.get_request(), - b'dom0\0mgmt.vm.Start\0some-vm\0\0') + b'dom0\0admin.vm.Start\0some-vm\0\0') def test_012_run_service_user(self): self.listen_and_send(b'0\0') @@ -296,7 +296,7 @@ class TC_20_QubesLocal(unittest.TestCase): stderr=subprocess.PIPE) self.assertEqual(self.get_request(), - b'dom0\0mgmt.vm.Start\0some-vm\0\0') + b'dom0\0admin.vm.Start\0some-vm\0\0') def test_013_run_service_default_target(self): with self.assertRaises(ValueError): diff --git a/qubesadmin/tests/devices.py b/qubesadmin/tests/devices.py index 347f122..bb057dc 100644 --- a/qubesadmin/tests/devices.py +++ b/qubesadmin/tests/devices.py @@ -25,7 +25,7 @@ import qubesadmin.devices class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def setUp(self): super(TC_00_DeviceCollection, self).setUp() - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\0test-vm class=AppVM state=Running\n' \ b'test-vm2 class=AppVM state=Running\n' \ b'test-vm3 class=AppVM state=Running\n' @@ -33,7 +33,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_000_available(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1\n' devices = list(self.vm.devices['test'].available()) self.assertEqual(len(devices), 1) @@ -49,7 +49,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_001_available_desc(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1 description=This is description\n' devices = list(self.vm.devices['test'].available()) self.assertEqual(len(devices), 1) @@ -64,7 +64,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_002_available_options(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1 ro=True other=123 description=This is description\n' devices = list(self.vm.devices['test'].available()) self.assertEqual(len(devices), 1) @@ -80,7 +80,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_010_getitem(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1 description=This is description\n' dev = self.vm.devices['test']['dev1'] self.assertIsInstance(dev, qubesadmin.devices.DeviceInfo) @@ -94,7 +94,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_011_getitem_missing(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1 description=This is description\n' dev = self.vm.devices['test']['dev2'] self.assertIsInstance(dev, qubesadmin.devices.UnknownDevice) @@ -108,7 +108,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_020_attach(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1', b'')] = \ + ('test-vm', 'admin.vm.device.test.Attach', 'test-vm2+dev1', b'')] = \ b'0\0' assign = qubesadmin.devices.DeviceAssignment( self.app.domains['test-vm2'], 'dev1') @@ -117,7 +117,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_021_attach_options(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1', + ('test-vm', 'admin.vm.device.test.Attach', 'test-vm2+dev1', b'ro=True something=value')] = b'0\0' assign = qubesadmin.devices.DeviceAssignment( self.app.domains['test-vm2'], 'dev1') @@ -128,7 +128,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_022_attach_persistent(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1', + ('test-vm', 'admin.vm.device.test.Attach', 'test-vm2+dev1', b'persistent=yes')] = b'0\0' assign = qubesadmin.devices.DeviceAssignment( self.app.domains['test-vm2'], 'dev1') @@ -138,7 +138,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_023_attach_persistent_options(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1', + ('test-vm', 'admin.vm.device.test.Attach', 'test-vm2+dev1', b'persistent=yes ro=True')] = b'0\0' assign = qubesadmin.devices.DeviceAssignment( self.app.domains['test-vm2'], 'dev1') @@ -149,7 +149,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_030_detach(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.Detach', 'test-vm2+dev1', + ('test-vm', 'admin.vm.device.test.Detach', 'test-vm2+dev1', None)] = b'0\0' assign = qubesadmin.devices.DeviceAssignment( self.app.domains['test-vm2'], 'dev1') @@ -158,7 +158,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_040_assignments(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.List', None, None)] = \ + ('test-vm', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm2+dev1\n' \ b'test-vm3+dev2\n' assigns = list(self.vm.devices['test'].assignments()) @@ -183,7 +183,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_041_assignments_options(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.List', None, None)] = \ + ('test-vm', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm2+dev1 ro=True\n' \ b'test-vm3+dev2 ro=False persistent=True\n' assigns = list(self.vm.devices['test'].assignments()) @@ -210,7 +210,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_041_assignments_persistent(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.List', None, None)] = \ + ('test-vm', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm2+dev1\n' \ b'test-vm3+dev2 persistent=True\n' assigns = list(self.vm.devices['test'].assignments(True)) @@ -227,7 +227,7 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_042_assignments_non_persistent(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.List', None, None)] = \ + ('test-vm', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm2+dev1\n' \ b'test-vm3+dev2 persistent=True\n' assigns = list(self.vm.devices['test'].assignments(False)) @@ -244,11 +244,11 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_050_persistent(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.List', None, None)] = \ + ('test-vm', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm2+dev1\n' \ b'test-vm3+dev2 persistent=True\n' self.app.expected_calls[ - ('test-vm3', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm3', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev2\n' devs = list(self.vm.devices['test'].persistent()) self.assertEqual(len(devs), 1) @@ -259,14 +259,14 @@ class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase): def test_060_attached(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.device.test.List', None, None)] = \ + ('test-vm', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm2+dev1\n' \ b'test-vm3+dev2 persistent=True\n' self.app.expected_calls[ - ('test-vm2', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm2', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1\n' self.app.expected_calls[ - ('test-vm3', 'mgmt.vm.device.test.Available', None, None)] = \ + ('test-vm3', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev2\n' devs = list(self.vm.devices['test'].attached()) self.assertEqual(len(devs), 2) diff --git a/qubesadmin/tests/errors.py b/qubesadmin/tests/errors.py index 012e4c0..cc8959f 100644 --- a/qubesadmin/tests/errors.py +++ b/qubesadmin/tests/errors.py @@ -24,14 +24,14 @@ import unittest class TC_00_Errors(qubesadmin.tests.QubesTestCase): def test_000_exception(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'2\x00QubesException\x00\x00An error occurred\x00' with self.assertRaises(qubesadmin.exc.QubesException) as context: vms = list(self.app.domains) self.assertEqual(str(context.exception), 'An error occurred') def test_001_exception_with_fields(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'2\x00QubesException\x00\x00' \ b'An error occurred: %s, %s\x00string\x00other\x00' with self.assertRaises(qubesadmin.exc.QubesException) as context: @@ -40,7 +40,7 @@ class TC_00_Errors(qubesadmin.tests.QubesTestCase): 'An error occurred: string, other') def test_002_exception_with_numbers(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'2\x00QubesException\x00\x00' \ b'An error occurred: %d, %d\x001\x002\x00' try: @@ -51,7 +51,7 @@ class TC_00_Errors(qubesadmin.tests.QubesTestCase): self.assertEqual(str(context.exception), 'An error occurred: 1, 2') def test_010_empty(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = b'' + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = b'' with self.assertRaises(qubesadmin.exc.QubesDaemonNoResponseError) \ as context: vms = list(self.app.domains) diff --git a/qubesadmin/tests/events.py b/qubesadmin/tests/events.py index 081655b..a14f79b 100644 --- a/qubesadmin/tests/events.py +++ b/qubesadmin/tests/events.py @@ -145,7 +145,7 @@ class TC_00_Events(qubesadmin.tests.QubesTestCase): self.read_all, sock2)) loop.run_until_complete(asyncio.wait([task, reader])) self.assertEqual(reader.result(), - b'dom0\0mgmt.Events\0dom0\0\0') + b'dom0\0admin.Events\0dom0\0\0') self.assertIsInstance(task.result()[0], asyncio.StreamReader) cleanup_func = task.result()[1] cleanup_func() @@ -171,7 +171,7 @@ class TC_00_Events(qubesadmin.tests.QubesTestCase): self.read_all, sock2)) loop.run_until_complete(asyncio.wait([task, reader])) self.assertEqual(reader.result(), - b'dom0\0mgmt.Events\0test-vm\0\0') + b'dom0\0admin.Events\0test-vm\0\0') self.assertIsInstance(task.result()[0], asyncio.StreamReader) cleanup_func = task.result()[1] cleanup_func() @@ -198,7 +198,7 @@ class TC_00_Events(qubesadmin.tests.QubesTestCase): loop.run_until_complete(task) self.assertEqual(mock_proc.mock_calls, [ unittest.mock.call(['qrexec-client-vm', 'dom0', - 'mgmt.Events'], stdin=subprocess.PIPE, + 'admin.Events'], stdin=subprocess.PIPE, stdout=subprocess.PIPE), unittest.mock.call().stdin.write_eof() ]) @@ -223,7 +223,7 @@ class TC_00_Events(qubesadmin.tests.QubesTestCase): loop.run_until_complete(task) self.assertEqual(mock_proc.mock_calls, [ unittest.mock.call(['qrexec-client-vm', 'test-vm', - 'mgmt.Events'], stdin=subprocess.PIPE, + 'admin.Events'], stdin=subprocess.PIPE, stdout=subprocess.PIPE), unittest.mock.call().stdin.write_eof() ]) diff --git a/qubesadmin/tests/firewall.py b/qubesadmin/tests/firewall.py index 00bff87..1270e62 100644 --- a/qubesadmin/tests/firewall.py +++ b/qubesadmin/tests/firewall.py @@ -405,12 +405,12 @@ class TC_10_Rule(qubesadmin.tests.QubesTestCase): class TC_11_Firewall(qubesadmin.tests.QubesTestCase): def setUp(self): super(TC_11_Firewall, self).setUp() - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\0test-vm class=AppVM state=Halted\n' self.vm = self.app.domains['test-vm'] def test_000_policy_get(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.GetPolicy', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.GetPolicy', None, None)] = b'0\0accept' policy = self.vm.firewall.policy self.assertEqual(policy, 'accept') @@ -418,19 +418,19 @@ class TC_11_Firewall(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_001_policy_set(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.SetPolicy', None, b'drop')] = b'0\0' self.vm.firewall.policy = 'drop' self.assertAllCalled() def test_002_policy_set2(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.SetPolicy', None, b'drop')] = b'0\0' self.vm.firewall.policy = qubesadmin.firewall.Action('drop') self.assertAllCalled() def test_010_load_rules(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' @@ -440,12 +440,12 @@ class TC_11_Firewall(qubesadmin.tests.QubesTestCase): qubesadmin.firewall.Rule('action=drop proto=icmp'), ]) # check caching - del self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + del self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] rules2 = self.vm.firewall.rules self.assertEqual(rules, rules2) # then force reload - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org proto=tcp dstports=443\n' self.vm.firewall.load_rules() @@ -461,7 +461,7 @@ class TC_11_Firewall(qubesadmin.tests.QubesTestCase): 'action=accept dsthost=example.com', ) rules = [qubesadmin.firewall.Rule(rule) for rule in rules_txt] - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None, + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Set', None, ''.join(rule + '\n' for rule in rules_txt).encode('ascii'))] = b'0\0' self.vm.firewall.rules = rules self.assertAllCalled() \ No newline at end of file diff --git a/qubesadmin/tests/label.py b/qubesadmin/tests/label.py index ea99422..16815a5 100644 --- a/qubesadmin/tests/label.py +++ b/qubesadmin/tests/label.py @@ -25,7 +25,7 @@ from qubesadmin.label import Label class TC_00_Label(qubesadmin.tests.QubesTestCase): def test_000_list(self): self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00green\nred\nblack\n' seen = set() for label in self.app.labels: @@ -35,7 +35,7 @@ class TC_00_Label(qubesadmin.tests.QubesTestCase): def test_010_get(self): self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00green\nred\nblack\n' label = self.app.labels['green'] self.assertIsInstance(label, Label) @@ -43,26 +43,26 @@ class TC_00_Label(qubesadmin.tests.QubesTestCase): def test_011_get_color(self): self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00green\nred\nblack\n' self.app.expected_calls[ - ('dom0', 'mgmt.label.Get', 'green', None)] = \ + ('dom0', 'admin.label.Get', 'green', None)] = \ b'0\x000x00FF00' label = self.app.labels['green'] self.assertEqual(label.color, '0x00FF00') def test_012_get_index(self): self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00green\nred\nblack\n' self.app.expected_calls[ - ('dom0', 'mgmt.label.Index', 'green', None)] = b'0\x003' + ('dom0', 'admin.label.Index', 'green', None)] = b'0\x003' label = self.app.labels['green'] self.assertEqual(label.index, 3) def test_024_get_icon(self): self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00green\nred\nblack\n' label = self.app.labels['green'] self.assertEqual(label.icon, 'appvm-green') diff --git a/qubesadmin/tests/storage.py b/qubesadmin/tests/storage.py index 9e05413..74dd011 100644 --- a/qubesadmin/tests/storage.py +++ b/qubesadmin/tests/storage.py @@ -32,7 +32,7 @@ class TestVMVolume(qubesadmin.tests.QubesTestCase): def expect_info(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.Info', 'volname', None)] = \ + ('test-vm', 'admin.vm.volume.Info', 'volname', None)] = \ b'0\x00' \ b'pool=test-pool\n' \ b'vid=some-id\n' \ @@ -47,7 +47,7 @@ class TestVMVolume(qubesadmin.tests.QubesTestCase): def test_000_qubesd_call(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.TestMethod', 'volname', None)] = \ + ('test-vm', 'admin.vm.volume.TestMethod', 'volname', None)] = \ b'0\x00method_result' self.assertEqual(self.vol._qubesd_call('TestMethod'), b'method_result') @@ -55,7 +55,7 @@ class TestVMVolume(qubesadmin.tests.QubesTestCase): def test_001_fetch_info(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.Info', 'volname', None)] = \ + ('test-vm', 'admin.vm.volume.Info', 'volname', None)] = \ b'0\x00prop1=val1\nprop2=val2\n' self.vol._fetch_info() self.assertEqual(self.vol._info, {'prop1': 'val1', 'prop2': 'val2'}) @@ -121,7 +121,7 @@ class TestVMVolume(qubesadmin.tests.QubesTestCase): def test_021_revisions(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.ListSnapshots', 'volname', None)] = \ + ('test-vm', 'admin.vm.volume.ListSnapshots', 'volname', None)] = \ b'0\x00' \ b'snapid1\n' \ b'snapid2\n' \ @@ -132,20 +132,20 @@ class TestVMVolume(qubesadmin.tests.QubesTestCase): def test_022_revisions_empty(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.ListSnapshots', 'volname', None)] = \ + ('test-vm', 'admin.vm.volume.ListSnapshots', 'volname', None)] = \ b'0\x00' self.assertEqual(self.vol.revisions, []) self.assertAllCalled() def test_030_resize(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.Resize', 'volname', b'2048')] = b'0\x00' + ('test-vm', 'admin.vm.volume.Resize', 'volname', b'2048')] = b'0\x00' self.vol.resize(2048) self.assertAllCalled() def test_031_revert(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.Revert', 'volname', b'snapid1')] = \ + ('test-vm', 'admin.vm.volume.Revert', 'volname', b'snapid1')] = \ b'0\x00' self.vol.revert('snapid1') self.assertAllCalled() @@ -159,7 +159,7 @@ class TestPoolVolume(TestVMVolume): def test_000_qubesd_call(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.TestMethod', + ('dom0', 'admin.pool.volume.TestMethod', 'test-pool', b'some-id')] = \ b'0\x00method_result' self.assertEqual(self.vol._qubesd_call('TestMethod'), @@ -168,7 +168,7 @@ class TestPoolVolume(TestVMVolume): def expect_info(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.Info', 'test-pool', b'some-id')] = \ + ('dom0', 'admin.pool.volume.Info', 'test-pool', b'some-id')] = \ b'0\x00' \ b'pool=test-pool\n' \ b'vid=some-id\n' \ @@ -183,7 +183,7 @@ class TestPoolVolume(TestVMVolume): def test_001_fetch_info(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.Info', 'test-pool', + ('dom0', 'admin.pool.volume.Info', 'test-pool', b'some-id')] = \ b'0\x00prop1=val1\nprop2=val2\n' self.vol._fetch_info() @@ -202,7 +202,7 @@ class TestPoolVolume(TestVMVolume): def test_021_revisions(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.ListSnapshots', + ('dom0', 'admin.pool.volume.ListSnapshots', 'test-pool', b'some-id')] = \ b'0\x00' \ b'snapid1\n' \ @@ -214,21 +214,21 @@ class TestPoolVolume(TestVMVolume): def test_022_revisions_empty(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.ListSnapshots', + ('dom0', 'admin.pool.volume.ListSnapshots', 'test-pool', b'some-id')] = b'0\x00' self.assertEqual(self.vol.revisions, []) self.assertAllCalled() def test_030_resize(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.Resize', + ('dom0', 'admin.pool.volume.Resize', 'test-pool', b'some-id 2048')] = b'0\x00' self.vol.resize(2048) self.assertAllCalled() def test_031_revert(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.Revert', 'test-pool', + ('dom0', 'admin.pool.volume.Revert', 'test-pool', b'some-id snapid1')] = b'0\x00' self.vol.revert('snapid1') self.assertAllCalled() @@ -236,7 +236,7 @@ class TestPoolVolume(TestVMVolume): class TestPool(qubesadmin.tests.QubesTestCase): def test_000_list(self): - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00file\nlvm\n' seen = set() for pool in self.app.pools: @@ -249,9 +249,9 @@ class TestPool(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_010_config(self): - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00file\nlvm\n' - self.app.expected_calls[('dom0', 'mgmt.pool.Info', 'file', None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.Info', 'file', None)] = \ b'0\x00driver=file\n' \ b'dir_path=/var/lib/qubes\n' \ b'name=file\n' \ @@ -266,10 +266,10 @@ class TestPool(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_020_volumes(self): - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00file\nlvm\n' self.app.expected_calls[ - ('dom0', 'mgmt.pool.volume.List', 'file', None)] = \ + ('dom0', 'admin.pool.volume.List', 'file', None)] = \ b'0\x00vol1\n' \ b'vol2\n' pool = self.app.pools['file'] @@ -286,7 +286,7 @@ class TestPool(qubesadmin.tests.QubesTestCase): def test_030_pool_drivers(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.ListDrivers', None, None)] = \ + ('dom0', 'admin.pool.ListDrivers', None, None)] = \ b'0\x00file dir_path revisions_to_keep\n' \ b'lvm volume_group thin_pool revisions_to_keep\n' self.assertEqual(set(self.app.pool_drivers), set(['file', 'lvm'])) @@ -296,7 +296,7 @@ class TestPool(qubesadmin.tests.QubesTestCase): def test_040_add(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.Add', 'some-driver', + ('dom0', 'admin.pool.Add', 'some-driver', b'name=test-pool\nparam1=value1\nparam2=123\n')] = b'0\x00' self.app.add_pool('test-pool', driver='some-driver', param1='value1', param2=123) @@ -304,6 +304,6 @@ class TestPool(qubesadmin.tests.QubesTestCase): def test_050_remove(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.Remove', 'test-pool', None)] = b'0\x00' + ('dom0', 'admin.pool.Remove', 'test-pool', None)] = b'0\x00' self.app.remove_pool('test-pool') self.assertAllCalled() diff --git a/qubesadmin/tests/tools/qubes_prefs.py b/qubesadmin/tests/tools/qubes_prefs.py index 1efa22f..4403f14 100644 --- a/qubesadmin/tests/tools/qubes_prefs.py +++ b/qubesadmin/tests/tools/qubes_prefs.py @@ -26,13 +26,13 @@ import qubesadmin.tools.qubes_prefs class TC_00_qubes_prefs(qubesadmin.tests.QubesTestCase): def test_000_list(self): self.app.expected_calls[ - ('dom0', 'mgmt.property.List', None, None)] = \ + ('dom0', 'admin.property.List', None, None)] = \ b'0\x00prop1\nprop2\n' self.app.expected_calls[ - ('dom0', 'mgmt.property.Get', 'prop1', None)] = \ + ('dom0', 'admin.property.Get', 'prop1', None)] = \ b'0\x00default=True type=str value1' self.app.expected_calls[ - ('dom0', 'mgmt.property.Get', 'prop2', None)] = \ + ('dom0', 'admin.property.Get', 'prop2', None)] = \ b'0\x00default=False type=str value2' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual(0, qubesadmin.tools.qubes_prefs.main([], app=self.app)) @@ -43,7 +43,7 @@ class TC_00_qubes_prefs(qubesadmin.tests.QubesTestCase): def test_002_set_property(self): self.app.expected_calls[ - ('dom0', 'mgmt.property.Set', 'default_user', b'testuser')]\ + ('dom0', 'admin.property.Set', 'default_user', b'testuser')]\ = b'0\x00' self.assertEqual(0, qubesadmin.tools.qubes_prefs.main([ 'default_user', 'testuser'], app=self.app)) @@ -51,7 +51,7 @@ class TC_00_qubes_prefs(qubesadmin.tests.QubesTestCase): def test_003_invalid_property(self): self.app.expected_calls[ - ('dom0', 'mgmt.property.Get', 'no_such_property', None)] = \ + ('dom0', 'admin.property.Get', 'no_such_property', None)] = \ b'2\x00AttributeError\x00\x00no_such_property\x00' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -63,7 +63,7 @@ class TC_00_qubes_prefs(qubesadmin.tests.QubesTestCase): def test_004_set_invalid_property(self): self.app.expected_calls[ - ('dom0', 'mgmt.property.Set', 'no_such_property', b'value')]\ + ('dom0', 'admin.property.Set', 'no_such_property', b'value')]\ = b'2\x00AttributeError\x00\x00no_such_property\x00' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: diff --git a/qubesadmin/tests/tools/qvm_check.py b/qubesadmin/tests/tools/qvm_check.py index 16f743e..4897925 100644 --- a/qubesadmin/tests/tools/qvm_check.py +++ b/qubesadmin/tests/tools/qvm_check.py @@ -24,7 +24,7 @@ import qubesadmin.tools.qvm_check class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_000_exists(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.assertEqual( qubesadmin.tools.qvm_check.main(['some-vm'], app=self.app), @@ -33,7 +33,7 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_001_exists_multi(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'other-vm class=AppVM state=Running\n' self.assertEqual( @@ -44,7 +44,7 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_002_exists_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -56,7 +56,7 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_003_exists_multi_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'other-vm class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: @@ -70,12 +70,12 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_004_running_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -88,15 +88,15 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_005_running_multi_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -110,18 +110,18 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_006_running_multi_verbose2(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm3', 'mgmt.vm.List', None, None)] = \ + ('some-vm3', 'admin.vm.List', None, None)] = \ b'0\x00some-vm3 class=AppVM state=Halted\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -135,12 +135,12 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_007_not_running_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm3', 'mgmt.vm.List', None, None)] = \ + ('some-vm3', 'admin.vm.List', None, None)] = \ b'0\x00some-vm3 class=AppVM state=Halted\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -154,12 +154,12 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_008_paused(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Paused\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -173,15 +173,15 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_009_paused_multi(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Paused\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -196,7 +196,7 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_010_template(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=TemplateVM state=Halted\n' @@ -212,7 +212,7 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase): def test_011_template_multi(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=TemplateVM state=Halted\n' diff --git a/qubesadmin/tests/tools/qvm_clone.py b/qubesadmin/tests/tools/qvm_clone.py index d531684..b4c33a1 100644 --- a/qubesadmin/tests/tools/qvm_clone.py +++ b/qubesadmin/tests/tools/qvm_clone.py @@ -24,9 +24,9 @@ import qubesadmin.tools.qvm_clone class TC_00_qvm_clone(qubesadmin.tests.QubesTestCase): def test_000_simple(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.Clone', None, + self.app.expected_calls[('test-vm', 'admin.vm.Clone', None, b'name=new-vm')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_clone.main(['test-vm', 'new-vm'], app=self.app) @@ -40,9 +40,9 @@ class TC_00_qvm_clone(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_004_pool(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.CloneInPool', + self.app.expected_calls[('test-vm', 'admin.vm.CloneInPool', None, b'name=new-vm pool=some-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_clone.main(['-P', 'some-pool', 'test-vm', 'new-vm'], @@ -50,10 +50,10 @@ class TC_00_qvm_clone(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_005_pools(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.CloneInPool', + self.app.expected_calls[('test-vm', 'admin.vm.CloneInPool', None, b'name=new-vm pool:private=some-pool ' b'pool:volatile=other-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' \ b'test-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_clone.main(['--pool', 'private=some-pool', diff --git a/qubesadmin/tests/tools/qvm_create.py b/qubesadmin/tests/tools/qvm_create.py index b934b37..bf934e4 100644 --- a/qubesadmin/tests/tools/qvm_create.py +++ b/qubesadmin/tests/tools/qvm_create.py @@ -24,11 +24,11 @@ import qubesadmin.tools.qvm_create class TC_00_qvm_create(qubesadmin.tests.QubesTestCase): def test_000_just_appvm(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', None, + self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM', None, b'name=new-vm label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_create.main(['-l', 'red', 'new-vm'], app=self.app) self.assertAllCalled() @@ -41,24 +41,24 @@ class TC_00_qvm_create(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_002_custom_template(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', + self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM', 'some-template', b'name=new-vm label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_create.main(['-l', 'red', '-t', 'some-template', 'new-vm'], app=self.app) self.assertAllCalled() def test_003_properties(self): - self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', + self.app.expected_calls[('dom0', 'admin.vm.Create.AppVM', None, b'name=new-vm label=red')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' - self.app.expected_calls[('new-vm', 'mgmt.vm.property.Set', + self.app.expected_calls[('new-vm', 'admin.vm.property.Set', 'netvm', b'sys-whonix')] = b'0\x00' qubesadmin.tools.qvm_create.main(['-l', 'red', '--prop', 'netvm=sys-whonix', 'new-vm'], @@ -66,11 +66,11 @@ class TC_00_qvm_create(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_004_pool(self): - self.app.expected_calls[('dom0', 'mgmt.vm.CreateInPool.AppVM', + self.app.expected_calls[('dom0', 'admin.vm.CreateInPool.AppVM', None, b'name=new-vm label=red pool=some-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_create.main(['-l', 'red', '-P', 'some-pool', 'new-vm'], @@ -78,12 +78,12 @@ class TC_00_qvm_create(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_005_pools(self): - self.app.expected_calls[('dom0', 'mgmt.vm.CreateInPool.AppVM', + self.app.expected_calls[('dom0', 'admin.vm.CreateInPool.AppVM', None, b'name=new-vm label=red pool:private=some-pool ' b'pool:volatile=other-pool')] = b'0\x00' - self.app.expected_calls[('dom0', 'mgmt.label.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblue\n' - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00new-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_create.main(['-l', 'red', '--pool', 'private=some-pool', '--pool', 'volatile=other-pool', 'new-vm'], diff --git a/qubesadmin/tests/tools/qvm_device.py b/qubesadmin/tests/tools/qvm_device.py index 54a895a..4d70ef3 100644 --- a/qubesadmin/tests/tools/qvm_device.py +++ b/qubesadmin/tests/tools/qvm_device.py @@ -34,11 +34,11 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): ''' Tests the output logic of the qvm-device tool ''' def setUp(self): super(TC_00_qvm_device, self).setUp() - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\0test-vm1 class=AppVM state=Running\n' \ b'test-vm2 class=AppVM state=Running\n' \ b'test-vm3 class=AppVM state=Running\n' - self.app.expected_calls[('test-vm1', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm1', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev1 description=Description here\n' self.vm1 = self.app.domains['test-vm1'] @@ -49,18 +49,18 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): ''' List all exposed vm devices. No devices are attached to other domains. ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev2 description=Description here2\n' - self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm3', 'admin.vm.device.test.Available', None, None)] = \ b'0\0' - self.app.expected_calls[('test-vm1', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm1', 'admin.vm.device.test.List', None, None)] = b'0\0' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.List', None, None)] = b'0\0' - self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm3', 'admin.vm.device.test.List', None, None)] = b'0\0' with qubesadmin.tests.tools.StdoutBuffer() as buf: @@ -75,17 +75,17 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): def test_001_list_persistent_attach(self): ''' Attach the device exposed by the `vm1` to the `vm3` persistently. ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev2 description=Description here2\n' - self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm3', 'admin.vm.device.test.Available', None, None)] = \ b'0\0' - self.app.expected_calls[('test-vm1', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm1', 'admin.vm.device.test.List', None, None)] = b'0\0' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.List', None, None)] = b'0\0' - self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm3', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm1+dev1 persistent=yes\n' @@ -101,18 +101,18 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): ''' Attach the device exposed by the `vm1` to the `vm3` non-persistently. ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Available', None, None)] = \ b'0\0dev2 description=Description here2\n' - self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.Available', + self.app.expected_calls[('test-vm3', 'admin.vm.device.test.Available', None, None)] = \ b'0\0' - self.app.expected_calls[('test-vm1', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm1', 'admin.vm.device.test.List', None, None)] = b'0\0' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.List', None, None)] = b'0\0' - self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.List', + self.app.expected_calls[('test-vm3', 'admin.vm.device.test.List', None, None)] = \ b'0\0test-vm1+dev1\n' @@ -126,7 +126,7 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): def test_010_attach(self): ''' Test attach action ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Attach', 'test-vm1+dev1', b'')] = b'0\0' qubesadmin.tools.qvm_device.main( ['test', 'attach', 'test-vm2', 'test-vm1:dev1'], app=self.app) @@ -134,7 +134,7 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): def test_011_attach_options(self): ''' Test attach action ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Attach', 'test-vm1+dev1', b'ro=True')] = b'0\0' qubesadmin.tools.qvm_device.main( ['test', 'attach', '-o', 'ro=True', 'test-vm2', 'test-vm1:dev1'], @@ -143,7 +143,7 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): def test_011_attach_persistent(self): ''' Test attach action ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Attach', 'test-vm1+dev1', b'persistent=yes')] = b'0\0' qubesadmin.tools.qvm_device.main( ['test', 'attach', '-p', 'test-vm2', 'test-vm1:dev1'], @@ -185,7 +185,7 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): def test_020_detach(self): ''' Test detach action ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Detach', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Detach', 'test-vm1+dev1', None)] = b'0\0' qubesadmin.tools.qvm_device.main( ['test', 'detach', 'test-vm2', 'test-vm1:dev1'], app=self.app) @@ -193,7 +193,7 @@ class TC_00_qvm_device(qubesadmin.tests.QubesTestCase): def test_021_detach_unknown(self): ''' Test detach action ''' - self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Detach', + self.app.expected_calls[('test-vm2', 'admin.vm.device.test.Detach', 'test-vm1+dev7', None)] = b'0\0' qubesadmin.tools.qvm_device.main( ['test', 'detach', 'test-vm2', 'test-vm1:dev7'], app=self.app) diff --git a/qubesadmin/tests/tools/qvm_features.py b/qubesadmin/tests/tools/qvm_features.py index 70ff92b..c725842 100644 --- a/qubesadmin/tests/tools/qvm_features.py +++ b/qubesadmin/tests/tools/qvm_features.py @@ -25,16 +25,16 @@ import qubesadmin.tools.qvm_features class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_000_list(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.feature.List', None, None)] = \ + ('some-vm', 'admin.vm.feature.List', None, None)] = \ b'0\x00feature1\nfeature2\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.feature.Get', 'feature1', None)] = \ + ('some-vm', 'admin.vm.feature.Get', 'feature1', None)] = \ b'0\x00value1' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.feature.Get', 'feature2', None)] = \ + ('some-vm', 'admin.vm.feature.Get', 'feature2', None)] = \ b'0\x00value2 with spaces' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -47,10 +47,10 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_001_set(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.feature.Set', + ('some-vm', 'admin.vm.feature.Set', 'feature3', 'value of feature')] = b'0\x00' self.assertEqual( qubesadmin.tools.qvm_features.main(['some-vm', 'feature3', @@ -61,10 +61,10 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_002_get(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.feature.Get', 'feature3', None)] = \ + ('some-vm', 'admin.vm.feature.Get', 'feature3', None)] = \ b'0\x00value2 with spaces' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -77,10 +77,10 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_003_del(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.feature.Remove', 'feature4', None)] = \ + ('some-vm', 'admin.vm.feature.Remove', 'feature4', None)] = \ b'0\x00' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -94,12 +94,12 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_004_running_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -112,15 +112,15 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_005_running_multi_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -134,18 +134,18 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_006_running_multi_verbose2(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm3', 'mgmt.vm.List', None, None)] = \ + ('some-vm3', 'admin.vm.List', None, None)] = \ b'0\x00some-vm3 class=AppVM state=Halted\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -159,12 +159,12 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_007_not_running_verbose(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Running\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm3', 'mgmt.vm.List', None, None)] = \ + ('some-vm3', 'admin.vm.List', None, None)] = \ b'0\x00some-vm3 class=AppVM state=Halted\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -178,12 +178,12 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_008_paused(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Paused\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -197,15 +197,15 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_009_paused_multi(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=AppVM state=Halted\n' self.app.expected_calls[ - ('some-vm2', 'mgmt.vm.List', None, None)] = \ + ('some-vm2', 'admin.vm.List', None, None)] = \ b'0\x00some-vm2 class=AppVM state=Paused\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.List', None, None)] = \ + ('some-vm', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual( @@ -220,7 +220,7 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_010_template(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=TemplateVM state=Halted\n' @@ -236,7 +236,7 @@ class TC_00_qvm_features(qubesadmin.tests.QubesTestCase): def test_011_template_multi(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'some-vm2 class=AppVM state=Paused\n' \ b'some-vm3 class=TemplateVM state=Halted\n' diff --git a/qubesadmin/tests/tools/qvm_firewall.py b/qubesadmin/tests/tools/qvm_firewall.py index 30353c1..d7b6803 100644 --- a/qubesadmin/tests/tools/qvm_firewall.py +++ b/qubesadmin/tests/tools/qvm_firewall.py @@ -70,11 +70,11 @@ class TC_00_RuleAction(qubesadmin.tests.QubesTestCase): class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): def setUp(self): super(TC_10_qvm_firewall, self).setUp() - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\0test-vm class=AppVM state=Halted\n' def test_000_list(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' @@ -91,7 +91,7 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ]) def test_001_list(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org proto=tcp ' \ b'dstports=443-443\n' \ @@ -112,7 +112,7 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ]) def test_002_list_raw(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' @@ -126,11 +126,11 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ]) def test_003_list_raw_reload(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Reload', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Reload', None, None)] = b'0\0' with qubesadmin.tests.tools.StdoutBuffer() as stdout: qubesadmin.tools.qvm_firewall.main( @@ -143,11 +143,11 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ]) def test_010_add_after(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None, + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Set', None, b'action=accept dsthost=qubes-os.org\n' b'action=drop proto=icmp\n' b'action=accept dst4=192.168.0.0/24 comment=Allow LAN\n')] = \ @@ -158,11 +158,11 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ) def test_011_add_before(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None, + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Set', None, b'action=accept dsthost=qubes-os.org\n' b'action=accept dst4=192.168.0.0/24 comment=Allow LAN\n' b'action=drop proto=icmp\n')] = b'0\0' @@ -173,11 +173,11 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ) def test_020_del_number(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None, + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Set', None, b'action=accept dsthost=qubes-os.org\n')] = b'0\0' qubesadmin.tools.qvm_firewall.main( ['test-vm', 'del', '--rule-no', '1'], @@ -185,11 +185,11 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ) def test_021_del_rule(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Get', None, None)] = \ b'0\0action=accept dsthost=qubes-os.org\n' \ b'action=drop proto=icmp\n' - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None, + self.app.expected_calls[('test-vm', 'admin.vm.firewall.Set', None, b'action=accept dsthost=qubes-os.org\n')] = b'0\0' qubesadmin.tools.qvm_firewall.main( ['test-vm', 'del', 'drop', 'proto=icmp'], @@ -197,7 +197,7 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): ) def test_030_policy_get(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.GetPolicy', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.GetPolicy', None, None)] = b'0\0accept' with qubesadmin.tests.tools.StdoutBuffer() as stdout: qubesadmin.tools.qvm_firewall.main( @@ -207,7 +207,7 @@ class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase): self.assertEqual(stdout.getvalue(), 'accept\n') def test_031_policy_set(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy', + self.app.expected_calls[('test-vm', 'admin.vm.firewall.SetPolicy', None, b'accept')] = b'0\0' with qubesadmin.tests.tools.StdoutBuffer() as stdout: qubesadmin.tools.qvm_firewall.main( diff --git a/qubesadmin/tests/tools/qvm_kill.py b/qubesadmin/tests/tools/qvm_kill.py index c7bd5d5..d9419e0 100644 --- a/qubesadmin/tests/tools/qvm_kill.py +++ b/qubesadmin/tests/tools/qvm_kill.py @@ -26,10 +26,10 @@ import qubesadmin.tools.qvm_kill class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase): def test_000_with_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Kill', None, None)] = b'0\x00' + ('some-vm', 'admin.vm.Kill', None, None)] = b'0\x00' qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app) self.assertAllCalled() @@ -43,7 +43,7 @@ class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase): def test_002_invalid_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -54,11 +54,11 @@ class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase): def test_003_not_running(self): # TODO: some option to ignore this error? self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Kill', None, None)] = \ + ('some-vm', 'admin.vm.Kill', None, None)] = \ b'2\x00QubesVMNotStartedError\x00\x00Domain is powered off: ' \ b'some-vm\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Halted\n' self.assertEqual( qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app), diff --git a/qubesadmin/tests/tools/qvm_ls.py b/qubesadmin/tests/tools/qvm_ls.py index 42a24da..79e029a 100644 --- a/qubesadmin/tests/tools/qvm_ls.py +++ b/qubesadmin/tests/tools/qvm_ls.py @@ -90,21 +90,21 @@ class TC_50_List(qubesadmin.tests.QubesTestCase): class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase): def test_100_list_with_status(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00vm1 class=AppVM state=Running\n' \ b'template1 class=TemplateVM state=Halted\n' \ b'sys-net class=AppVM state=Running\n' self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\nblack\ngreen\nblue\n' self.app.expected_calls[ - ('vm1', 'mgmt.vm.List', None, None)] = \ + ('vm1', 'admin.vm.List', None, None)] = \ b'0\x00vm1 class=AppVM state=Running\n' self.app.expected_calls[ - ('sys-net', 'mgmt.vm.List', None, None)] = \ + ('sys-net', 'admin.vm.List', None, None)] = \ b'0\x00sys-net class=AppVM state=Running\n' self.app.expected_calls[ - ('template1', 'mgmt.vm.List', None, None)] = \ + ('template1', 'admin.vm.List', None, None)] = \ b'0\x00template1 class=TemplateVM state=Halted\n' props = { 'label': b'type=label green', @@ -120,7 +120,7 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase): } for key, value in props.items(): self.app.expected_calls[ - ('vm1', 'mgmt.vm.property.Get', key, None)] = \ + ('vm1', 'admin.vm.property.Get', key, None)] = \ b'0\x00default=True ' + value # setup template1 @@ -128,10 +128,10 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase): props['updateable'] = b'type=bool True' for key, value in props.items(): self.app.expected_calls[ - ('template1', 'mgmt.vm.property.Get', key, None)] = \ + ('template1', 'admin.vm.property.Get', key, None)] = \ b'0\x00default=True ' + value self.app.expected_calls[ - ('template1', 'mgmt.vm.property.Get', 'template', None)] = \ + ('template1', 'admin.vm.property.Get', 'template', None)] = \ b'' # request refused - no such property # setup sys-net @@ -140,7 +140,7 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase): props['updateable'] = b'type=bool False' for key, value in props.items(): self.app.expected_calls[ - ('sys-net', 'mgmt.vm.property.Get', key, None)] = \ + ('sys-net', 'admin.vm.property.Get', key, None)] = \ b'0\x00default=True ' + value with qubesadmin.tests.tools.StdoutBuffer() as stdout: diff --git a/qubesadmin/tests/tools/qvm_pause.py b/qubesadmin/tests/tools/qvm_pause.py index 006a4fb..2e5ffb9 100644 --- a/qubesadmin/tests/tools/qvm_pause.py +++ b/qubesadmin/tests/tools/qvm_pause.py @@ -26,10 +26,10 @@ import qubesadmin.tools.qvm_pause class TC_00_qvm_pause(qubesadmin.tests.QubesTestCase): def test_000_with_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Pause', None, None)] = b'0\x00' + ('some-vm', 'admin.vm.Pause', None, None)] = b'0\x00' qubesadmin.tools.qvm_pause.main(['some-vm'], app=self.app) self.assertAllCalled() @@ -43,7 +43,7 @@ class TC_00_qvm_pause(qubesadmin.tests.QubesTestCase): def test_002_invalid_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -54,11 +54,11 @@ class TC_00_qvm_pause(qubesadmin.tests.QubesTestCase): def test_003_not_running(self): # TODO: some option to ignore this error? self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Pause', None, None)] = \ + ('some-vm', 'admin.vm.Pause', None, None)] = \ b'2\x00QubesVMNotStartedError\x00\x00Domain is powered off: ' \ b'some-vm\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Halted\n' self.assertEqual( qubesadmin.tools.qvm_pause.main(['some-vm'], app=self.app), @@ -67,13 +67,13 @@ class TC_00_qvm_pause(qubesadmin.tests.QubesTestCase): def test_004_multiple_vms(self): self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Pause', None, None)] = \ + ('some-vm', 'admin.vm.Pause', None, None)] = \ b'0\x00' self.app.expected_calls[ - ('other-vm', 'mgmt.vm.Pause', None, None)] = \ + ('other-vm', 'admin.vm.Pause', None, None)] = \ b'0\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'other-vm class=AppVM state=Running\n' self.assertEqual( diff --git a/qubesadmin/tests/tools/qvm_pool.py b/qubesadmin/tests/tools/qvm_pool.py index 4fc9291..2c993c5 100644 --- a/qubesadmin/tests/tools/qvm_pool.py +++ b/qubesadmin/tests/tools/qvm_pool.py @@ -25,13 +25,13 @@ import qubesadmin.tools.qvm_pool class TC_00_qvm_pool(qubesadmin.tests.QubesTestCase): def test_000_list(self): - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\npool-lvm\n' self.app.expected_calls[ - ('dom0', 'mgmt.pool.Info', 'pool-file', None)] = \ + ('dom0', 'admin.pool.Info', 'pool-file', None)] = \ b'0\x00driver=file\ndir_path=/var/lib/qubes\n' self.app.expected_calls[ - ('dom0', 'mgmt.pool.Info', 'pool-lvm', None)] = \ + ('dom0', 'admin.pool.Info', 'pool-lvm', None)] = \ b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual(0, @@ -44,7 +44,7 @@ class TC_00_qvm_pool(qubesadmin.tests.QubesTestCase): def test_010_list_drivers(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.ListDrivers', None, None)] = \ + ('dom0', 'admin.pool.ListDrivers', None, None)] = \ b'0\x00file dir_path revisions_to_keep\n' \ b'lvm volume_group thin_pool revisions_to_keep\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: @@ -59,7 +59,7 @@ class TC_00_qvm_pool(qubesadmin.tests.QubesTestCase): def test_020_add(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.Add', 'file', + ('dom0', 'admin.pool.Add', 'file', b'name=test-pool\ndir_path=/some/path\n')] = b'0\x00' self.assertEqual(0, qubesadmin.tools.qvm_pool.main( @@ -69,17 +69,17 @@ class TC_00_qvm_pool(qubesadmin.tests.QubesTestCase): def test_030_remove(self): self.app.expected_calls[ - ('dom0', 'mgmt.pool.Remove', 'test-pool', None)] = b'0\x00' + ('dom0', 'admin.pool.Remove', 'test-pool', None)] = b'0\x00' self.assertEqual(0, qubesadmin.tools.qvm_pool.main(['--remove', 'test-pool'], app=self.app)) self.assertAllCalled() def test_040_info(self): - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\npool-lvm\n' self.app.expected_calls[ - ('dom0', 'mgmt.pool.Info', 'pool-lvm', None)] = \ + ('dom0', 'admin.pool.Info', 'pool-lvm', None)] = \ b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual(0, diff --git a/qubesadmin/tests/tools/qvm_prefs.py b/qubesadmin/tests/tools/qvm_prefs.py index bcde372..f1f1665 100644 --- a/qubesadmin/tests/tools/qvm_prefs.py +++ b/qubesadmin/tests/tools/qvm_prefs.py @@ -27,16 +27,16 @@ import qubesadmin.tools.qvm_prefs class TC_00_qvm_prefs(qubesadmin.tests.QubesTestCase): def test_000_list(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00dom0 class=AdminVM state=Running\n' self.app.expected_calls[ - ('dom0', 'mgmt.vm.property.List', None, None)] = \ + ('dom0', 'admin.vm.property.List', None, None)] = \ b'0\x00prop1\nprop2\n' self.app.expected_calls[ - ('dom0', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('dom0', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=True type=str value1' self.app.expected_calls[ - ('dom0', 'mgmt.vm.property.Get', 'prop2', None)] = \ + ('dom0', 'admin.vm.property.Get', 'prop2', None)] = \ b'0\x00default=False type=str value2' with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual(0, qubesadmin.tools.qvm_prefs.main([ @@ -59,10 +59,10 @@ class TC_00_qvm_prefs(qubesadmin.tests.QubesTestCase): def test_002_set_property(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00dom0 class=AdminVM state=Running\n' self.app.expected_calls[ - ('dom0', 'mgmt.vm.property.Set', 'default_user', b'testuser')] = \ + ('dom0', 'admin.vm.property.Set', 'default_user', b'testuser')] = \ b'0\x00' self.assertEqual(0, qubesadmin.tools.qvm_prefs.main([ 'dom0', 'default_user', 'testuser'], app=self.app)) @@ -70,10 +70,10 @@ class TC_00_qvm_prefs(qubesadmin.tests.QubesTestCase): def test_003_invalid_property(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00dom0 class=AdminVM state=Running\n' self.app.expected_calls[ - ('dom0', 'mgmt.vm.property.Get', 'no_such_property', None)] = \ + ('dom0', 'admin.vm.property.Get', 'no_such_property', None)] = \ b'2\x00AttributeError\x00\x00no_such_property\x00' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -85,10 +85,10 @@ class TC_00_qvm_prefs(qubesadmin.tests.QubesTestCase): def test_004_set_invalid_property(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00dom0 class=AdminVM state=Running\n' self.app.expected_calls[ - ('dom0', 'mgmt.vm.property.Set', 'no_such_property', b'value')] = \ + ('dom0', 'admin.vm.property.Set', 'no_such_property', b'value')] = \ b'2\x00AttributeError\x00\x00no_such_property\x00' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: diff --git a/qubesadmin/tests/tools/qvm_remove.py b/qubesadmin/tests/tools/qvm_remove.py index 0e60416..5a6b58d 100644 --- a/qubesadmin/tests/tools/qvm_remove.py +++ b/qubesadmin/tests/tools/qvm_remove.py @@ -26,10 +26,10 @@ import qubesadmin.tools.qvm_remove class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase): def test_000_single(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Remove', None, None)] = \ + ('some-vm', 'admin.vm.Remove', None, None)] = \ b'0\x00\n' qubesadmin.tools.qvm_remove.main(['some-vm'], app=self.app) self.assertAllCalled() diff --git a/qubesadmin/tests/tools/qvm_run.py b/qubesadmin/tests/tools/qvm_run.py index f369461..cf2132e 100644 --- a/qubesadmin/tests/tools/qvm_run.py +++ b/qubesadmin/tests/tools/qvm_run.py @@ -36,10 +36,10 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): super(TC_00_qvm_run, self).setUp() def test_000_run_single(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' ret = qubesadmin.tools.qvm_run.main(['test-vm', 'command'], app=self.app) self.assertEqual(ret, 0) @@ -60,11 +60,11 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): def test_001_run_multiple(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' \ b'test-vm2 class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' ret = qubesadmin.tools.qvm_run.main(['test-vm', 'test-vm2', 'command'], app=self.app) @@ -99,10 +99,10 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): def test_002_passio(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE) with unittest.mock.patch('sys.stdin', echo.stdout): @@ -125,10 +125,10 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): def test_002_color_output(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' stdout = io.StringIO() echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE) @@ -155,10 +155,10 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): def test_003_no_color_output(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' stdout = io.StringIO() echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE) @@ -185,10 +185,10 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): def test_004_no_filter_esc(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' stdout = io.StringIO() echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE) @@ -215,10 +215,10 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase): def test_005_localcmd(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' # self.app.expected_calls[ - # ('test-vm', 'mgmt.vm.List', None, None)] = \ + # ('test-vm', 'admin.vm.List', None, None)] = \ # b'0\x00test-vm class=AppVM state=Running\n' ret = qubesadmin.tools.qvm_run.main( ['--pass-io', '--localcmd', 'local-command', diff --git a/qubesadmin/tests/tools/qvm_shutdown.py b/qubesadmin/tests/tools/qvm_shutdown.py index 272d9b7..6dff403 100644 --- a/qubesadmin/tests/tools/qvm_shutdown.py +++ b/qubesadmin/tests/tools/qvm_shutdown.py @@ -25,10 +25,10 @@ import qubesadmin.tools.qvm_shutdown class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase): def test_000_with_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Shutdown', None, None)] = b'0\x00' + ('some-vm', 'admin.vm.Shutdown', None, None)] = b'0\x00' qubesadmin.tools.qvm_shutdown.main(['some-vm'], app=self.app) self.assertAllCalled() @@ -42,7 +42,7 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase): def test_002_invalid_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -53,24 +53,24 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase): def test_003_not_running(self): # TODO: some option to ignore this error? self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Shutdown', None, None)] = \ + ('some-vm', 'admin.vm.Shutdown', None, None)] = \ b'2\x00QubesVMNotStartedError\x00\x00Domain is powered off: ' \ b'some-vm\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Halted\n' qubesadmin.tools.qvm_shutdown.main(['some-vm'], app=self.app) self.assertAllCalled() def test_004_multiple_vms(self): self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Shutdown', None, None)] = \ + ('some-vm', 'admin.vm.Shutdown', None, None)] = \ b'0\x00' self.app.expected_calls[ - ('other-vm', 'mgmt.vm.Shutdown', None, None)] = \ + ('other-vm', 'admin.vm.Shutdown', None, None)] = \ b'0\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'other-vm class=AppVM state=Running\n' qubesadmin.tools.qvm_shutdown.main(['some-vm', 'other-vm'], app=self.app), diff --git a/qubesadmin/tests/tools/qvm_start.py b/qubesadmin/tests/tools/qvm_start.py index 7b29e01..8587cd3 100644 --- a/qubesadmin/tests/tools/qvm_start.py +++ b/qubesadmin/tests/tools/qvm_start.py @@ -26,10 +26,10 @@ import qubesadmin.tools.qvm_start class TC_00_qvm_start(qubesadmin.tests.QubesTestCase): def test_000_with_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Start', None, None)] = b'0\x00' + ('some-vm', 'admin.vm.Start', None, None)] = b'0\x00' qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app) self.assertAllCalled() @@ -43,7 +43,7 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase): def test_002_invalid_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -54,11 +54,11 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase): def test_003_already_running(self): # TODO: some option to ignore this error? self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Start', None, None)] = \ + ('some-vm', 'admin.vm.Start', None, None)] = \ b'2\x00QubesVMNotHaltedError\x00\x00Domain is running: ' \ b'some-vm\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.assertEqual( qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app), diff --git a/qubesadmin/tests/tools/qvm_start_gui.py b/qubesadmin/tests/tools/qvm_start_gui.py index 3e83b74..9ae1ce3 100644 --- a/qubesadmin/tests/tools/qvm_start_gui.py +++ b/qubesadmin/tests/tools/qvm_start_gui.py @@ -35,13 +35,13 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): @unittest.mock.patch('subprocess.check_output') def test_000_kde_args(self, proc_mock): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'label', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'label', None)] = \ b'0\x00default=False type=label red' self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\n' proc_mock.side_effect = [ @@ -61,7 +61,7 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): @unittest.mock.patch('subprocess.check_output') def test_001_kde_args_none(self, proc_mock): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' proc_mock.side_effect = [b''] @@ -73,22 +73,22 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): def test_010_common_args(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'label', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'label', None)] = \ b'0\x00default=False type=label red' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'debug', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'debug', None)] = \ b'0\x00default=False type=bool False' self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\n' self.app.expected_calls[ - ('dom0', 'mgmt.label.Get', 'red', None)] = \ + ('dom0', 'admin.label.Get', 'red', None)] = \ b'0\x000xff0000' self.app.expected_calls[ - ('dom0', 'mgmt.label.Index', 'red', None)] = \ + ('dom0', 'admin.label.Index', 'red', None)] = \ b'0\x001' with unittest.mock.patch.object(self.launcher, 'kde_guid_args') as \ @@ -106,22 +106,22 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): def test_011_common_args_debug(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'label', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'label', None)] = \ b'0\x00default=False type=label red' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'debug', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'debug', None)] = \ b'0\x00default=False type=bool True' self.app.expected_calls[ - ('dom0', 'mgmt.label.List', None, None)] = \ + ('dom0', 'admin.label.List', None, None)] = \ b'0\x00red\n' self.app.expected_calls[ - ('dom0', 'mgmt.label.Get', 'red', None)] = \ + ('dom0', 'admin.label.Get', 'red', None)] = \ b'0\x000xff0000' self.app.expected_calls[ - ('dom0', 'mgmt.label.Index', 'red', None)] = \ + ('dom0', 'admin.label.Index', 'red', None)] = \ b'0\x001' with unittest.mock.patch.object(self.launcher, 'kde_guid_args') as \ @@ -140,13 +140,13 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): @unittest.mock.patch('asyncio.create_subprocess_exec') def test_020_start_gui_for_vm(self, proc_mock): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'xid', None)] = \ b'0\x00default=False type=int 3000' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'hvm', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'hvm', None)] = \ b'0\x00default=False type=bool False' with unittest.mock.patch.object(self.launcher, 'common_guid_args', lambda vm: []): @@ -159,22 +159,22 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): @unittest.mock.patch('asyncio.create_subprocess_exec') def test_021_start_gui_for_vm_hvm(self, proc_mock): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'xid', None)] = \ b'0\x00default=False type=int 3000' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'stubdom_xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'stubdom_xid', None)] = \ b'0\x00default=False type=int 3001' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'hvm', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'hvm', None)] = \ b'0\x00default=False type=bool True' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'debug', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'debug', None)] = \ b'0\x00default=False type=bool False' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.feature.CheckWithTemplate', 'rpc-clipboard', + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'rpc-clipboard', None)] = \ b'0\x00True' with unittest.mock.patch.object(self.launcher, @@ -187,22 +187,22 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): def test_022_start_gui_for_vm_hvm_stubdom(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'xid', None)] = \ b'0\x00default=False type=int 3000' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'stubdom_xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'stubdom_xid', None)] = \ b'0\x00default=False type=int 3001' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'hvm', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'hvm', None)] = \ b'0\x00default=False type=bool True' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'debug', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'debug', None)] = \ b'0\x00default=False type=bool False' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.feature.CheckWithTemplate', 'rpc-clipboard', + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'rpc-clipboard', None)] = \ b'0\x00True' pidfile = tempfile.NamedTemporaryFile() @@ -230,13 +230,13 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): def test_030_start_gui_for_stubdomain(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'xid', None)] = \ b'0\x00default=False type=int 3000' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'stubdom_xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'stubdom_xid', None)] = \ b'0\x00default=False type=int 3001' with unittest.mock.patch('asyncio.create_subprocess_exec') as proc_mock: with unittest.mock.patch.object(self.launcher, @@ -258,26 +258,26 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase): self.addCleanup(loop.close) self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.List', None, None)] = \ + ('test-vm', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.feature.CheckWithTemplate', 'gui', None)] = \ + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'gui', None)] = \ b'0\x00True' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.feature.CheckWithTemplate', + ('test-vm', 'admin.vm.feature.CheckWithTemplate', 'no-monitor-layout', None)] = \ b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'hvm', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'hvm', None)] = \ b'0\x00default=False type=bool True' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'xid', None)] = \ b'0\x00default=False type=int 3000' self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'stubdom_xid', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'stubdom_xid', None)] = \ b'0\x00default=False type=int 3001' vm = self.app.domains['test-vm'] diff --git a/qubesadmin/tests/tools/qvm_unpause.py b/qubesadmin/tests/tools/qvm_unpause.py index 6ac56e4..448064a 100644 --- a/qubesadmin/tests/tools/qvm_unpause.py +++ b/qubesadmin/tests/tools/qvm_unpause.py @@ -25,10 +25,10 @@ import qubesadmin.tools.qvm_unpause class TC_00_qvm_unpause(qubesadmin.tests.QubesTestCase): def test_000_with_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Unpause', None, None)] = b'0\x00' + ('some-vm', 'admin.vm.Unpause', None, None)] = b'0\x00' qubesadmin.tools.qvm_unpause.main(['some-vm'], app=self.app) self.assertAllCalled() @@ -42,7 +42,7 @@ class TC_00_qvm_unpause(qubesadmin.tests.QubesTestCase): def test_002_invalid_vm(self): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' with self.assertRaises(SystemExit): with qubesadmin.tests.tools.StderrBuffer() as stderr: @@ -53,11 +53,11 @@ class TC_00_qvm_unpause(qubesadmin.tests.QubesTestCase): def test_003_not_running(self): # TODO: some option to ignore this error? self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Unpause', None, None)] = \ + ('some-vm', 'admin.vm.Unpause', None, None)] = \ b'2\x00QubesVMNotStartedError\x00\x00Domain is powered off: ' \ b'some-vm\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Halted\n' self.assertEqual( qubesadmin.tools.qvm_unpause.main(['some-vm'], app=self.app), @@ -66,13 +66,13 @@ class TC_00_qvm_unpause(qubesadmin.tests.QubesTestCase): def test_004_multiple_vms(self): self.app.expected_calls[ - ('some-vm', 'mgmt.vm.Unpause', None, None)] = \ + ('some-vm', 'admin.vm.Unpause', None, None)] = \ b'0\x00' self.app.expected_calls[ - ('other-vm', 'mgmt.vm.Unpause', None, None)] = \ + ('other-vm', 'admin.vm.Unpause', None, None)] = \ b'0\x00' self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00some-vm class=AppVM state=Running\n' \ b'other-vm class=AppVM state=Running\n' self.assertEqual( diff --git a/qubesadmin/tests/tools/qvm_volume.py b/qubesadmin/tests/tools/qvm_volume.py index 0008536..8c8b183 100644 --- a/qubesadmin/tests/tools/qvm_volume.py +++ b/qubesadmin/tests/tools/qvm_volume.py @@ -27,13 +27,13 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): def setup_expected_calls_for_list(self, vms=('vm1', 'sys-net')): self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00vm1 class=AppVM state=Running\n' \ b'sys-net class=AppVM state=Running\n' for vm in vms: for vol in ('root', 'private'): self.app.expected_calls[ - (vm, 'mgmt.vm.volume.Info', vol, None)] = \ + (vm, 'admin.vm.volume.Info', vol, None)] = \ b'0\x00' + \ (b'pool=pool-file\n' if vol == 'root' else b'pool=other-pool\n') + \ @@ -41,10 +41,10 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): b'internal=True\n' \ b'size=10737418240\n' self.app.expected_calls[ - (vm, 'mgmt.vm.volume.ListSnapshots', vol, None)] = \ + (vm, 'admin.vm.volume.ListSnapshots', vol, None)] = \ b'0\x00snap1\n' if vol == 'private' else b'0\x00' self.app.expected_calls[ - (vm, 'mgmt.vm.volume.List', None, None)] = \ + (vm, 'admin.vm.volume.List', None, None)] = \ b'0\x00root\nprivate\n' def test_000_list(self): @@ -77,10 +77,10 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): def test_002_list_domain_pool(self): self.setup_expected_calls_for_list(vms=('vm1',)) - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\nother-pool\n' del self.app.expected_calls[ - ('vm1', 'mgmt.vm.volume.ListSnapshots', 'private', None)] + ('vm1', 'admin.vm.volume.ListSnapshots', 'private', None)] with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual(0, qubesadmin.tools.qvm_volume.main( @@ -94,12 +94,12 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): def test_003_list_pool(self): self.setup_expected_calls_for_list() - self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.pool.List', None, None)] = \ b'0\x00pool-file\nother-pool\n' del self.app.expected_calls[ - ('vm1', 'mgmt.vm.volume.ListSnapshots', 'private', None)] + ('vm1', 'admin.vm.volume.ListSnapshots', 'private', None)] del self.app.expected_calls[ - ('sys-net', 'mgmt.vm.volume.ListSnapshots', 'private', None)] + ('sys-net', 'admin.vm.volume.ListSnapshots', 'private', None)] with qubesadmin.tests.tools.StdoutBuffer() as stdout: self.assertEqual(0, @@ -116,7 +116,7 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): def test_004_list_multiple_domains(self): self.setup_expected_calls_for_list(vms=('vm1', 'vm2')) self.app.expected_calls[ - ('dom0', 'mgmt.vm.List', None, None)] = \ + ('dom0', 'admin.vm.List', None, None)] = \ b'0\x00vm1 class=AppVM state=Running\n' \ b'vm2 class=AppVM state=Running\n' \ b'vm3 class=AppVM state=Running\n' @@ -134,13 +134,13 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_010_extend(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00testvm class=AppVM state=Running\n' self.app.expected_calls[ - ('testvm', 'mgmt.vm.volume.List', None, None)] = \ + ('testvm', 'admin.vm.volume.List', None, None)] = \ b'0\x00root\nprivate\n' self.app.expected_calls[ - ('testvm', 'mgmt.vm.volume.Resize', 'private', b'10737418240')] = \ + ('testvm', 'admin.vm.volume.Resize', 'private', b'10737418240')] = \ b'0\x00' self.assertEqual(0, qubesadmin.tools.qvm_volume.main( @@ -149,13 +149,13 @@ class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase): self.assertAllCalled() def test_011_extend_error(self): - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00testvm class=AppVM state=Running\n' self.app.expected_calls[ - ('testvm', 'mgmt.vm.volume.List', None, None)] = \ + ('testvm', 'admin.vm.volume.List', None, None)] = \ b'0\x00root\nprivate\n' self.app.expected_calls[ - ('testvm', 'mgmt.vm.volume.Resize', 'private', b'1073741824')] = \ + ('testvm', 'admin.vm.volume.Resize', 'private', b'1073741824')] = \ b'2\x00StoragePoolException\x00\x00Failed to resize volume: ' \ b'shrink not allowed\x00' with qubesadmin.tests.tools.StderrBuffer() as stderr: diff --git a/qubesadmin/tests/vm/__init__.py b/qubesadmin/tests/vm/__init__.py index 94fc448..06e244c 100644 --- a/qubesadmin/tests/vm/__init__.py +++ b/qubesadmin/tests/vm/__init__.py @@ -24,6 +24,6 @@ import qubesadmin.tests class VMTestCase(qubesadmin.tests.QubesTestCase): def setUp(self): super(VMTestCase, self).setUp() - self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.vm = self.app.domains['test-vm'] diff --git a/qubesadmin/tests/vm/actions.py b/qubesadmin/tests/vm/actions.py index e7352de..be92c38 100644 --- a/qubesadmin/tests/vm/actions.py +++ b/qubesadmin/tests/vm/actions.py @@ -25,35 +25,35 @@ import qubesadmin.tests.vm class TC_00_Actions(qubesadmin.tests.vm.VMTestCase): def test_000_start(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Start', None, None)] = \ + ('test-vm', 'admin.vm.Start', None, None)] = \ b'0\x00' self.vm.start() self.assertAllCalled() def test_001_shutdown(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Shutdown', None, None)] = \ + ('test-vm', 'admin.vm.Shutdown', None, None)] = \ b'0\x00' self.vm.shutdown() self.assertAllCalled() def test_002_kill(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Kill', None, None)] = \ + ('test-vm', 'admin.vm.Kill', None, None)] = \ b'0\x00' self.vm.kill() self.assertAllCalled() def test_003_pause(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Pause', None, None)] = \ + ('test-vm', 'admin.vm.Pause', None, None)] = \ b'0\x00' self.vm.pause() self.assertAllCalled() def test_004_unpause(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Unpause', None, None)] = \ + ('test-vm', 'admin.vm.Unpause', None, None)] = \ b'0\x00' self.vm.unpause() self.assertAllCalled() @@ -61,7 +61,7 @@ class TC_00_Actions(qubesadmin.tests.vm.VMTestCase): @unittest.skip('Not part of the mgmt API yet') def test_005_suspend(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Suspend', None, None)] = \ + ('test-vm', 'admin.vm.Suspend', None, None)] = \ b'0\x00' self.vm.suspend() self.assertAllCalled() @@ -69,7 +69,7 @@ class TC_00_Actions(qubesadmin.tests.vm.VMTestCase): @unittest.skip('Not part of the mgmt API yet') def test_006_resume(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.Resume', None, None)] = \ + ('test-vm', 'admin.vm.Resume', None, None)] = \ b'0\x00' self.vm.resume() self.assertAllCalled() diff --git a/qubesadmin/tests/vm/properties.py b/qubesadmin/tests/vm/properties.py index b181f53..e698e69 100644 --- a/qubesadmin/tests/vm/properties.py +++ b/qubesadmin/tests/vm/properties.py @@ -25,7 +25,7 @@ class TC_00_Properties(qubesadmin.tests.vm.VMTestCase): def test_000_list(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.List', None, None)] = \ + ('test-vm', 'admin.vm.property.List', None, None)] = \ b'0\x00prop1\nprop2\n' self.assertEqual( self.vm.property_list(), @@ -34,28 +34,28 @@ class TC_00_Properties(qubesadmin.tests.vm.VMTestCase): def test_001_get_str(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=str value' self.assertEqual(self.vm.prop1, 'value') self.assertAllCalled() def test_002_get_int(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=int 123' self.assertEqual(self.vm.prop1, 123) self.assertAllCalled() def test_003_get_bool(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=bool True' self.assertEqual(self.vm.prop1, True) self.assertAllCalled() def test_004_get_vm(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=vm test-vm' self.assertIsInstance(self.vm.prop1, qubesadmin.vm.QubesVM) self.assertEqual(self.vm.prop1.name, 'test-vm') @@ -63,14 +63,14 @@ class TC_00_Properties(qubesadmin.tests.vm.VMTestCase): def test_005_get_none_vm(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=vm ' self.assertEqual(self.vm.prop1, None) self.assertAllCalled() def test_006_get_none_bool(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=bool ' with self.assertRaises(AttributeError): self.vm.prop1 @@ -78,7 +78,7 @@ class TC_00_Properties(qubesadmin.tests.vm.VMTestCase): def test_007_get_none_int(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=int ' with self.assertRaises(AttributeError): self.vm.prop1 @@ -86,70 +86,70 @@ class TC_00_Properties(qubesadmin.tests.vm.VMTestCase): def test_008_get_none_str(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=str ' self.assertEqual(self.vm.prop1, '') self.assertAllCalled() def test_010_get_default(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=False type=str value' self.assertEqual(self.vm.property_is_default('prop1'), False) self.assertAllCalled() def test_011_get_default(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Get', 'prop1', None)] = \ b'0\x00default=True type=str value' self.assertEqual(self.vm.property_is_default('prop1'), True) self.assertAllCalled() def test_020_set_str(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'prop1', b'value')] = \ + ('test-vm', 'admin.vm.property.Set', 'prop1', b'value')] = \ b'0\x00' self.vm.prop1 = 'value' self.assertAllCalled() def test_021_set_int(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'prop1', b'123')] = \ + ('test-vm', 'admin.vm.property.Set', 'prop1', b'123')] = \ b'0\x00' self.vm.prop1 = 123 self.assertAllCalled() def test_022_set_bool(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'prop1', b'True')] = \ + ('test-vm', 'admin.vm.property.Set', 'prop1', b'True')] = \ b'0\x00' self.vm.prop1 = True self.assertAllCalled() def test_023_set_vm(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'prop1', b'test-vm')] = \ + ('test-vm', 'admin.vm.property.Set', 'prop1', b'test-vm')] = \ b'0\x00' self.vm.prop1 = self.vm self.assertAllCalled() def test_024_set_none(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'prop1', b'None')] = \ + ('test-vm', 'admin.vm.property.Set', 'prop1', b'None')] = \ b'0\x00' self.vm.prop1 = None self.assertAllCalled() def test_030_reset(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Reset', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Reset', 'prop1', None)] = \ b'0\x00' self.vm.prop1 = qubesadmin.DEFAULT self.assertAllCalled() def test_031_reset(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Reset', 'prop1', None)] = \ + ('test-vm', 'admin.vm.property.Reset', 'prop1', None)] = \ b'0\x00' del self.vm.prop1 self.assertAllCalled() @@ -164,7 +164,7 @@ class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase): def test_001_set_name(self): # but this one should still do a call self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'name', b'test-vm2')] = \ + ('test-vm', 'admin.vm.property.Set', 'name', b'test-vm2')] = \ b'0\x00' self.vm.name = 'test-vm2' # here should be no separate mgmt.vm.property.Get+name call @@ -174,12 +174,12 @@ class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase): # check if VM list cache was cleared self.app.actual_calls = [] del self.app.expected_calls[ - ('test-vm', 'mgmt.vm.property.Set', 'name', b'test-vm2')] + ('test-vm', 'admin.vm.property.Set', 'name', b'test-vm2')] vm = self.app.domains['test-vm'] self.assertAllCalled() def test_010_power_state_running(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Running\n' self.assertEqual(self.vm.get_power_state(), 'Running') self.assertTrue(self.vm.is_running()) @@ -187,7 +187,7 @@ class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase): self.assertFalse(self.vm.is_paused()) def test_011_power_state_paused(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Paused\n' self.assertEqual(self.vm.get_power_state(), 'Paused') self.assertTrue(self.vm.is_running()) @@ -195,7 +195,7 @@ class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase): self.assertTrue(self.vm.is_paused()) def test_012_power_state_halted(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Halted\n' self.assertEqual(self.vm.get_power_state(), 'Halted') self.assertFalse(self.vm.is_running()) @@ -203,7 +203,7 @@ class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase): self.assertFalse(self.vm.is_paused()) def test_012_power_state_transient(self): - self.app.expected_calls[('test-vm', 'mgmt.vm.List', None, None)] = \ + self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \ b'0\x00test-vm class=AppVM state=Transient\n' self.assertEqual(self.vm.get_power_state(), 'Transient') self.assertTrue(self.vm.is_running()) diff --git a/qubesadmin/tests/vm/storage.py b/qubesadmin/tests/vm/storage.py index e93d0a7..33ac118 100644 --- a/qubesadmin/tests/vm/storage.py +++ b/qubesadmin/tests/vm/storage.py @@ -24,7 +24,7 @@ import qubesadmin.tests.vm class TestVMVolumes(qubesadmin.tests.vm.VMTestCase): def test_000_list_volumes(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.List', None, None)] = \ + ('test-vm', 'admin.vm.volume.List', None, None)] = \ b'0\x00root\nprivate\nvolatile\nmodules\n' self.assertEqual(set(self.vm.volumes.keys()), set(['root', 'private', 'volatile', 'modules'])) @@ -32,14 +32,14 @@ class TestVMVolumes(qubesadmin.tests.vm.VMTestCase): def test_001_volume_get(self): self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.List', None, None)] = \ + ('test-vm', 'admin.vm.volume.List', None, None)] = \ b'0\x00root\nprivate\nvolatile\nmodules\n' vol = self.vm.volumes['private'] self.assertEqual(vol._vm, 'test-vm') self.assertEqual(vol._vm_name, 'private') # add it here, to raise exception if was called earlier self.app.expected_calls[ - ('test-vm', 'mgmt.vm.volume.Info', 'private', None)] = \ + ('test-vm', 'admin.vm.volume.Info', 'private', None)] = \ b'0\x00pool=test-pool\nvid=some-id\n' self.assertEqual(vol.pool, 'test-pool') self.assertEqual(vol.vid, 'some-id') diff --git a/qubesadmin/vm/__init__.py b/qubesadmin/vm/__init__.py index 1d73bdd..02838a6 100644 --- a/qubesadmin/vm/__init__.py +++ b/qubesadmin/vm/__init__.py @@ -41,7 +41,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): firewall = None def __init__(self, app, name): - super(QubesVM, self).__init__(app, 'mgmt.vm.property.', name) + super(QubesVM, self).__init__(app, 'admin.vm.property.', name) self._volumes = None self.log = logging.getLogger(name) self.features = qubesadmin.features.Features(self) @@ -78,7 +78,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): :return: ''' - self.qubesd_call(self._method_dest, 'mgmt.vm.Start') + self.qubesd_call(self._method_dest, 'admin.vm.Start') def shutdown(self, force=False): ''' @@ -90,7 +90,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): # TODO: wait parameter (using event?) if force: raise NotImplementedError - self.qubesd_call(self._method_dest, 'mgmt.vm.Shutdown') + self.qubesd_call(self._method_dest, 'admin.vm.Shutdown') def kill(self): ''' @@ -98,7 +98,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): :return: ''' - self.qubesd_call(self._method_dest, 'mgmt.vm.Kill') + self.qubesd_call(self._method_dest, 'admin.vm.Kill') def pause(self): ''' @@ -108,7 +108,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): :return: ''' - self.qubesd_call(self._method_dest, 'mgmt.vm.Pause') + self.qubesd_call(self._method_dest, 'admin.vm.Pause') def unpause(self): ''' @@ -118,7 +118,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): :return: ''' - self.qubesd_call(self._method_dest, 'mgmt.vm.Unpause') + self.qubesd_call(self._method_dest, 'admin.vm.Unpause') def suspend(self): ''' @@ -130,7 +130,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): :return: ''' raise NotImplementedError - #self.qubesd_call(self._method_dest, 'mgmt.vm.Suspend') + #self.qubesd_call(self._method_dest, 'admin.vm.Suspend') def resume(self): ''' @@ -141,7 +141,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): :return: ''' raise NotImplementedError - #self.qubesd_call(self._method_dest, 'mgmt.vm.Resume') + #self.qubesd_call(self._method_dest, 'admin.vm.Resume') def get_power_state(self): '''Return power state description string. @@ -174,7 +174,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): ''' vm_list_info = self.qubesd_call( - self._method_dest, 'mgmt.vm.List', None, None).decode('ascii') + self._method_dest, 'admin.vm.List', None, None).decode('ascii') # name class=... state=... other=... vm_state = vm_list_info.strip().partition('state=')[2].split(' ')[0] return vm_state @@ -213,7 +213,7 @@ class QubesVM(qubesadmin.base.PropertyHolder): '''VM disk volumes''' if self._volumes is None: volumes_list = self.qubesd_call( - self._method_dest, 'mgmt.vm.volume.List') + self._method_dest, 'admin.vm.volume.List') self._volumes = {} for volname in volumes_list.decode('ascii').splitlines(): if not volname: