From 258d268a3aa22168d86e22397423b1bde9e318f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 12 May 2017 19:14:29 +0200 Subject: [PATCH] Rename MgmtAPI to AdminAPI - part 2: internal API QubesOS/qubes-issues#853 --- qubes/api/internal.py | 8 ++++---- qubespolicy/__init__.py | 10 +++++----- qubespolicy/tests/__init__.py | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/qubes/api/internal.py b/qubes/api/internal.py index cd063ea3..f400cdbe 100644 --- a/qubes/api/internal.py +++ b/qubes/api/internal.py @@ -39,7 +39,7 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI): # ACTUAL RPC CALLS # - @qubes.api.method('mgmtinternal.GetSystemInfo', no_payload=True) + @qubes.api.method('internal.GetSystemInfo', no_payload=True) @asyncio.coroutine def getsysteminfo(self): assert self.dest.name == 'dom0' @@ -58,14 +58,14 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI): return json.dumps(system_info) - @qubes.api.method('mgmtinternal.vm.Start', no_payload=True) + @qubes.api.method('internal.vm.Start', no_payload=True) @asyncio.coroutine def start(self): assert not self.arg yield from self.dest.start() - @qubes.api.method('mgmtinternal.vm.Create.DispVM', no_payload=True) + @qubes.api.method('internal.vm.Create.DispVM', no_payload=True) @asyncio.coroutine def create_dispvm(self): assert not self.arg @@ -74,7 +74,7 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI): dispvm = qubes.vm.dispvm.DispVM.from_appvm(self.dest) return dispvm.name - @qubes.api.method('mgmtinternal.vm.CleanupDispVM', no_payload=True) + @qubes.api.method('internal.vm.CleanupDispVM', no_payload=True) @asyncio.coroutine def cleanup_dispvm(self): assert not self.arg diff --git a/qubespolicy/__init__.py b/qubespolicy/__init__.py index e092f711..199f52cd 100755 --- a/qubespolicy/__init__.py +++ b/qubespolicy/__init__.py @@ -413,9 +413,9 @@ class PolicyAction(object): :return: name of new Disposable VM ''' base_appvm = self.target.split(':', 1)[1] - dispvm_name = qubesd_call(base_appvm, 'mgmtinternal.vm.Create.DispVM') + dispvm_name = qubesd_call(base_appvm, 'internal.vm.Create.DispVM') dispvm_name = dispvm_name.decode('ascii') - qubesd_call(dispvm_name, 'mgmtinternal.vm.Start') + qubesd_call(dispvm_name, 'internal.vm.Start') return dispvm_name def ensure_target_running(self): @@ -425,7 +425,7 @@ class PolicyAction(object): :return: None ''' try: - qubesd_call(self.target, 'mgmtinternal.vm.Start') + qubesd_call(self.target, 'internal.vm.Start') except QubesMgmtException as e: if e.exc_type == 'QubesVMNotHaltedError': pass @@ -440,7 +440,7 @@ class PolicyAction(object): :param dispvm: name of Disposable VM :return: None ''' - qubesd_call(dispvm, 'mgmtinternal.vm.CleanupDispVM') + qubesd_call(dispvm, 'internal.vm.CleanupDispVM') class Policy(object): @@ -642,5 +642,5 @@ def get_system_info(): ''' - system_info = qubesd_call('dom0', 'mgmtinternal.GetSystemInfo') + system_info = qubesd_call('dom0', 'internal.GetSystemInfo') return json.loads(system_info.decode('utf-8')) diff --git a/qubespolicy/tests/__init__.py b/qubespolicy/tests/__init__.py index 9cca2726..f82d149d 100644 --- a/qubespolicy/tests/__init__.py +++ b/qubespolicy/tests/__init__.py @@ -414,7 +414,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase): 'test-vm2', rule, 'test-vm2') action.execute('some-ident') self.assertEqual(mock_qubesd_call.mock_calls, - [unittest.mock.call('test-vm2', 'mgmtinternal.vm.Start')]) + [unittest.mock.call('test-vm2', 'internal.vm.Start')]) self.assertEqual(mock_subprocess.mock_calls, [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'test-vm2', '-c', 'some-ident', 'DEFAULT:QUBESRPC test.service test-vm1'])]) @@ -427,7 +427,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase): 'dom0', rule, 'dom0') action.execute('some-ident') self.assertEqual(mock_qubesd_call.mock_calls, - [unittest.mock.call('dom0', 'mgmtinternal.vm.Start')]) + [unittest.mock.call('dom0', 'internal.vm.Start')]) self.assertEqual(mock_subprocess.mock_calls, [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'dom0', '-c', 'some-ident', @@ -441,14 +441,14 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase): action = qubespolicy.PolicyAction('test.service', 'test-vm1', '$dispvm:default-dvm', rule, '$dispvm:default-dvm') mock_qubesd_call.side_effect = (lambda target, call: - b'dispvm-name' if call == 'mgmtinternal.vm.Create.DispVM' else + b'dispvm-name' if call == 'internal.vm.Create.DispVM' else unittest.mock.DEFAULT) action.execute('some-ident') self.assertEqual(mock_qubesd_call.mock_calls, - [unittest.mock.call('default-dvm', 'mgmtinternal.vm.Create.DispVM'), - unittest.mock.call('dispvm-name', 'mgmtinternal.vm.Start'), + [unittest.mock.call('default-dvm', 'internal.vm.Create.DispVM'), + unittest.mock.call('dispvm-name', 'internal.vm.Start'), unittest.mock.call('dispvm-name', - 'mgmtinternal.vm.CleanupDispVM')]) + 'internal.vm.CleanupDispVM')]) self.assertEqual(mock_subprocess.mock_calls, [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'dispvm-name', '-c', 'some-ident', '-W', @@ -465,7 +465,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase): qubespolicy.QubesMgmtException('QubesVMNotHaltedError') action.execute('some-ident') self.assertEqual(mock_qubesd_call.mock_calls, - [unittest.mock.call('test-vm2', 'mgmtinternal.vm.Start')]) + [unittest.mock.call('test-vm2', 'internal.vm.Start')]) self.assertEqual(mock_subprocess.mock_calls, [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'test-vm2', '-c', 'some-ident', 'DEFAULT:QUBESRPC test.service test-vm1'])]) @@ -482,7 +482,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase): with self.assertRaises(qubespolicy.QubesMgmtException): action.execute('some-ident') self.assertEqual(mock_qubesd_call.mock_calls, - [unittest.mock.call('test-vm2', 'mgmtinternal.vm.Start')]) + [unittest.mock.call('test-vm2', 'internal.vm.Start')]) self.assertEqual(mock_subprocess.mock_calls, []) @unittest.mock.patch('qubespolicy.POLICY_DIR', tmp_policy_dir)