Rename MgmtAPI to AdminAPI - part 2: internal API

QubesOS/qubes-issues#853
This commit is contained in:
Marek Marczykowski-Górecki 2017-05-12 19:14:29 +02:00
parent cd489f46e1
commit 258d268a3a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 17 additions and 17 deletions

View File

@ -39,7 +39,7 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI):
# ACTUAL RPC CALLS # ACTUAL RPC CALLS
# #
@qubes.api.method('mgmtinternal.GetSystemInfo', no_payload=True) @qubes.api.method('internal.GetSystemInfo', no_payload=True)
@asyncio.coroutine @asyncio.coroutine
def getsysteminfo(self): def getsysteminfo(self):
assert self.dest.name == 'dom0' assert self.dest.name == 'dom0'
@ -58,14 +58,14 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI):
return json.dumps(system_info) 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 @asyncio.coroutine
def start(self): def start(self):
assert not self.arg assert not self.arg
yield from self.dest.start() 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 @asyncio.coroutine
def create_dispvm(self): def create_dispvm(self):
assert not self.arg assert not self.arg
@ -74,7 +74,7 @@ class QubesInternalAPI(qubes.api.AbstractQubesAPI):
dispvm = qubes.vm.dispvm.DispVM.from_appvm(self.dest) dispvm = qubes.vm.dispvm.DispVM.from_appvm(self.dest)
return dispvm.name return dispvm.name
@qubes.api.method('mgmtinternal.vm.CleanupDispVM', no_payload=True) @qubes.api.method('internal.vm.CleanupDispVM', no_payload=True)
@asyncio.coroutine @asyncio.coroutine
def cleanup_dispvm(self): def cleanup_dispvm(self):
assert not self.arg assert not self.arg

View File

@ -413,9 +413,9 @@ class PolicyAction(object):
:return: name of new Disposable VM :return: name of new Disposable VM
''' '''
base_appvm = self.target.split(':', 1)[1] 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') dispvm_name = dispvm_name.decode('ascii')
qubesd_call(dispvm_name, 'mgmtinternal.vm.Start') qubesd_call(dispvm_name, 'internal.vm.Start')
return dispvm_name return dispvm_name
def ensure_target_running(self): def ensure_target_running(self):
@ -425,7 +425,7 @@ class PolicyAction(object):
:return: None :return: None
''' '''
try: try:
qubesd_call(self.target, 'mgmtinternal.vm.Start') qubesd_call(self.target, 'internal.vm.Start')
except QubesMgmtException as e: except QubesMgmtException as e:
if e.exc_type == 'QubesVMNotHaltedError': if e.exc_type == 'QubesVMNotHaltedError':
pass pass
@ -440,7 +440,7 @@ class PolicyAction(object):
:param dispvm: name of Disposable VM :param dispvm: name of Disposable VM
:return: None :return: None
''' '''
qubesd_call(dispvm, 'mgmtinternal.vm.CleanupDispVM') qubesd_call(dispvm, 'internal.vm.CleanupDispVM')
class Policy(object): 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')) return json.loads(system_info.decode('utf-8'))

View File

@ -414,7 +414,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase):
'test-vm2', rule, 'test-vm2') 'test-vm2', rule, 'test-vm2')
action.execute('some-ident') action.execute('some-ident')
self.assertEqual(mock_qubesd_call.mock_calls, 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, self.assertEqual(mock_subprocess.mock_calls,
[unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'test-vm2', [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'test-vm2',
'-c', 'some-ident', 'DEFAULT:QUBESRPC test.service test-vm1'])]) '-c', 'some-ident', 'DEFAULT:QUBESRPC test.service test-vm1'])])
@ -427,7 +427,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase):
'dom0', rule, 'dom0') 'dom0', rule, 'dom0')
action.execute('some-ident') action.execute('some-ident')
self.assertEqual(mock_qubesd_call.mock_calls, 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, self.assertEqual(mock_subprocess.mock_calls,
[unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'dom0', [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'dom0',
'-c', 'some-ident', '-c', 'some-ident',
@ -441,14 +441,14 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase):
action = qubespolicy.PolicyAction('test.service', 'test-vm1', action = qubespolicy.PolicyAction('test.service', 'test-vm1',
'$dispvm:default-dvm', rule, '$dispvm:default-dvm') '$dispvm:default-dvm', rule, '$dispvm:default-dvm')
mock_qubesd_call.side_effect = (lambda target, call: 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) unittest.mock.DEFAULT)
action.execute('some-ident') action.execute('some-ident')
self.assertEqual(mock_qubesd_call.mock_calls, self.assertEqual(mock_qubesd_call.mock_calls,
[unittest.mock.call('default-dvm', 'mgmtinternal.vm.Create.DispVM'), [unittest.mock.call('default-dvm', 'internal.vm.Create.DispVM'),
unittest.mock.call('dispvm-name', 'mgmtinternal.vm.Start'), unittest.mock.call('dispvm-name', 'internal.vm.Start'),
unittest.mock.call('dispvm-name', unittest.mock.call('dispvm-name',
'mgmtinternal.vm.CleanupDispVM')]) 'internal.vm.CleanupDispVM')])
self.assertEqual(mock_subprocess.mock_calls, self.assertEqual(mock_subprocess.mock_calls,
[unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'dispvm-name', [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'dispvm-name',
'-c', 'some-ident', '-W', '-c', 'some-ident', '-W',
@ -465,7 +465,7 @@ class TC_10_PolicyAction(qubes.tests.QubesTestCase):
qubespolicy.QubesMgmtException('QubesVMNotHaltedError') qubespolicy.QubesMgmtException('QubesVMNotHaltedError')
action.execute('some-ident') action.execute('some-ident')
self.assertEqual(mock_qubesd_call.mock_calls, 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, self.assertEqual(mock_subprocess.mock_calls,
[unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'test-vm2', [unittest.mock.call([qubespolicy.QREXEC_CLIENT, '-d', 'test-vm2',
'-c', 'some-ident', 'DEFAULT:QUBESRPC test.service test-vm1'])]) '-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): with self.assertRaises(qubespolicy.QubesMgmtException):
action.execute('some-ident') action.execute('some-ident')
self.assertEqual(mock_qubesd_call.mock_calls, 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, []) self.assertEqual(mock_subprocess.mock_calls, [])
@unittest.mock.patch('qubespolicy.POLICY_DIR', tmp_policy_dir) @unittest.mock.patch('qubespolicy.POLICY_DIR', tmp_policy_dir)