瀏覽代碼

Rename MgmtAPI to AdminAPI - part 2: internal API

QubesOS/qubes-issues#853
Marek Marczykowski-Górecki 7 年之前
父節點
當前提交
258d268a3a
共有 3 個文件被更改,包括 17 次插入17 次删除
  1. 4 4
      qubes/api/internal.py
  2. 5 5
      qubespolicy/__init__.py
  3. 8 8
      qubespolicy/tests/__init__.py

+ 4 - 4
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

+ 5 - 5
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'))

+ 8 - 8
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)