parent
78c28a70e9
commit
4ceff0f8c0
@ -10,7 +10,7 @@ install:
|
|||||||
- git clone https://github.com/"${TRAVIS_REPO_SLUG%%/*}"/qubes-builder ~/qubes-builder
|
- git clone https://github.com/"${TRAVIS_REPO_SLUG%%/*}"/qubes-builder ~/qubes-builder
|
||||||
script:
|
script:
|
||||||
- test -z "$TESTS_ONLY" || python setup.py build
|
- test -z "$TESTS_ONLY" || python setup.py build
|
||||||
- test -z "$TESTS_ONLY" || { cd build/lib; PYTHONPATH=../../test-packages pylint --rcfile=../../ci/pylintrc qubesmgmt; }
|
- test -z "$TESTS_ONLY" || { cd build/lib; PYTHONPATH=../../test-packages pylint --rcfile=../../ci/pylintrc qubesadmin; }
|
||||||
- test -z "$TESTS_ONLY" || { cd build/lib; ROOTDIR=../.. ../../run-tests; }
|
- test -z "$TESTS_ONLY" || { cd build/lib; ROOTDIR=../.. ../../run-tests; }
|
||||||
- test -n "$TESTS_ONLY" || ~/qubes-builder/scripts/travis-build
|
- test -n "$TESTS_ONLY" || ~/qubes-builder/scripts/travis-build
|
||||||
env:
|
env:
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
|
|
||||||
RPM_SPEC_FILES := rpm_spec/qubes-core-mgmt-client.spec
|
RPM_SPEC_FILES := rpm_spec/qubes-core-admin-client.spec
|
||||||
|
@ -9,6 +9,6 @@ Compatibility
|
|||||||
Most of the API modules are compatible with Python >= 2.7.
|
Most of the API modules are compatible with Python >= 2.7.
|
||||||
Very few parts require Python >= 3.4:
|
Very few parts require Python >= 3.4:
|
||||||
- tools (`qvm-*`)
|
- tools (`qvm-*`)
|
||||||
- qubesmgmt.events module (for asyncio module)
|
- qubesadmin.events module (for asyncio module)
|
||||||
|
|
||||||
Parts not compatible with Python < 3.4, are not installed in such environment.
|
Parts not compatible with Python < 3.4, are not installed in such environment.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[run]
|
[run]
|
||||||
source = qubesmgmt
|
source = qubesadmin
|
||||||
omit = qubesmgmt/tests/*
|
omit = qubesadmin/tests/*
|
||||||
|
@ -41,8 +41,8 @@ extensions = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import qubesmgmt.tools.dochelpers
|
import qubesadmin.tools.dochelpers
|
||||||
extensions.append('qubesmgmt.tools.dochelpers')
|
extensions.append('qubesadmin.tools.dochelpers')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -5,16 +5,16 @@ import sys
|
|||||||
sys.path.insert(0, os.path.abspath('../'))
|
sys.path.insert(0, os.path.abspath('../'))
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import qubesmgmt.dochelpers
|
import qubesadmin.dochelpers
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='prepare new manpage for command')
|
parser = argparse.ArgumentParser(description='prepare new manpage for command')
|
||||||
parser.add_argument('command', metavar='COMMAND',
|
parser.add_argument('command', metavar='COMMAND',
|
||||||
help='program\'s command name; this should translate to '
|
help='program\'s command name; this should translate to '
|
||||||
'qubesmgmt.tools.<command_name>')
|
'qubesadmin.tools.<command_name>')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
sys.stdout.write(qubesmgmt.dochelpers.prepare_manpage(args.command))
|
sys.stdout.write(qubesadmin.dochelpers.prepare_manpage(args.command))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import qubesmgmt.config
|
import qubesadmin.config
|
||||||
import qubesmgmt.base
|
import qubesadmin.base
|
||||||
import qubesmgmt.app
|
import qubesadmin.app
|
||||||
|
|
||||||
DEFAULT = qubesmgmt.base.DEFAULT
|
DEFAULT = qubesadmin.base.DEFAULT
|
||||||
|
|
||||||
if os.path.exists(qubesmgmt.config.QUBESD_SOCKET):
|
if os.path.exists(qubesadmin.config.QUBESD_SOCKET):
|
||||||
Qubes = qubesmgmt.app.QubesLocal
|
Qubes = qubesadmin.app.QubesLocal
|
||||||
else:
|
else:
|
||||||
Qubes = qubesmgmt.app.QubesRemote
|
Qubes = qubesadmin.app.QubesRemote
|
@ -28,16 +28,16 @@ import subprocess
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import qubesmgmt.base
|
import qubesadmin.base
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.label
|
import qubesadmin.label
|
||||||
import qubesmgmt.storage
|
import qubesadmin.storage
|
||||||
import qubesmgmt.utils
|
import qubesadmin.utils
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
import qubesmgmt.config
|
import qubesadmin.config
|
||||||
|
|
||||||
BUF_SIZE = 4096
|
BUF_SIZE = 4096
|
||||||
VM_ENTRY_POINT = 'qubesmgmt.vm'
|
VM_ENTRY_POINT = 'qubesadmin.vm'
|
||||||
|
|
||||||
class VMCollection(object):
|
class VMCollection(object):
|
||||||
'''Collection of VMs objects'''
|
'''Collection of VMs objects'''
|
||||||
@ -85,7 +85,7 @@ class VMCollection(object):
|
|||||||
if item not in self:
|
if item not in self:
|
||||||
raise KeyError(item)
|
raise KeyError(item)
|
||||||
if item not in self._vm_objects:
|
if item not in self._vm_objects:
|
||||||
cls = qubesmgmt.utils.get_entry_point_one(VM_ENTRY_POINT,
|
cls = qubesadmin.utils.get_entry_point_one(VM_ENTRY_POINT,
|
||||||
self._vm_list[item]['class'])
|
self._vm_list[item]['class'])
|
||||||
self._vm_objects[item] = cls(self.app, item)
|
self._vm_objects[item] = cls(self.app, item)
|
||||||
return self._vm_objects[item]
|
return self._vm_objects[item]
|
||||||
@ -109,7 +109,7 @@ class VMCollection(object):
|
|||||||
return self._vm_list.keys()
|
return self._vm_list.keys()
|
||||||
|
|
||||||
|
|
||||||
class QubesBase(qubesmgmt.base.PropertyHolder):
|
class QubesBase(qubesadmin.base.PropertyHolder):
|
||||||
'''Main Qubes application'''
|
'''Main Qubes application'''
|
||||||
|
|
||||||
#: domains (VMs) collection
|
#: domains (VMs) collection
|
||||||
@ -126,10 +126,10 @@ class QubesBase(qubesmgmt.base.PropertyHolder):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(QubesBase, self).__init__(self, 'mgmt.property.', 'dom0')
|
super(QubesBase, self).__init__(self, 'mgmt.property.', 'dom0')
|
||||||
self.domains = VMCollection(self)
|
self.domains = VMCollection(self)
|
||||||
self.labels = qubesmgmt.base.WrapperObjectsCollection(
|
self.labels = qubesadmin.base.WrapperObjectsCollection(
|
||||||
self, 'mgmt.label.List', qubesmgmt.label.Label)
|
self, 'mgmt.label.List', qubesadmin.label.Label)
|
||||||
self.pools = qubesmgmt.base.WrapperObjectsCollection(
|
self.pools = qubesadmin.base.WrapperObjectsCollection(
|
||||||
self, 'mgmt.pool.List', qubesmgmt.storage.Pool)
|
self, 'mgmt.pool.List', qubesadmin.storage.Pool)
|
||||||
#: cache for available storage pool drivers and options to create them
|
#: cache for available storage pool drivers and options to create them
|
||||||
self._pool_drivers = None
|
self._pool_drivers = None
|
||||||
self.log = logging.getLogger('app')
|
self.log = logging.getLogger('app')
|
||||||
@ -215,10 +215,10 @@ class QubesBase(qubesmgmt.base.PropertyHolder):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return qubesmgmt.utils.get_entry_point_one(
|
return qubesadmin.utils.get_entry_point_one(
|
||||||
VM_ENTRY_POINT, clsname)
|
VM_ENTRY_POINT, clsname)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise qubesmgmt.exc.QubesException(
|
raise qubesadmin.exc.QubesException(
|
||||||
'no such VM class: {!r}'.format(clsname))
|
'no such VM class: {!r}'.format(clsname))
|
||||||
# don't catch TypeError
|
# don't catch TypeError
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ class QubesBase(qubesmgmt.base.PropertyHolder):
|
|||||||
|
|
||||||
Example usage with custom storage pools:
|
Example usage with custom storage pools:
|
||||||
|
|
||||||
>>> app = qubesmgmt.Qubes()
|
>>> app = qubesadmin.Qubes()
|
||||||
>>> pools = {'private': 'external'}
|
>>> pools = {'private': 'external'}
|
||||||
>>> vm = app.add_new_vm('AppVM', 'my-new-vm', 'red',
|
>>> vm = app.add_new_vm('AppVM', 'my-new-vm', 'red',
|
||||||
>>> 'my-template', pools=pools)
|
>>> 'my-template', pools=pools)
|
||||||
@ -273,7 +273,7 @@ class QubesBase(qubesmgmt.base.PropertyHolder):
|
|||||||
|
|
||||||
Example usage with custom storage pools:
|
Example usage with custom storage pools:
|
||||||
|
|
||||||
>>> app = qubesmgmt.Qubes()
|
>>> app = qubesadmin.Qubes()
|
||||||
>>> pools = {'private': 'external'}
|
>>> pools = {'private': 'external'}
|
||||||
>>> src_vm = app.domains['personal']
|
>>> src_vm = app.domains['personal']
|
||||||
>>> vm = app.clone_vm(src_vm, 'my-new-vm', pools=pools)
|
>>> vm = app.clone_vm(src_vm, 'my-new-vm', pools=pools)
|
||||||
@ -338,7 +338,7 @@ class QubesLocal(QubesBase):
|
|||||||
def qubesd_call(self, dest, method, arg=None, payload=None):
|
def qubesd_call(self, dest, method, arg=None, payload=None):
|
||||||
try:
|
try:
|
||||||
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
client_socket.connect(qubesmgmt.config.QUBESD_SOCKET)
|
client_socket.connect(qubesadmin.config.QUBESD_SOCKET)
|
||||||
except IOError:
|
except IOError:
|
||||||
# TODO:
|
# TODO:
|
||||||
raise
|
raise
|
||||||
@ -375,7 +375,7 @@ class QubesLocal(QubesBase):
|
|||||||
raise ValueError('Empty destination name allowed only from a VM')
|
raise ValueError('Empty destination name allowed only from a VM')
|
||||||
try:
|
try:
|
||||||
self.qubesd_call(dest, 'mgmt.vm.Start')
|
self.qubesd_call(dest, 'mgmt.vm.Start')
|
||||||
except qubesmgmt.exc.QubesVMNotHaltedError:
|
except qubesadmin.exc.QubesVMNotHaltedError:
|
||||||
pass
|
pass
|
||||||
qrexec_opts = ['-d', dest]
|
qrexec_opts = ['-d', dest]
|
||||||
if filter_esc:
|
if filter_esc:
|
||||||
@ -387,7 +387,7 @@ class QubesLocal(QubesBase):
|
|||||||
kwargs.setdefault('stdin', subprocess.PIPE)
|
kwargs.setdefault('stdin', subprocess.PIPE)
|
||||||
kwargs.setdefault('stdout', subprocess.PIPE)
|
kwargs.setdefault('stdout', subprocess.PIPE)
|
||||||
kwargs.setdefault('stderr', subprocess.PIPE)
|
kwargs.setdefault('stderr', subprocess.PIPE)
|
||||||
proc = subprocess.Popen([qubesmgmt.config.QREXEC_CLIENT] +
|
proc = subprocess.Popen([qubesadmin.config.QREXEC_CLIENT] +
|
||||||
qrexec_opts + ['{}:QUBESRPC {} dom0'.format(user, service)],
|
qrexec_opts + ['{}:QUBESRPC {} dom0'.format(user, service)],
|
||||||
**kwargs)
|
**kwargs)
|
||||||
return proc
|
return proc
|
||||||
@ -405,14 +405,14 @@ class QubesRemote(QubesBase):
|
|||||||
service_name = method
|
service_name = method
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
service_name += '+' + arg
|
service_name += '+' + arg
|
||||||
p = subprocess.Popen([qubesmgmt.config.QREXEC_CLIENT_VM,
|
p = subprocess.Popen([qubesadmin.config.QREXEC_CLIENT_VM,
|
||||||
dest, service_name],
|
dest, service_name],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
(stdout, stderr) = p.communicate(payload)
|
(stdout, stderr) = p.communicate(payload)
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
# TODO: use dedicated exception
|
# TODO: use dedicated exception
|
||||||
raise qubesmgmt.exc.QubesException('Service call error: %s',
|
raise qubesadmin.exc.QubesException('Service call error: %s',
|
||||||
stderr.decode())
|
stderr.decode())
|
||||||
|
|
||||||
return self._parse_qubesd_response(stdout)
|
return self._parse_qubesd_response(stdout)
|
||||||
@ -439,7 +439,7 @@ class QubesRemote(QubesBase):
|
|||||||
kwargs.setdefault('stdin', subprocess.PIPE)
|
kwargs.setdefault('stdin', subprocess.PIPE)
|
||||||
kwargs.setdefault('stdout', subprocess.PIPE)
|
kwargs.setdefault('stdout', subprocess.PIPE)
|
||||||
kwargs.setdefault('stderr', subprocess.PIPE)
|
kwargs.setdefault('stderr', subprocess.PIPE)
|
||||||
proc = subprocess.Popen([qubesmgmt.config.QREXEC_CLIENT_VM,
|
proc = subprocess.Popen([qubesadmin.config.QREXEC_CLIENT_VM,
|
||||||
dest or '', service] + (shlex.split(localcmd) if localcmd else []),
|
dest or '', service] + (shlex.split(localcmd) if localcmd else []),
|
||||||
**kwargs)
|
**kwargs)
|
||||||
return proc
|
return proc
|
@ -21,7 +21,7 @@
|
|||||||
'''Base classes for managed objects'''
|
'''Base classes for managed objects'''
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
DEFAULT = object()
|
DEFAULT = object()
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ class PropertyHolder(object):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
if response_data == b'':
|
if response_data == b'':
|
||||||
raise qubesmgmt.exc.QubesDaemonNoResponseError(
|
raise qubesadmin.exc.QubesDaemonNoResponseError(
|
||||||
'Got empty response from qubesd')
|
'Got empty response from qubesd')
|
||||||
|
|
||||||
if response_data[0:2] == b'\x30\x00':
|
if response_data[0:2] == b'\x30\x00':
|
||||||
@ -86,17 +86,17 @@ class PropertyHolder(object):
|
|||||||
format_string = format_string.decode('utf-8')
|
format_string = format_string.decode('utf-8')
|
||||||
exc_type = exc_type.decode('ascii')
|
exc_type = exc_type.decode('ascii')
|
||||||
try:
|
try:
|
||||||
exc_class = getattr(qubesmgmt.exc, exc_type)
|
exc_class = getattr(qubesadmin.exc, exc_type)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
if exc_type.endswith('Error'):
|
if exc_type.endswith('Error'):
|
||||||
exc_class = __builtins__.get(exc_type,
|
exc_class = __builtins__.get(exc_type,
|
||||||
qubesmgmt.exc.QubesException)
|
qubesadmin.exc.QubesException)
|
||||||
else:
|
else:
|
||||||
exc_class = qubesmgmt.exc.QubesException
|
exc_class = qubesadmin.exc.QubesException
|
||||||
# TODO: handle traceback if given
|
# TODO: handle traceback if given
|
||||||
raise exc_class(format_string, *args)
|
raise exc_class(format_string, *args)
|
||||||
else:
|
else:
|
||||||
raise qubesmgmt.exc.QubesDaemonCommunicationError(
|
raise qubesadmin.exc.QubesDaemonCommunicationError(
|
||||||
'Invalid response format')
|
'Invalid response format')
|
||||||
|
|
||||||
def property_list(self):
|
def property_list(self):
|
||||||
@ -159,12 +159,12 @@ class PropertyHolder(object):
|
|||||||
self._method_prefix + 'Get',
|
self._method_prefix + 'Get',
|
||||||
item,
|
item,
|
||||||
None)
|
None)
|
||||||
except qubesmgmt.exc.QubesDaemonNoResponseError:
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
raise qubesmgmt.exc.QubesPropertyAccessError(item)
|
raise qubesadmin.exc.QubesPropertyAccessError(item)
|
||||||
(_default, prop_type, value) = property_str.split(b' ', 2)
|
(_default, prop_type, value) = property_str.split(b' ', 2)
|
||||||
prop_type = prop_type.decode('ascii')
|
prop_type = prop_type.decode('ascii')
|
||||||
if not prop_type.startswith('type='):
|
if not prop_type.startswith('type='):
|
||||||
raise qubesmgmt.exc.QubesDaemonCommunicationError(
|
raise qubesadmin.exc.QubesDaemonCommunicationError(
|
||||||
'Invalid type prefix received: {}'.format(prop_type))
|
'Invalid type prefix received: {}'.format(prop_type))
|
||||||
(_, prop_type) = prop_type.split('=', 1)
|
(_, prop_type) = prop_type.split('=', 1)
|
||||||
value = value.decode()
|
value = value.decode()
|
||||||
@ -188,23 +188,23 @@ class PropertyHolder(object):
|
|||||||
# TODO
|
# TODO
|
||||||
return self.app.labels[value]
|
return self.app.labels[value]
|
||||||
else:
|
else:
|
||||||
raise qubesmgmt.exc.QubesDaemonCommunicationError(
|
raise qubesadmin.exc.QubesDaemonCommunicationError(
|
||||||
'Received invalid value type: {}'.format(prop_type))
|
'Received invalid value type: {}'.format(prop_type))
|
||||||
|
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
if key.startswith('_') or key in dir(self):
|
if key.startswith('_') or key in dir(self):
|
||||||
return super(PropertyHolder, self).__setattr__(key, value)
|
return super(PropertyHolder, self).__setattr__(key, value)
|
||||||
if value is qubesmgmt.DEFAULT:
|
if value is qubesadmin.DEFAULT:
|
||||||
try:
|
try:
|
||||||
self.qubesd_call(
|
self.qubesd_call(
|
||||||
self._method_dest,
|
self._method_dest,
|
||||||
self._method_prefix + 'Reset',
|
self._method_prefix + 'Reset',
|
||||||
key,
|
key,
|
||||||
None)
|
None)
|
||||||
except qubesmgmt.exc.QubesDaemonNoResponseError:
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
raise qubesmgmt.exc.QubesPropertyAccessError(key)
|
raise qubesadmin.exc.QubesPropertyAccessError(key)
|
||||||
else:
|
else:
|
||||||
if isinstance(value, qubesmgmt.vm.QubesVM):
|
if isinstance(value, qubesadmin.vm.QubesVM):
|
||||||
value = value.name
|
value = value.name
|
||||||
try:
|
try:
|
||||||
self.qubesd_call(
|
self.qubesd_call(
|
||||||
@ -212,8 +212,8 @@ class PropertyHolder(object):
|
|||||||
self._method_prefix + 'Set',
|
self._method_prefix + 'Set',
|
||||||
key,
|
key,
|
||||||
str(value).encode('utf-8'))
|
str(value).encode('utf-8'))
|
||||||
except qubesmgmt.exc.QubesDaemonNoResponseError:
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
raise qubesmgmt.exc.QubesPropertyAccessError(key)
|
raise qubesadmin.exc.QubesPropertyAccessError(key)
|
||||||
|
|
||||||
def __delattr__(self, name):
|
def __delattr__(self, name):
|
||||||
if name.startswith('_') or name in dir(self):
|
if name.startswith('_') or name in dir(self):
|
||||||
@ -224,8 +224,8 @@ class PropertyHolder(object):
|
|||||||
self._method_prefix + 'Reset',
|
self._method_prefix + 'Reset',
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
except qubesmgmt.exc.QubesDaemonNoResponseError:
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
raise qubesmgmt.exc.QubesPropertyAccessError(name)
|
raise qubesadmin.exc.QubesPropertyAccessError(name)
|
||||||
|
|
||||||
|
|
||||||
class WrapperObjectsCollection(object):
|
class WrapperObjectsCollection(object):
|
@ -23,8 +23,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import qubesmgmt.config
|
import qubesadmin.config
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
|
|
||||||
class EventsDispatcher(object):
|
class EventsDispatcher(object):
|
||||||
@ -75,7 +75,7 @@ class EventsDispatcher(object):
|
|||||||
|
|
||||||
if self.app.qubesd_connection_type == 'socket':
|
if self.app.qubesd_connection_type == 'socket':
|
||||||
reader, writer = yield from asyncio.open_unix_connection(
|
reader, writer = yield from asyncio.open_unix_connection(
|
||||||
qubesmgmt.config.QUBESD_SOCKET)
|
qubesadmin.config.QUBESD_SOCKET)
|
||||||
writer.write(b'dom0\0') # source
|
writer.write(b'dom0\0') # source
|
||||||
writer.write(b'mgmt.Events\0') # method
|
writer.write(b'mgmt.Events\0') # method
|
||||||
writer.write(dest.encode('ascii') + b'\0') # dest
|
writer.write(dest.encode('ascii') + b'\0') # dest
|
||||||
@ -124,9 +124,9 @@ class EventsDispatcher(object):
|
|||||||
break
|
break
|
||||||
self.app.log.warning(
|
self.app.log.warning(
|
||||||
'Connection to qubesd terminated, reconnecting in {} '
|
'Connection to qubesd terminated, reconnecting in {} '
|
||||||
'seconds'.format(qubesmgmt.config.QUBESD_RECONNECT_DELAY))
|
'seconds'.format(qubesadmin.config.QUBESD_RECONNECT_DELAY))
|
||||||
# avoid busy-loop if qubesd is dead
|
# avoid busy-loop if qubesd is dead
|
||||||
yield from asyncio.sleep(qubesmgmt.config.QUBESD_RECONNECT_DELAY)
|
yield from asyncio.sleep(qubesadmin.config.QUBESD_RECONNECT_DELAY)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _listen_for_events(self, vm=None):
|
def _listen_for_events(self, vm=None):
|
||||||
@ -159,7 +159,7 @@ class EventsDispatcher(object):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
if not event_data.startswith(b'1\0'):
|
if not event_data.startswith(b'1\0'):
|
||||||
raise qubesmgmt.exc.QubesDaemonCommunicationError(
|
raise qubesadmin.exc.QubesDaemonCommunicationError(
|
||||||
'Non-event received on events connection: '
|
'Non-event received on events connection: '
|
||||||
+ repr(event_data))
|
+ repr(event_data))
|
||||||
event_data = event_data.decode('utf-8')
|
event_data = event_data.decode('utf-8')
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
'''VM Labels'''
|
'''VM Labels'''
|
||||||
|
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
|
|
||||||
class Label(object):
|
class Label(object):
|
||||||
@ -45,7 +45,7 @@ class Label(object):
|
|||||||
try:
|
try:
|
||||||
qubesd_response = self.app.qubesd_call(
|
qubesd_response = self.app.qubesd_call(
|
||||||
'dom0', 'mgmt.label.Get', self._name, None)
|
'dom0', 'mgmt.label.Get', self._name, None)
|
||||||
except qubesmgmt.exc.QubesDaemonNoResponseError:
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
self._color = qubesd_response.decode()
|
self._color = qubesd_response.decode()
|
||||||
return self._color
|
return self._color
|
||||||
@ -68,7 +68,7 @@ class Label(object):
|
|||||||
try:
|
try:
|
||||||
qubesd_response = self.app.qubesd_call(
|
qubesd_response = self.app.qubesd_call(
|
||||||
'dom0', 'mgmt.label.Index', self._name, None)
|
'dom0', 'mgmt.label.Index', self._name, None)
|
||||||
except qubesmgmt.exc.QubesDaemonNoResponseError:
|
except qubesadmin.exc.QubesDaemonNoResponseError:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
self._index = int(qubesd_response.decode())
|
self._index = int(qubesd_response.decode())
|
||||||
return self._index
|
return self._index
|
@ -22,8 +22,8 @@ import unittest
|
|||||||
|
|
||||||
import io
|
import io
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.app
|
import qubesadmin.app
|
||||||
|
|
||||||
|
|
||||||
class TestVM(object):
|
class TestVM(object):
|
||||||
@ -107,7 +107,7 @@ class _AssertNotRaisesContext(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class QubesTest(qubesmgmt.app.QubesBase):
|
class QubesTest(qubesadmin.app.QubesBase):
|
||||||
expected_calls = None
|
expected_calls = None
|
||||||
actual_calls = None
|
actual_calls = None
|
||||||
service_calls = None
|
service_calls = None
|
@ -31,10 +31,10 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
|
|
||||||
|
|
||||||
class TC_00_VMCollection(qubesmgmt.tests.QubesTestCase):
|
class TC_00_VMCollection(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00test-vm class=AppVM state=Running\n'
|
b'0\x00test-vm class=AppVM state=Running\n'
|
||||||
@ -79,7 +79,7 @@ class TC_00_VMCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
|
|
||||||
class TC_10_QubesBase(qubesmgmt.tests.QubesTestCase):
|
class TC_10_QubesBase(qubesadmin.tests.QubesTestCase):
|
||||||
def test_010_new_simple(self):
|
def test_010_new_simple(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', None,
|
self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', None,
|
||||||
b'name=new-vm label=red')] = b'0\x00'
|
b'name=new-vm label=red')] = b'0\x00'
|
||||||
@ -200,10 +200,10 @@ class TC_20_QubesLocal(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_20_QubesLocal, self).setUp()
|
super(TC_20_QubesLocal, self).setUp()
|
||||||
self.socket_dir = tempfile.mkdtemp()
|
self.socket_dir = tempfile.mkdtemp()
|
||||||
self.orig_sock = qubesmgmt.config.QUBESD_SOCKET
|
self.orig_sock = qubesadmin.config.QUBESD_SOCKET
|
||||||
qubesmgmt.config.QUBESD_SOCKET = os.path.join(self.socket_dir, 'sock')
|
qubesadmin.config.QUBESD_SOCKET = os.path.join(self.socket_dir, 'sock')
|
||||||
self.proc = None
|
self.proc = None
|
||||||
self.app = qubesmgmt.app.QubesLocal()
|
self.app = qubesadmin.app.QubesLocal()
|
||||||
|
|
||||||
def listen_and_send(self, send_data):
|
def listen_and_send(self, send_data):
|
||||||
'''Listen on socket and send data in response.
|
'''Listen on socket and send data in response.
|
||||||
@ -230,7 +230,7 @@ class TC_20_QubesLocal(unittest.TestCase):
|
|||||||
return self.socket_pipe.recv()
|
return self.socket_pipe.recv()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
qubesmgmt.config.QUBESD_SOCKET = self.orig_sock
|
qubesadmin.config.QUBESD_SOCKET = self.orig_sock
|
||||||
if self.proc is not None:
|
if self.proc is not None:
|
||||||
try:
|
try:
|
||||||
self.proc.terminate()
|
self.proc.terminate()
|
||||||
@ -262,7 +262,7 @@ class TC_20_QubesLocal(unittest.TestCase):
|
|||||||
with mock.patch('subprocess.Popen') as mock_proc:
|
with mock.patch('subprocess.Popen') as mock_proc:
|
||||||
p = self.app.run_service('some-vm', 'service.name')
|
p = self.app.run_service('some-vm', 'service.name')
|
||||||
mock_proc.assert_called_once_with([
|
mock_proc.assert_called_once_with([
|
||||||
qubesmgmt.config.QREXEC_CLIENT,
|
qubesadmin.config.QREXEC_CLIENT,
|
||||||
'-d', 'some-vm', 'DEFAULT:QUBESRPC service.name dom0'],
|
'-d', 'some-vm', 'DEFAULT:QUBESRPC service.name dom0'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
@ -275,7 +275,7 @@ class TC_20_QubesLocal(unittest.TestCase):
|
|||||||
with mock.patch('subprocess.Popen') as mock_proc:
|
with mock.patch('subprocess.Popen') as mock_proc:
|
||||||
p = self.app.run_service('some-vm', 'service.name', filter_esc=True)
|
p = self.app.run_service('some-vm', 'service.name', filter_esc=True)
|
||||||
mock_proc.assert_called_once_with([
|
mock_proc.assert_called_once_with([
|
||||||
qubesmgmt.config.QREXEC_CLIENT,
|
qubesadmin.config.QREXEC_CLIENT,
|
||||||
'-d', 'some-vm', '-t', '-T',
|
'-d', 'some-vm', '-t', '-T',
|
||||||
'DEFAULT:QUBESRPC service.name dom0'],
|
'DEFAULT:QUBESRPC service.name dom0'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
@ -289,7 +289,7 @@ class TC_20_QubesLocal(unittest.TestCase):
|
|||||||
with mock.patch('subprocess.Popen') as mock_proc:
|
with mock.patch('subprocess.Popen') as mock_proc:
|
||||||
p = self.app.run_service('some-vm', 'service.name', user='user')
|
p = self.app.run_service('some-vm', 'service.name', user='user')
|
||||||
mock_proc.assert_called_once_with([
|
mock_proc.assert_called_once_with([
|
||||||
qubesmgmt.config.QREXEC_CLIENT,
|
qubesadmin.config.QREXEC_CLIENT,
|
||||||
'-d', 'some-vm',
|
'-d', 'some-vm',
|
||||||
'user:QUBESRPC service.name dom0'],
|
'user:QUBESRPC service.name dom0'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
@ -312,7 +312,7 @@ class TC_30_QubesRemote(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
self.proc_patch = mock.patch('subprocess.Popen', self.proc_mock)
|
self.proc_patch = mock.patch('subprocess.Popen', self.proc_mock)
|
||||||
self.proc_patch.start()
|
self.proc_patch.start()
|
||||||
self.app = qubesmgmt.app.QubesRemote()
|
self.app = qubesadmin.app.QubesRemote()
|
||||||
|
|
||||||
def set_proc_stdout(self, send_data):
|
def set_proc_stdout(self, send_data):
|
||||||
self.proc_mock.configure_mock(**{
|
self.proc_mock.configure_mock(**{
|
||||||
@ -327,7 +327,7 @@ class TC_30_QubesRemote(unittest.TestCase):
|
|||||||
self.set_proc_stdout(b'0\0')
|
self.set_proc_stdout(b'0\0')
|
||||||
self.app.qubesd_call('test-vm', 'some.method', 'arg1', b'payload')
|
self.app.qubesd_call('test-vm', 'some.method', 'arg1', b'payload')
|
||||||
self.assertEqual(self.proc_mock.mock_calls, [
|
self.assertEqual(self.proc_mock.mock_calls, [
|
||||||
mock.call([qubesmgmt.config.QREXEC_CLIENT_VM, 'test-vm',
|
mock.call([qubesadmin.config.QREXEC_CLIENT_VM, 'test-vm',
|
||||||
'some.method+arg1'],
|
'some.method+arg1'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE),
|
stderr=subprocess.PIPE),
|
||||||
@ -338,7 +338,7 @@ class TC_30_QubesRemote(unittest.TestCase):
|
|||||||
self.set_proc_stdout(b'0\0')
|
self.set_proc_stdout(b'0\0')
|
||||||
self.app.qubesd_call('test-vm', 'some.method', None, b'payload')
|
self.app.qubesd_call('test-vm', 'some.method', None, b'payload')
|
||||||
self.assertEqual(self.proc_mock.mock_calls, [
|
self.assertEqual(self.proc_mock.mock_calls, [
|
||||||
mock.call([qubesmgmt.config.QREXEC_CLIENT_VM, 'test-vm',
|
mock.call([qubesadmin.config.QREXEC_CLIENT_VM, 'test-vm',
|
||||||
'some.method'],
|
'some.method'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE),
|
stderr=subprocess.PIPE),
|
||||||
@ -349,7 +349,7 @@ class TC_30_QubesRemote(unittest.TestCase):
|
|||||||
self.set_proc_stdout(b'0\0')
|
self.set_proc_stdout(b'0\0')
|
||||||
self.app.qubesd_call('test-vm', 'some.method', None, None)
|
self.app.qubesd_call('test-vm', 'some.method', None, None)
|
||||||
self.assertEqual(self.proc_mock.mock_calls, [
|
self.assertEqual(self.proc_mock.mock_calls, [
|
||||||
mock.call([qubesmgmt.config.QREXEC_CLIENT_VM, 'test-vm',
|
mock.call([qubesadmin.config.QREXEC_CLIENT_VM, 'test-vm',
|
||||||
'some.method'],
|
'some.method'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE),
|
stderr=subprocess.PIPE),
|
||||||
@ -359,7 +359,7 @@ class TC_30_QubesRemote(unittest.TestCase):
|
|||||||
def test_010_run_service(self):
|
def test_010_run_service(self):
|
||||||
self.app.run_service('some-vm', 'service.name')
|
self.app.run_service('some-vm', 'service.name')
|
||||||
self.proc_mock.assert_called_once_with([
|
self.proc_mock.assert_called_once_with([
|
||||||
qubesmgmt.config.QREXEC_CLIENT_VM,
|
qubesadmin.config.QREXEC_CLIENT_VM,
|
||||||
'some-vm', 'service.name'],
|
'some-vm', 'service.name'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
@ -375,7 +375,7 @@ class TC_30_QubesRemote(unittest.TestCase):
|
|||||||
def test_013_run_service_default_target(self):
|
def test_013_run_service_default_target(self):
|
||||||
self.app.run_service('', 'service.name')
|
self.app.run_service('', 'service.name')
|
||||||
self.proc_mock.assert_called_once_with([
|
self.proc_mock.assert_called_once_with([
|
||||||
qubesmgmt.config.QREXEC_CLIENT_VM,
|
qubesadmin.config.QREXEC_CLIENT_VM,
|
||||||
'', 'service.name'],
|
'', 'service.name'],
|
||||||
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
@ -18,11 +18,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.devices
|
import qubesadmin.devices
|
||||||
|
|
||||||
|
|
||||||
class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
class TC_00_DeviceCollection(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_00_DeviceCollection, self).setUp()
|
super(TC_00_DeviceCollection, self).setUp()
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -38,7 +38,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
devices = list(self.vm.devices['test'].available())
|
devices = list(self.vm.devices['test'].available())
|
||||||
self.assertEqual(len(devices), 1)
|
self.assertEqual(len(devices), 1)
|
||||||
dev = devices[0]
|
dev = devices[0]
|
||||||
self.assertIsInstance(dev, qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(dev, qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(dev.backend_domain, self.vm)
|
self.assertEqual(dev.backend_domain, self.vm)
|
||||||
self.assertEqual(dev.ident, 'dev1')
|
self.assertEqual(dev.ident, 'dev1')
|
||||||
self.assertEqual(dev.description, '')
|
self.assertEqual(dev.description, '')
|
||||||
@ -54,7 +54,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
devices = list(self.vm.devices['test'].available())
|
devices = list(self.vm.devices['test'].available())
|
||||||
self.assertEqual(len(devices), 1)
|
self.assertEqual(len(devices), 1)
|
||||||
dev = devices[0]
|
dev = devices[0]
|
||||||
self.assertIsInstance(dev, qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(dev, qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(dev.backend_domain, self.vm)
|
self.assertEqual(dev.backend_domain, self.vm)
|
||||||
self.assertEqual(dev.ident, 'dev1')
|
self.assertEqual(dev.ident, 'dev1')
|
||||||
self.assertEqual(dev.description, 'This is description')
|
self.assertEqual(dev.description, 'This is description')
|
||||||
@ -69,7 +69,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
devices = list(self.vm.devices['test'].available())
|
devices = list(self.vm.devices['test'].available())
|
||||||
self.assertEqual(len(devices), 1)
|
self.assertEqual(len(devices), 1)
|
||||||
dev = devices[0]
|
dev = devices[0]
|
||||||
self.assertIsInstance(dev, qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(dev, qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(dev.backend_domain, self.vm)
|
self.assertEqual(dev.backend_domain, self.vm)
|
||||||
self.assertEqual(dev.ident, 'dev1')
|
self.assertEqual(dev.ident, 'dev1')
|
||||||
self.assertEqual(dev.description, 'This is description')
|
self.assertEqual(dev.description, 'This is description')
|
||||||
@ -83,7 +83,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \
|
('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \
|
||||||
b'0\0dev1 description=This is description\n'
|
b'0\0dev1 description=This is description\n'
|
||||||
dev = self.vm.devices['test']['dev1']
|
dev = self.vm.devices['test']['dev1']
|
||||||
self.assertIsInstance(dev, qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(dev, qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(dev.backend_domain, self.vm)
|
self.assertEqual(dev.backend_domain, self.vm)
|
||||||
self.assertEqual(dev.ident, 'dev1')
|
self.assertEqual(dev.ident, 'dev1')
|
||||||
self.assertEqual(dev.description, 'This is description')
|
self.assertEqual(dev.description, 'This is description')
|
||||||
@ -97,7 +97,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \
|
('test-vm', 'mgmt.vm.device.test.Available', None, None)] = \
|
||||||
b'0\0dev1 description=This is description\n'
|
b'0\0dev1 description=This is description\n'
|
||||||
dev = self.vm.devices['test']['dev2']
|
dev = self.vm.devices['test']['dev2']
|
||||||
self.assertIsInstance(dev, qubesmgmt.devices.UnknownDevice)
|
self.assertIsInstance(dev, qubesadmin.devices.UnknownDevice)
|
||||||
self.assertEqual(dev.backend_domain, self.vm)
|
self.assertEqual(dev.backend_domain, self.vm)
|
||||||
self.assertEqual(dev.ident, 'dev2')
|
self.assertEqual(dev.ident, 'dev2')
|
||||||
self.assertEqual(dev.description, 'Unknown device')
|
self.assertEqual(dev.description, 'Unknown device')
|
||||||
@ -110,7 +110,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1', b'')] = \
|
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1', b'')] = \
|
||||||
b'0\0'
|
b'0\0'
|
||||||
assign = qubesmgmt.devices.DeviceAssignment(
|
assign = qubesadmin.devices.DeviceAssignment(
|
||||||
self.app.domains['test-vm2'], 'dev1')
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
self.vm.devices['test'].attach(assign)
|
self.vm.devices['test'].attach(assign)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -119,7 +119,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1',
|
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1',
|
||||||
b'ro=True something=value')] = b'0\0'
|
b'ro=True something=value')] = b'0\0'
|
||||||
assign = qubesmgmt.devices.DeviceAssignment(
|
assign = qubesadmin.devices.DeviceAssignment(
|
||||||
self.app.domains['test-vm2'], 'dev1')
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
assign.options['ro'] = True
|
assign.options['ro'] = True
|
||||||
assign.options['something'] = 'value'
|
assign.options['something'] = 'value'
|
||||||
@ -130,7 +130,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1',
|
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1',
|
||||||
b'persistent=yes')] = b'0\0'
|
b'persistent=yes')] = b'0\0'
|
||||||
assign = qubesmgmt.devices.DeviceAssignment(
|
assign = qubesadmin.devices.DeviceAssignment(
|
||||||
self.app.domains['test-vm2'], 'dev1')
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
assign.persistent = True
|
assign.persistent = True
|
||||||
self.vm.devices['test'].attach(assign)
|
self.vm.devices['test'].attach(assign)
|
||||||
@ -140,7 +140,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1',
|
('test-vm', 'mgmt.vm.device.test.Attach', 'test-vm2+dev1',
|
||||||
b'persistent=yes ro=True')] = b'0\0'
|
b'persistent=yes ro=True')] = b'0\0'
|
||||||
assign = qubesmgmt.devices.DeviceAssignment(
|
assign = qubesadmin.devices.DeviceAssignment(
|
||||||
self.app.domains['test-vm2'], 'dev1')
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
assign.persistent = True
|
assign.persistent = True
|
||||||
assign.options['ro'] = True
|
assign.options['ro'] = True
|
||||||
@ -151,7 +151,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.device.test.Detach', 'test-vm2+dev1',
|
('test-vm', 'mgmt.vm.device.test.Detach', 'test-vm2+dev1',
|
||||||
None)] = b'0\0'
|
None)] = b'0\0'
|
||||||
assign = qubesmgmt.devices.DeviceAssignment(
|
assign = qubesadmin.devices.DeviceAssignment(
|
||||||
self.app.domains['test-vm2'], 'dev1')
|
self.app.domains['test-vm2'], 'dev1')
|
||||||
self.vm.devices['test'].detach(assign)
|
self.vm.devices['test'].detach(assign)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -163,7 +163,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'test-vm3+dev2\n'
|
b'test-vm3+dev2\n'
|
||||||
assigns = list(self.vm.devices['test'].assignments())
|
assigns = list(self.vm.devices['test'].assignments())
|
||||||
self.assertEqual(len(assigns), 2)
|
self.assertEqual(len(assigns), 2)
|
||||||
self.assertIsInstance(assigns[0], qubesmgmt.devices.DeviceAssignment)
|
self.assertIsInstance(assigns[0], qubesadmin.devices.DeviceAssignment)
|
||||||
self.assertEqual(assigns[0].backend_domain,
|
self.assertEqual(assigns[0].backend_domain,
|
||||||
self.app.domains['test-vm2'])
|
self.app.domains['test-vm2'])
|
||||||
self.assertEqual(assigns[0].ident, 'dev1')
|
self.assertEqual(assigns[0].ident, 'dev1')
|
||||||
@ -171,7 +171,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.domains['test-vm'])
|
self.app.domains['test-vm'])
|
||||||
self.assertEqual(assigns[0].options, {})
|
self.assertEqual(assigns[0].options, {})
|
||||||
|
|
||||||
self.assertIsInstance(assigns[1], qubesmgmt.devices.DeviceAssignment)
|
self.assertIsInstance(assigns[1], qubesadmin.devices.DeviceAssignment)
|
||||||
self.assertEqual(assigns[1].backend_domain,
|
self.assertEqual(assigns[1].backend_domain,
|
||||||
self.app.domains['test-vm3'])
|
self.app.domains['test-vm3'])
|
||||||
self.assertEqual(assigns[1].ident, 'dev2')
|
self.assertEqual(assigns[1].ident, 'dev2')
|
||||||
@ -188,7 +188,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'test-vm3+dev2 ro=False persistent=True\n'
|
b'test-vm3+dev2 ro=False persistent=True\n'
|
||||||
assigns = list(self.vm.devices['test'].assignments())
|
assigns = list(self.vm.devices['test'].assignments())
|
||||||
self.assertEqual(len(assigns), 2)
|
self.assertEqual(len(assigns), 2)
|
||||||
self.assertIsInstance(assigns[0], qubesmgmt.devices.DeviceAssignment)
|
self.assertIsInstance(assigns[0], qubesadmin.devices.DeviceAssignment)
|
||||||
self.assertEqual(assigns[0].backend_domain,
|
self.assertEqual(assigns[0].backend_domain,
|
||||||
self.app.domains['test-vm2'])
|
self.app.domains['test-vm2'])
|
||||||
self.assertEqual(assigns[0].ident, 'dev1')
|
self.assertEqual(assigns[0].ident, 'dev1')
|
||||||
@ -197,7 +197,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.assertEqual(assigns[0].options, {'ro': 'True'})
|
self.assertEqual(assigns[0].options, {'ro': 'True'})
|
||||||
self.assertEqual(assigns[0].persistent, False)
|
self.assertEqual(assigns[0].persistent, False)
|
||||||
|
|
||||||
self.assertIsInstance(assigns[1], qubesmgmt.devices.DeviceAssignment)
|
self.assertIsInstance(assigns[1], qubesadmin.devices.DeviceAssignment)
|
||||||
self.assertEqual(assigns[1].backend_domain,
|
self.assertEqual(assigns[1].backend_domain,
|
||||||
self.app.domains['test-vm3'])
|
self.app.domains['test-vm3'])
|
||||||
self.assertEqual(assigns[1].ident, 'dev2')
|
self.assertEqual(assigns[1].ident, 'dev2')
|
||||||
@ -215,7 +215,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'test-vm3+dev2 persistent=True\n'
|
b'test-vm3+dev2 persistent=True\n'
|
||||||
assigns = list(self.vm.devices['test'].assignments(True))
|
assigns = list(self.vm.devices['test'].assignments(True))
|
||||||
self.assertEqual(len(assigns), 1)
|
self.assertEqual(len(assigns), 1)
|
||||||
self.assertIsInstance(assigns[0], qubesmgmt.devices.DeviceAssignment)
|
self.assertIsInstance(assigns[0], qubesadmin.devices.DeviceAssignment)
|
||||||
self.assertEqual(assigns[0].backend_domain,
|
self.assertEqual(assigns[0].backend_domain,
|
||||||
self.app.domains['test-vm3'])
|
self.app.domains['test-vm3'])
|
||||||
self.assertEqual(assigns[0].ident, 'dev2')
|
self.assertEqual(assigns[0].ident, 'dev2')
|
||||||
@ -232,7 +232,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'test-vm3+dev2 persistent=True\n'
|
b'test-vm3+dev2 persistent=True\n'
|
||||||
assigns = list(self.vm.devices['test'].assignments(False))
|
assigns = list(self.vm.devices['test'].assignments(False))
|
||||||
self.assertEqual(len(assigns), 1)
|
self.assertEqual(len(assigns), 1)
|
||||||
self.assertIsInstance(assigns[0], qubesmgmt.devices.DeviceAssignment)
|
self.assertIsInstance(assigns[0], qubesadmin.devices.DeviceAssignment)
|
||||||
self.assertEqual(assigns[0].backend_domain,
|
self.assertEqual(assigns[0].backend_domain,
|
||||||
self.app.domains['test-vm2'])
|
self.app.domains['test-vm2'])
|
||||||
self.assertEqual(assigns[0].ident, 'dev1')
|
self.assertEqual(assigns[0].ident, 'dev1')
|
||||||
@ -252,7 +252,7 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\0dev2\n'
|
b'0\0dev2\n'
|
||||||
devs = list(self.vm.devices['test'].persistent())
|
devs = list(self.vm.devices['test'].persistent())
|
||||||
self.assertEqual(len(devs), 1)
|
self.assertEqual(len(devs), 1)
|
||||||
self.assertIsInstance(devs[0], qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(devs[0], qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(devs[0].backend_domain, self.app.domains['test-vm3'])
|
self.assertEqual(devs[0].backend_domain, self.app.domains['test-vm3'])
|
||||||
self.assertEqual(devs[0].ident, 'dev2')
|
self.assertEqual(devs[0].ident, 'dev2')
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -270,10 +270,10 @@ class TC_00_DeviceCollection(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\0dev2\n'
|
b'0\0dev2\n'
|
||||||
devs = list(self.vm.devices['test'].attached())
|
devs = list(self.vm.devices['test'].attached())
|
||||||
self.assertEqual(len(devs), 2)
|
self.assertEqual(len(devs), 2)
|
||||||
self.assertIsInstance(devs[0], qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(devs[0], qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(devs[0].backend_domain, self.app.domains['test-vm2'])
|
self.assertEqual(devs[0].backend_domain, self.app.domains['test-vm2'])
|
||||||
self.assertEqual(devs[0].ident, 'dev1')
|
self.assertEqual(devs[0].ident, 'dev1')
|
||||||
self.assertIsInstance(devs[1], qubesmgmt.devices.DeviceInfo)
|
self.assertIsInstance(devs[1], qubesadmin.devices.DeviceInfo)
|
||||||
self.assertEqual(devs[1].backend_domain, self.app.domains['test-vm3'])
|
self.assertEqual(devs[1].backend_domain, self.app.domains['test-vm3'])
|
||||||
self.assertEqual(devs[1].ident, 'dev2')
|
self.assertEqual(devs[1].ident, 'dev2')
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
@ -18,15 +18,15 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TC_00_Errors(qubesmgmt.tests.QubesTestCase):
|
class TC_00_Errors(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_exception(self):
|
def test_000_exception(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'2\x00QubesException\x00\x00An error occurred\x00'
|
b'2\x00QubesException\x00\x00An error occurred\x00'
|
||||||
with self.assertRaises(qubesmgmt.exc.QubesException) as context:
|
with self.assertRaises(qubesadmin.exc.QubesException) as context:
|
||||||
vms = list(self.app.domains)
|
vms = list(self.app.domains)
|
||||||
self.assertEqual(str(context.exception), 'An error occurred')
|
self.assertEqual(str(context.exception), 'An error occurred')
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class TC_00_Errors(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'2\x00QubesException\x00\x00' \
|
b'2\x00QubesException\x00\x00' \
|
||||||
b'An error occurred: %s, %s\x00string\x00other\x00'
|
b'An error occurred: %s, %s\x00string\x00other\x00'
|
||||||
with self.assertRaises(qubesmgmt.exc.QubesException) as context:
|
with self.assertRaises(qubesadmin.exc.QubesException) as context:
|
||||||
vms = list(self.app.domains)
|
vms = list(self.app.domains)
|
||||||
self.assertEqual(str(context.exception),
|
self.assertEqual(str(context.exception),
|
||||||
'An error occurred: string, other')
|
'An error occurred: string, other')
|
||||||
@ -44,7 +44,7 @@ class TC_00_Errors(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'2\x00QubesException\x00\x00' \
|
b'2\x00QubesException\x00\x00' \
|
||||||
b'An error occurred: %d, %d\x001\x002\x00'
|
b'An error occurred: %d, %d\x001\x002\x00'
|
||||||
try:
|
try:
|
||||||
with self.assertRaises(qubesmgmt.exc.QubesException) as context:
|
with self.assertRaises(qubesadmin.exc.QubesException) as context:
|
||||||
vms = list(self.app.domains)
|
vms = list(self.app.domains)
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
self.fail('TypeError: {!s}'.format(e))
|
self.fail('TypeError: {!s}'.format(e))
|
||||||
@ -52,7 +52,7 @@ class TC_00_Errors(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_010_empty(self):
|
def test_010_empty(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = b''
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = b''
|
||||||
with self.assertRaises(qubesmgmt.exc.QubesDaemonNoResponseError) \
|
with self.assertRaises(qubesadmin.exc.QubesDaemonNoResponseError) \
|
||||||
as context:
|
as context:
|
||||||
vms = list(self.app.domains)
|
vms = list(self.app.domains)
|
||||||
self.assertEqual(str(context.exception),
|
self.assertEqual(str(context.exception),
|
@ -22,13 +22,13 @@
|
|||||||
|
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import unittest
|
import unittest
|
||||||
try:
|
try:
|
||||||
# qubesmgmt.events require python3, so this tests can also use python3 features
|
# qubesadmin.events require python3, so this tests can also use python3 features
|
||||||
import asyncio
|
import asyncio
|
||||||
import unittest.mock
|
import unittest.mock
|
||||||
import qubesmgmt.events
|
import qubesadmin.events
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# don't run any tests on python2
|
# don't run any tests on python2
|
||||||
def load_tests(loader, tests, pattern):
|
def load_tests(loader, tests, pattern):
|
||||||
@ -40,11 +40,11 @@ except ImportError:
|
|||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
class TC_00_Events(qubesmgmt.tests.QubesTestCase):
|
class TC_00_Events(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.app = unittest.mock.MagicMock()
|
self.app = unittest.mock.MagicMock()
|
||||||
self.dispatcher = qubesmgmt.events.EventsDispatcher(self.app)
|
self.dispatcher = qubesadmin.events.EventsDispatcher(self.app)
|
||||||
|
|
||||||
def test_000_handler_specific(self):
|
def test_000_handler_specific(self):
|
||||||
handler = unittest.mock.Mock()
|
handler = unittest.mock.Mock()
|
||||||
@ -139,7 +139,7 @@ class TC_00_Events(qubesmgmt.tests.QubesTestCase):
|
|||||||
sock1, sock2 = socket.socketpair()
|
sock1, sock2 = socket.socketpair()
|
||||||
with unittest.mock.patch('asyncio.open_unix_connection',
|
with unittest.mock.patch('asyncio.open_unix_connection',
|
||||||
lambda path: self.mock_open_unix_connection(
|
lambda path: self.mock_open_unix_connection(
|
||||||
qubesmgmt.config.QUBESD_SOCKET, sock1, path)):
|
qubesadmin.config.QUBESD_SOCKET, sock1, path)):
|
||||||
task = asyncio.ensure_future(self.dispatcher._get_events_reader())
|
task = asyncio.ensure_future(self.dispatcher._get_events_reader())
|
||||||
reader = asyncio.ensure_future(loop.run_in_executor(None,
|
reader = asyncio.ensure_future(loop.run_in_executor(None,
|
||||||
self.read_all, sock2))
|
self.read_all, sock2))
|
||||||
@ -165,7 +165,7 @@ class TC_00_Events(qubesmgmt.tests.QubesTestCase):
|
|||||||
vm.name = 'test-vm'
|
vm.name = 'test-vm'
|
||||||
with unittest.mock.patch('asyncio.open_unix_connection',
|
with unittest.mock.patch('asyncio.open_unix_connection',
|
||||||
lambda path: self.mock_open_unix_connection(
|
lambda path: self.mock_open_unix_connection(
|
||||||
qubesmgmt.config.QUBESD_SOCKET, sock1, path)):
|
qubesadmin.config.QUBESD_SOCKET, sock1, path)):
|
||||||
task = asyncio.ensure_future(self.dispatcher._get_events_reader(vm))
|
task = asyncio.ensure_future(self.dispatcher._get_events_reader(vm))
|
||||||
reader = asyncio.ensure_future(loop.run_in_executor(None,
|
reader = asyncio.ensure_future(loop.run_in_executor(None,
|
||||||
self.read_all, sock2))
|
self.read_all, sock2))
|
@ -22,18 +22,18 @@
|
|||||||
'''Tests for firewall API. This is mostly copy from core-admin'''
|
'''Tests for firewall API. This is mostly copy from core-admin'''
|
||||||
import datetime
|
import datetime
|
||||||
import unittest
|
import unittest
|
||||||
import qubesmgmt.firewall
|
import qubesadmin.firewall
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
|
|
||||||
|
|
||||||
class TestOption(qubesmgmt.firewall.RuleChoice):
|
class TestOption(qubesadmin.firewall.RuleChoice):
|
||||||
opt1 = 'opt1'
|
opt1 = 'opt1'
|
||||||
opt2 = 'opt2'
|
opt2 = 'opt2'
|
||||||
another = 'another'
|
another = 'another'
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
class TC_00_RuleChoice(qubesmgmt.tests.QubesTestCase):
|
class TC_00_RuleChoice(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_accept_allowed(self):
|
def test_000_accept_allowed(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
TestOption('opt1')
|
TestOption('opt1')
|
||||||
@ -49,41 +49,41 @@ class TC_00_RuleChoice(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.assertRaises(ValueError, lambda: TestOption('invalid'))
|
self.assertRaises(ValueError, lambda: TestOption('invalid'))
|
||||||
|
|
||||||
|
|
||||||
class TC_01_Action(qubesmgmt.tests.QubesTestCase):
|
class TC_01_Action(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_allowed_values(self):
|
def test_000_allowed_values(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Action('accept')
|
instance = qubesadmin.firewall.Action('accept')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
set(instance.allowed_values), {'accept', 'drop'})
|
set(instance.allowed_values), {'accept', 'drop'})
|
||||||
|
|
||||||
def test_001_rule(self):
|
def test_001_rule(self):
|
||||||
instance = qubesmgmt.firewall.Action('accept')
|
instance = qubesadmin.firewall.Action('accept')
|
||||||
self.assertEqual(instance.rule, 'action=accept')
|
self.assertEqual(instance.rule, 'action=accept')
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
class TC_02_Proto(qubesmgmt.tests.QubesTestCase):
|
class TC_02_Proto(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_allowed_values(self):
|
def test_000_allowed_values(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Proto('tcp')
|
instance = qubesadmin.firewall.Proto('tcp')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
set(instance.allowed_values), {'tcp', 'udp', 'icmp'})
|
set(instance.allowed_values), {'tcp', 'udp', 'icmp'})
|
||||||
|
|
||||||
def test_001_rule(self):
|
def test_001_rule(self):
|
||||||
instance = qubesmgmt.firewall.Proto('tcp')
|
instance = qubesadmin.firewall.Proto('tcp')
|
||||||
self.assertEqual(instance.rule, 'proto=tcp')
|
self.assertEqual(instance.rule, 'proto=tcp')
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
class TC_02_DstHost(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_hostname(self):
|
def test_000_hostname(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('qubes-os.org')
|
instance = qubesadmin.firewall.DstHost('qubes-os.org')
|
||||||
self.assertEqual(instance.type, 'dsthost')
|
self.assertEqual(instance.type, 'dsthost')
|
||||||
|
|
||||||
def test_001_ipv4(self):
|
def test_001_ipv4(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('127.0.0.1')
|
instance = qubesadmin.firewall.DstHost('127.0.0.1')
|
||||||
self.assertEqual(instance.type, 'dst4')
|
self.assertEqual(instance.type, 'dst4')
|
||||||
self.assertEqual(instance.prefixlen, 32)
|
self.assertEqual(instance.prefixlen, 32)
|
||||||
self.assertEqual(str(instance), '127.0.0.1/32')
|
self.assertEqual(str(instance), '127.0.0.1/32')
|
||||||
@ -91,7 +91,7 @@ class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_002_ipv4_prefixlen(self):
|
def test_002_ipv4_prefixlen(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('127.0.0.0', 8)
|
instance = qubesadmin.firewall.DstHost('127.0.0.0', 8)
|
||||||
self.assertEqual(instance.type, 'dst4')
|
self.assertEqual(instance.type, 'dst4')
|
||||||
self.assertEqual(instance.prefixlen, 8)
|
self.assertEqual(instance.prefixlen, 8)
|
||||||
self.assertEqual(str(instance), '127.0.0.0/8')
|
self.assertEqual(str(instance), '127.0.0.0/8')
|
||||||
@ -99,7 +99,7 @@ class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_003_ipv4_parse_prefixlen(self):
|
def test_003_ipv4_parse_prefixlen(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('127.0.0.0/8')
|
instance = qubesadmin.firewall.DstHost('127.0.0.0/8')
|
||||||
self.assertEqual(instance.type, 'dst4')
|
self.assertEqual(instance.type, 'dst4')
|
||||||
self.assertEqual(instance.prefixlen, 8)
|
self.assertEqual(instance.prefixlen, 8)
|
||||||
self.assertEqual(str(instance), '127.0.0.0/8')
|
self.assertEqual(str(instance), '127.0.0.0/8')
|
||||||
@ -107,31 +107,31 @@ class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_004_ipv4_invalid_prefix(self):
|
def test_004_ipv4_invalid_prefix(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('127.0.0.0/33')
|
qubesadmin.firewall.DstHost('127.0.0.0/33')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('127.0.0.0', 33)
|
qubesadmin.firewall.DstHost('127.0.0.0', 33)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('127.0.0.0/-1')
|
qubesadmin.firewall.DstHost('127.0.0.0/-1')
|
||||||
|
|
||||||
def test_005_ipv4_reject_shortened(self):
|
def test_005_ipv4_reject_shortened(self):
|
||||||
# not strictly required, but ppl are used to it
|
# not strictly required, but ppl are used to it
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('127/8')
|
qubesadmin.firewall.DstHost('127/8')
|
||||||
|
|
||||||
def test_006_ipv4_invalid_addr(self):
|
def test_006_ipv4_invalid_addr(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('137.327.0.0/16')
|
qubesadmin.firewall.DstHost('137.327.0.0/16')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('1.2.3.4.5/32')
|
qubesadmin.firewall.DstHost('1.2.3.4.5/32')
|
||||||
|
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_007_ipv4_invalid_network(self):
|
def test_007_ipv4_invalid_network(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('127.0.0.1/32')
|
qubesadmin.firewall.DstHost('127.0.0.1/32')
|
||||||
|
|
||||||
def test_010_ipv6(self):
|
def test_010_ipv6(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('2001:abcd:efab::3')
|
instance = qubesadmin.firewall.DstHost('2001:abcd:efab::3')
|
||||||
self.assertEqual(instance.type, 'dst6')
|
self.assertEqual(instance.type, 'dst6')
|
||||||
self.assertEqual(instance.prefixlen, 128)
|
self.assertEqual(instance.prefixlen, 128)
|
||||||
self.assertEqual(str(instance), '2001:abcd:efab::3/128')
|
self.assertEqual(str(instance), '2001:abcd:efab::3/128')
|
||||||
@ -139,7 +139,7 @@ class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_011_ipv6_prefixlen(self):
|
def test_011_ipv6_prefixlen(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('2001:abcd:efab::', 64)
|
instance = qubesadmin.firewall.DstHost('2001:abcd:efab::', 64)
|
||||||
self.assertEqual(instance.type, 'dst6')
|
self.assertEqual(instance.type, 'dst6')
|
||||||
self.assertEqual(instance.prefixlen, 64)
|
self.assertEqual(instance.prefixlen, 64)
|
||||||
self.assertEqual(str(instance), '2001:abcd:efab::/64')
|
self.assertEqual(str(instance), '2001:abcd:efab::/64')
|
||||||
@ -147,7 +147,7 @@ class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_012_ipv6_parse_prefixlen(self):
|
def test_012_ipv6_parse_prefixlen(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstHost('2001:abcd:efab::/64')
|
instance = qubesadmin.firewall.DstHost('2001:abcd:efab::/64')
|
||||||
self.assertEqual(instance.type, 'dst6')
|
self.assertEqual(instance.type, 'dst6')
|
||||||
self.assertEqual(instance.prefixlen, 64)
|
self.assertEqual(instance.prefixlen, 64)
|
||||||
self.assertEqual(str(instance), '2001:abcd:efab::/64')
|
self.assertEqual(str(instance), '2001:abcd:efab::/64')
|
||||||
@ -155,120 +155,120 @@ class TC_02_DstHost(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_013_ipv6_invalid_prefix(self):
|
def test_013_ipv6_invalid_prefix(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab::3/129')
|
qubesadmin.firewall.DstHost('2001:abcd:efab::3/129')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab::3', 129)
|
qubesadmin.firewall.DstHost('2001:abcd:efab::3', 129)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab::3/-1')
|
qubesadmin.firewall.DstHost('2001:abcd:efab::3/-1')
|
||||||
|
|
||||||
def test_014_ipv6_invalid_addr(self):
|
def test_014_ipv6_invalid_addr(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab0123::3/128')
|
qubesadmin.firewall.DstHost('2001:abcd:efab0123::3/128')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab:3/128')
|
qubesadmin.firewall.DstHost('2001:abcd:efab:3/128')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab:a:a:a:a:a:a:3/128')
|
qubesadmin.firewall.DstHost('2001:abcd:efab:a:a:a:a:a:a:3/128')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efgh::3/128')
|
qubesadmin.firewall.DstHost('2001:abcd:efgh::3/128')
|
||||||
|
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_015_ipv6_invalid_network(self):
|
def test_015_ipv6_invalid_network(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('2001:abcd:efab::3/64')
|
qubesadmin.firewall.DstHost('2001:abcd:efab::3/64')
|
||||||
|
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_020_invalid_hostname(self):
|
def test_020_invalid_hostname(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('www qubes-os.org')
|
qubesadmin.firewall.DstHost('www qubes-os.org')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstHost('https://qubes-os.org')
|
qubesadmin.firewall.DstHost('https://qubes-os.org')
|
||||||
|
|
||||||
|
|
||||||
class TC_03_DstPorts(qubesmgmt.tests.QubesTestCase):
|
class TC_03_DstPorts(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_single_str(self):
|
def test_000_single_str(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstPorts('80')
|
instance = qubesadmin.firewall.DstPorts('80')
|
||||||
self.assertEqual(str(instance), '80')
|
self.assertEqual(str(instance), '80')
|
||||||
self.assertEqual(instance.range, [80, 80])
|
self.assertEqual(instance.range, [80, 80])
|
||||||
self.assertEqual(instance.rule, 'dstports=80-80')
|
self.assertEqual(instance.rule, 'dstports=80-80')
|
||||||
|
|
||||||
def test_001_single_int(self):
|
def test_001_single_int(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstPorts(80)
|
instance = qubesadmin.firewall.DstPorts(80)
|
||||||
self.assertEqual(str(instance), '80')
|
self.assertEqual(str(instance), '80')
|
||||||
self.assertEqual(instance.range, [80, 80])
|
self.assertEqual(instance.range, [80, 80])
|
||||||
self.assertEqual(instance.rule, 'dstports=80-80')
|
self.assertEqual(instance.rule, 'dstports=80-80')
|
||||||
|
|
||||||
def test_002_range(self):
|
def test_002_range(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.DstPorts('80-90')
|
instance = qubesadmin.firewall.DstPorts('80-90')
|
||||||
self.assertEqual(str(instance), '80-90')
|
self.assertEqual(str(instance), '80-90')
|
||||||
self.assertEqual(instance.range, [80, 90])
|
self.assertEqual(instance.range, [80, 90])
|
||||||
self.assertEqual(instance.rule, 'dstports=80-90')
|
self.assertEqual(instance.rule, 'dstports=80-90')
|
||||||
|
|
||||||
def test_003_invalid(self):
|
def test_003_invalid(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('80-90-100')
|
qubesadmin.firewall.DstPorts('80-90-100')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('abcdef')
|
qubesadmin.firewall.DstPorts('abcdef')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('80 90')
|
qubesadmin.firewall.DstPorts('80 90')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('')
|
qubesadmin.firewall.DstPorts('')
|
||||||
|
|
||||||
def test_004_reversed_range(self):
|
def test_004_reversed_range(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('100-20')
|
qubesadmin.firewall.DstPorts('100-20')
|
||||||
|
|
||||||
def test_005_out_of_range(self):
|
def test_005_out_of_range(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('1000000000000')
|
qubesadmin.firewall.DstPorts('1000000000000')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts(1000000000000)
|
qubesadmin.firewall.DstPorts(1000000000000)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.DstPorts('1-1000000000000')
|
qubesadmin.firewall.DstPorts('1-1000000000000')
|
||||||
|
|
||||||
|
|
||||||
class TC_04_IcmpType(qubesmgmt.tests.QubesTestCase):
|
class TC_04_IcmpType(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_number(self):
|
def test_000_number(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.IcmpType(8)
|
instance = qubesadmin.firewall.IcmpType(8)
|
||||||
self.assertEqual(str(instance), '8')
|
self.assertEqual(str(instance), '8')
|
||||||
self.assertEqual(instance.rule, 'icmptype=8')
|
self.assertEqual(instance.rule, 'icmptype=8')
|
||||||
|
|
||||||
def test_001_str(self):
|
def test_001_str(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.IcmpType('8')
|
instance = qubesadmin.firewall.IcmpType('8')
|
||||||
self.assertEqual(str(instance), '8')
|
self.assertEqual(str(instance), '8')
|
||||||
self.assertEqual(instance.rule, 'icmptype=8')
|
self.assertEqual(instance.rule, 'icmptype=8')
|
||||||
|
|
||||||
def test_002_invalid(self):
|
def test_002_invalid(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.IcmpType(600)
|
qubesadmin.firewall.IcmpType(600)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.IcmpType(-1)
|
qubesadmin.firewall.IcmpType(-1)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.IcmpType('abcde')
|
qubesadmin.firewall.IcmpType('abcde')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.IcmpType('')
|
qubesadmin.firewall.IcmpType('')
|
||||||
|
|
||||||
|
|
||||||
class TC_05_SpecialTarget(qubesmgmt.tests.QubesTestCase):
|
class TC_05_SpecialTarget(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_allowed_values(self):
|
def test_000_allowed_values(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.SpecialTarget('dns')
|
instance = qubesadmin.firewall.SpecialTarget('dns')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
set(instance.allowed_values), {'dns'})
|
set(instance.allowed_values), {'dns'})
|
||||||
|
|
||||||
def test_001_rule(self):
|
def test_001_rule(self):
|
||||||
instance = qubesmgmt.firewall.SpecialTarget('dns')
|
instance = qubesadmin.firewall.SpecialTarget('dns')
|
||||||
self.assertEqual(instance.rule, 'specialtarget=dns')
|
self.assertEqual(instance.rule, 'specialtarget=dns')
|
||||||
|
|
||||||
|
|
||||||
class TC_06_Expire(qubesmgmt.tests.QubesTestCase):
|
class TC_06_Expire(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_number(self):
|
def test_000_number(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Expire(1463292452)
|
instance = qubesadmin.firewall.Expire(1463292452)
|
||||||
self.assertEqual(str(instance), '1463292452')
|
self.assertEqual(str(instance), '1463292452')
|
||||||
self.assertEqual(instance.datetime,
|
self.assertEqual(instance.datetime,
|
||||||
datetime.datetime(2016, 5, 15, 6, 7, 32))
|
datetime.datetime(2016, 5, 15, 6, 7, 32))
|
||||||
@ -276,7 +276,7 @@ class TC_06_Expire(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_001_str(self):
|
def test_001_str(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Expire('1463292452')
|
instance = qubesadmin.firewall.Expire('1463292452')
|
||||||
self.assertEqual(str(instance), '1463292452')
|
self.assertEqual(str(instance), '1463292452')
|
||||||
self.assertEqual(instance.datetime,
|
self.assertEqual(instance.datetime,
|
||||||
datetime.datetime(2016, 5, 15, 6, 7, 32))
|
datetime.datetime(2016, 5, 15, 6, 7, 32))
|
||||||
@ -284,31 +284,31 @@ class TC_06_Expire(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_002_invalid(self):
|
def test_002_invalid(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.Expire('abcdef')
|
qubesadmin.firewall.Expire('abcdef')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
qubesmgmt.firewall.Expire('')
|
qubesadmin.firewall.Expire('')
|
||||||
|
|
||||||
def test_003_expired(self):
|
def test_003_expired(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Expire('1463292452')
|
instance = qubesadmin.firewall.Expire('1463292452')
|
||||||
self.assertTrue(instance.expired)
|
self.assertTrue(instance.expired)
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Expire('1583292452')
|
instance = qubesadmin.firewall.Expire('1583292452')
|
||||||
self.assertFalse(instance.expired)
|
self.assertFalse(instance.expired)
|
||||||
|
|
||||||
|
|
||||||
class TC_07_Comment(qubesmgmt.tests.QubesTestCase):
|
class TC_07_Comment(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_str(self):
|
def test_000_str(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
instance = qubesmgmt.firewall.Comment('Some comment')
|
instance = qubesadmin.firewall.Comment('Some comment')
|
||||||
self.assertEqual(str(instance), 'Some comment')
|
self.assertEqual(str(instance), 'Some comment')
|
||||||
self.assertEqual(instance.rule, 'comment=Some comment')
|
self.assertEqual(instance.rule, 'comment=Some comment')
|
||||||
|
|
||||||
|
|
||||||
class TC_10_Rule(qubesmgmt.tests.QubesTestCase):
|
class TC_10_Rule(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_simple(self):
|
def test_000_simple(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule = qubesmgmt.firewall.Rule(None, action='accept', proto='icmp')
|
rule = qubesadmin.firewall.Rule(None, action='accept', proto='icmp')
|
||||||
self.assertEqual(rule.rule, 'action=accept proto=icmp')
|
self.assertEqual(rule.rule, 'action=accept proto=icmp')
|
||||||
self.assertIsNone(rule.dsthost)
|
self.assertIsNone(rule.dsthost)
|
||||||
self.assertIsNone(rule.dstports)
|
self.assertIsNone(rule.dstports)
|
||||||
@ -320,7 +320,7 @@ class TC_10_Rule(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_001_expire(self):
|
def test_001_expire(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule = qubesmgmt.firewall.Rule(None, action='accept', proto='icmp',
|
rule = qubesadmin.firewall.Rule(None, action='accept', proto='icmp',
|
||||||
expire='1463292452')
|
expire='1463292452')
|
||||||
self.assertEqual(rule.rule,
|
self.assertEqual(rule.rule,
|
||||||
'action=accept proto=icmp expire=1463292452')
|
'action=accept proto=icmp expire=1463292452')
|
||||||
@ -328,40 +328,40 @@ class TC_10_Rule(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_002_dstports(self):
|
def test_002_dstports(self):
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule = qubesmgmt.firewall.Rule(None, action='accept', proto='tcp',
|
rule = qubesadmin.firewall.Rule(None, action='accept', proto='tcp',
|
||||||
dstports=80)
|
dstports=80)
|
||||||
self.assertEqual(str(rule.dstports), '80')
|
self.assertEqual(str(rule.dstports), '80')
|
||||||
|
|
||||||
def test_003_reject_invalid(self):
|
def test_003_reject_invalid(self):
|
||||||
with self.assertRaises((ValueError, AssertionError)):
|
with self.assertRaises((ValueError, AssertionError)):
|
||||||
# missing action
|
# missing action
|
||||||
qubesmgmt.firewall.Rule(None, proto='icmp')
|
qubesadmin.firewall.Rule(None, proto='icmp')
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
# not proto=tcp or proto=udp for dstports
|
# not proto=tcp or proto=udp for dstports
|
||||||
qubesmgmt.firewall.Rule(None, action='accept', proto='icmp',
|
qubesadmin.firewall.Rule(None, action='accept', proto='icmp',
|
||||||
dstports=80)
|
dstports=80)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
# not proto=tcp or proto=udp for dstports
|
# not proto=tcp or proto=udp for dstports
|
||||||
qubesmgmt.firewall.Rule(None, action='accept', dstports=80)
|
qubesadmin.firewall.Rule(None, action='accept', dstports=80)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
# not proto=icmp for icmptype
|
# not proto=icmp for icmptype
|
||||||
qubesmgmt.firewall.Rule(None, action='accept', proto='tcp',
|
qubesadmin.firewall.Rule(None, action='accept', proto='tcp',
|
||||||
icmptype=8)
|
icmptype=8)
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
# not proto=icmp for icmptype
|
# not proto=icmp for icmptype
|
||||||
qubesmgmt.firewall.Rule(None, action='accept', icmptype=8)
|
qubesadmin.firewall.Rule(None, action='accept', icmptype=8)
|
||||||
|
|
||||||
def test_004_proto_change(self):
|
def test_004_proto_change(self):
|
||||||
rule = qubesmgmt.firewall.Rule(None, action='accept', proto='tcp')
|
rule = qubesadmin.firewall.Rule(None, action='accept', proto='tcp')
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule.proto = 'udp'
|
rule.proto = 'udp'
|
||||||
self.assertEqual(rule.rule, 'action=accept proto=udp')
|
self.assertEqual(rule.rule, 'action=accept proto=udp')
|
||||||
rule = qubesmgmt.firewall.Rule(None, action='accept', proto='tcp',
|
rule = qubesadmin.firewall.Rule(None, action='accept', proto='tcp',
|
||||||
dstports=80)
|
dstports=80)
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule.proto = 'udp'
|
rule.proto = 'udp'
|
||||||
self.assertEqual(rule.rule, 'action=accept proto=udp dstports=80-80')
|
self.assertEqual(rule.rule, 'action=accept proto=udp dstports=80-80')
|
||||||
rule = qubesmgmt.firewall.Rule(None, action='accept')
|
rule = qubesadmin.firewall.Rule(None, action='accept')
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule.proto = 'udp'
|
rule.proto = 'udp'
|
||||||
self.assertEqual(rule.rule, 'action=accept proto=udp')
|
self.assertEqual(rule.rule, 'action=accept proto=udp')
|
||||||
@ -383,7 +383,7 @@ class TC_10_Rule(qubesmgmt.tests.QubesTestCase):
|
|||||||
rule_txt = \
|
rule_txt = \
|
||||||
'action=accept dst4=192.168.0.0/24 proto=tcp dstports=443'
|
'action=accept dst4=192.168.0.0/24 proto=tcp dstports=443'
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule = qubesmgmt.firewall.Rule(rule_txt)
|
rule = qubesadmin.firewall.Rule(rule_txt)
|
||||||
self.assertEqual(rule.dsthost, '192.168.0.0/24')
|
self.assertEqual(rule.dsthost, '192.168.0.0/24')
|
||||||
self.assertEqual(rule.proto, 'tcp')
|
self.assertEqual(rule.proto, 'tcp')
|
||||||
self.assertEqual(rule.dstports, '443')
|
self.assertEqual(rule.dstports, '443')
|
||||||
@ -394,7 +394,7 @@ class TC_10_Rule(qubesmgmt.tests.QubesTestCase):
|
|||||||
rule_txt = \
|
rule_txt = \
|
||||||
'action=accept dsthost=qubes-os.org comment=Some comment'
|
'action=accept dsthost=qubes-os.org comment=Some comment'
|
||||||
with self.assertNotRaises(ValueError):
|
with self.assertNotRaises(ValueError):
|
||||||
rule = qubesmgmt.firewall.Rule(rule_txt)
|
rule = qubesadmin.firewall.Rule(rule_txt)
|
||||||
self.assertEqual(rule.dsthost, 'qubes-os.org')
|
self.assertEqual(rule.dsthost, 'qubes-os.org')
|
||||||
self.assertIsNone(rule.proto)
|
self.assertIsNone(rule.proto)
|
||||||
self.assertIsNone(rule.dstports)
|
self.assertIsNone(rule.dstports)
|
||||||
@ -402,7 +402,7 @@ class TC_10_Rule(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.assertEqual(rule.comment, 'Some comment')
|
self.assertEqual(rule.comment, 'Some comment')
|
||||||
|
|
||||||
|
|
||||||
class TC_11_Firewall(qubesmgmt.tests.QubesTestCase):
|
class TC_11_Firewall(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_11_Firewall, self).setUp()
|
super(TC_11_Firewall, self).setUp()
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -414,7 +414,7 @@ class TC_11_Firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
None, None)] = b'0\0accept'
|
None, None)] = b'0\0accept'
|
||||||
policy = self.vm.firewall.policy
|
policy = self.vm.firewall.policy
|
||||||
self.assertEqual(policy, 'accept')
|
self.assertEqual(policy, 'accept')
|
||||||
self.assertEqual(policy, qubesmgmt.firewall.Action('accept'))
|
self.assertEqual(policy, qubesadmin.firewall.Action('accept'))
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_policy_set(self):
|
def test_001_policy_set(self):
|
||||||
@ -426,7 +426,7 @@ class TC_11_Firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_002_policy_set2(self):
|
def test_002_policy_set2(self):
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy',
|
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy',
|
||||||
None, b'drop')] = b'0\0'
|
None, b'drop')] = b'0\0'
|
||||||
self.vm.firewall.policy = qubesmgmt.firewall.Action('drop')
|
self.vm.firewall.policy = qubesadmin.firewall.Action('drop')
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_010_load_rules(self):
|
def test_010_load_rules(self):
|
||||||
@ -436,8 +436,8 @@ class TC_11_Firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
rules = self.vm.firewall.rules
|
rules = self.vm.firewall.rules
|
||||||
self.assertListEqual(rules, [
|
self.assertListEqual(rules, [
|
||||||
qubesmgmt.firewall.Rule('action=accept dsthost=qubes-os.org'),
|
qubesadmin.firewall.Rule('action=accept dsthost=qubes-os.org'),
|
||||||
qubesmgmt.firewall.Rule('action=drop proto=icmp'),
|
qubesadmin.firewall.Rule('action=drop proto=icmp'),
|
||||||
])
|
])
|
||||||
# check caching
|
# check caching
|
||||||
del self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get',
|
del self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Get',
|
||||||
@ -451,7 +451,7 @@ class TC_11_Firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.vm.firewall.load_rules()
|
self.vm.firewall.load_rules()
|
||||||
rules3 = self.vm.firewall.rules
|
rules3 = self.vm.firewall.rules
|
||||||
self.assertListEqual(rules3, [
|
self.assertListEqual(rules3, [
|
||||||
qubesmgmt.firewall.Rule(
|
qubesadmin.firewall.Rule(
|
||||||
'action=accept dsthost=qubes-os.org proto=tcp dstports=443')])
|
'action=accept dsthost=qubes-os.org proto=tcp dstports=443')])
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -460,7 +460,7 @@ class TC_11_Firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
'action=accept proto=tcp dsthost=qubes-os.org dstports=443-443',
|
'action=accept proto=tcp dsthost=qubes-os.org dstports=443-443',
|
||||||
'action=accept dsthost=example.com',
|
'action=accept dsthost=example.com',
|
||||||
)
|
)
|
||||||
rules = [qubesmgmt.firewall.Rule(rule) for rule in rules_txt]
|
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', 'mgmt.vm.firewall.Set', None,
|
||||||
''.join(rule + '\n' for rule in rules_txt).encode('ascii'))] = b'0\0'
|
''.join(rule + '\n' for rule in rules_txt).encode('ascii'))] = b'0\0'
|
||||||
self.vm.firewall.rules = rules
|
self.vm.firewall.rules = rules
|
@ -18,11 +18,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
from qubesmgmt.label import Label
|
from qubesadmin.label import Label
|
||||||
|
|
||||||
|
|
||||||
class TC_00_Label(qubesmgmt.tests.QubesTestCase):
|
class TC_00_Label(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.label.List', None, None)] = \
|
('dom0', 'mgmt.label.List', None, None)] = \
|
@ -18,16 +18,16 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.storage
|
import qubesadmin.storage
|
||||||
|
|
||||||
|
|
||||||
class TestVMVolume(qubesmgmt.tests.QubesTestCase):
|
class TestVMVolume(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestVMVolume, self).setUp()
|
super(TestVMVolume, self).setUp()
|
||||||
self.vol = qubesmgmt.storage.Volume(self.app, vm='test-vm',
|
self.vol = qubesadmin.storage.Volume(self.app, vm='test-vm',
|
||||||
vm_name='volname')
|
vm_name='volname')
|
||||||
self.pool_vol = qubesmgmt.storage.Volume(self.app, pool='test-pool',
|
self.pool_vol = qubesadmin.storage.Volume(self.app, pool='test-pool',
|
||||||
vid='some-id')
|
vid='some-id')
|
||||||
|
|
||||||
def expect_info(self):
|
def expect_info(self):
|
||||||
@ -154,7 +154,7 @@ class TestVMVolume(qubesmgmt.tests.QubesTestCase):
|
|||||||
class TestPoolVolume(TestVMVolume):
|
class TestPoolVolume(TestVMVolume):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestPoolVolume, self).setUp()
|
super(TestPoolVolume, self).setUp()
|
||||||
self.vol = qubesmgmt.storage.Volume(self.app, pool='test-pool',
|
self.vol = qubesadmin.storage.Volume(self.app, pool='test-pool',
|
||||||
vid='some-id')
|
vid='some-id')
|
||||||
|
|
||||||
def test_000_qubesd_call(self):
|
def test_000_qubesd_call(self):
|
||||||
@ -234,13 +234,13 @@ class TestPoolVolume(TestVMVolume):
|
|||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
|
|
||||||
class TestPool(qubesmgmt.tests.QubesTestCase):
|
class TestPool(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \
|
||||||
b'0\x00file\nlvm\n'
|
b'0\x00file\nlvm\n'
|
||||||
seen = set()
|
seen = set()
|
||||||
for pool in self.app.pools:
|
for pool in self.app.pools:
|
||||||
self.assertIsInstance(pool, qubesmgmt.storage.Pool)
|
self.assertIsInstance(pool, qubesadmin.storage.Pool)
|
||||||
self.assertIn(pool.name, ('file', 'lvm'))
|
self.assertIn(pool.name, ('file', 'lvm'))
|
||||||
self.assertNotIn(pool.name, seen)
|
self.assertNotIn(pool.name, seen)
|
||||||
seen.add(pool.name)
|
seen.add(pool.name)
|
||||||
@ -275,7 +275,7 @@ class TestPool(qubesmgmt.tests.QubesTestCase):
|
|||||||
pool = self.app.pools['file']
|
pool = self.app.pools['file']
|
||||||
seen = set()
|
seen = set()
|
||||||
for volume in pool.volumes:
|
for volume in pool.volumes:
|
||||||
self.assertIsInstance(volume, qubesmgmt.storage.Volume)
|
self.assertIsInstance(volume, qubesadmin.storage.Volume)
|
||||||
self.assertIn(volume.vid, ('vol1', 'vol2'))
|
self.assertIn(volume.vid, ('vol1', 'vol2'))
|
||||||
self.assertEqual(volume.pool, 'file')
|
self.assertEqual(volume.pool, 'file')
|
||||||
self.assertNotIn(volume.vid, seen)
|
self.assertNotIn(volume.vid, seen)
|
@ -19,16 +19,16 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
|
|
||||||
class TC_00_PropertyAction(qubesmgmt.tests.QubesTestCase):
|
class TC_00_PropertyAction(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_default(self):
|
def test_000_default(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--property', '-p',
|
parser.add_argument('--property', '-p',
|
||||||
action=qubesmgmt.tools.PropertyAction)
|
action=qubesadmin.tools.PropertyAction)
|
||||||
parser.set_defaults(properties={'defaultprop': 'defaultvalue'})
|
parser.set_defaults(properties={'defaultprop': 'defaultvalue'})
|
||||||
|
|
||||||
args = parser.parse_args([])
|
args = parser.parse_args([])
|
||||||
@ -38,7 +38,7 @@ class TC_00_PropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_001_set_prop(self):
|
def test_001_set_prop(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--property', '-p',
|
parser.add_argument('--property', '-p',
|
||||||
action=qubesmgmt.tools.PropertyAction)
|
action=qubesadmin.tools.PropertyAction)
|
||||||
|
|
||||||
args = parser.parse_args(['-p', 'testprop=testvalue'])
|
args = parser.parse_args(['-p', 'testprop=testvalue'])
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
@ -47,7 +47,7 @@ class TC_00_PropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_002_set_prop_2(self):
|
def test_002_set_prop_2(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--property', '-p',
|
parser.add_argument('--property', '-p',
|
||||||
action=qubesmgmt.tools.PropertyAction)
|
action=qubesadmin.tools.PropertyAction)
|
||||||
parser.set_defaults(properties={'defaultprop': 'defaultvalue'})
|
parser.set_defaults(properties={'defaultprop': 'defaultvalue'})
|
||||||
|
|
||||||
args = parser.parse_args(
|
args = parser.parse_args(
|
||||||
@ -59,7 +59,7 @@ class TC_00_PropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_003_set_prop_with_default(self):
|
def test_003_set_prop_with_default(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--property', '-p',
|
parser.add_argument('--property', '-p',
|
||||||
action=qubesmgmt.tools.PropertyAction)
|
action=qubesadmin.tools.PropertyAction)
|
||||||
parser.set_defaults(properties={'defaultprop': 'defaultvalue'})
|
parser.set_defaults(properties={'defaultprop': 'defaultvalue'})
|
||||||
|
|
||||||
args = parser.parse_args(['-p', 'testprop=testvalue'])
|
args = parser.parse_args(['-p', 'testprop=testvalue'])
|
||||||
@ -71,7 +71,7 @@ class TC_00_PropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--property', '-p',
|
parser.add_argument('--property', '-p',
|
||||||
action=qubesmgmt.tools.PropertyAction)
|
action=qubesadmin.tools.PropertyAction)
|
||||||
parser.set_defaults(properties={'testprop': 'defaultvalue'})
|
parser.set_defaults(properties={'testprop': 'defaultvalue'})
|
||||||
|
|
||||||
args = parser.parse_args(['-p', 'testprop=testvalue'])
|
args = parser.parse_args(['-p', 'testprop=testvalue'])
|
||||||
@ -80,24 +80,24 @@ class TC_00_PropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
args.properties)
|
args.properties)
|
||||||
|
|
||||||
|
|
||||||
class TC_01_SinglePropertyAction(qubesmgmt.tests.QubesTestCase):
|
class TC_01_SinglePropertyAction(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_help(self):
|
def test_000_help(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
action = parser.add_argument('--testprop', '-T',
|
action = parser.add_argument('--testprop', '-T',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction)
|
action=qubesadmin.tools.SinglePropertyAction)
|
||||||
self.assertIn('testprop', action.help)
|
self.assertIn('testprop', action.help)
|
||||||
|
|
||||||
def test_001_help_const(self):
|
def test_001_help_const(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
action = parser.add_argument('--testprop', '-T',
|
action = parser.add_argument('--testprop', '-T',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction,
|
action=qubesadmin.tools.SinglePropertyAction,
|
||||||
const='testvalue')
|
const='testvalue')
|
||||||
self.assertIn('testvalue', action.help)
|
self.assertIn('testvalue', action.help)
|
||||||
|
|
||||||
def test_100_default(self):
|
def test_100_default(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--testprop', '-T',
|
parser.add_argument('--testprop', '-T',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction)
|
action=qubesadmin.tools.SinglePropertyAction)
|
||||||
parser.set_defaults(properties={'testprop': 'defaultvalue'})
|
parser.set_defaults(properties={'testprop': 'defaultvalue'})
|
||||||
|
|
||||||
args = parser.parse_args([])
|
args = parser.parse_args([])
|
||||||
@ -107,7 +107,7 @@ class TC_01_SinglePropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_101_set_prop(self):
|
def test_101_set_prop(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--testprop', '-T',
|
parser.add_argument('--testprop', '-T',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction)
|
action=qubesadmin.tools.SinglePropertyAction)
|
||||||
args = parser.parse_args(['-T', 'testvalue'])
|
args = parser.parse_args(['-T', 'testvalue'])
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
{'testprop': 'testvalue'}, args.properties)
|
{'testprop': 'testvalue'}, args.properties)
|
||||||
@ -115,7 +115,7 @@ class TC_01_SinglePropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_102_set_prop_dest(self):
|
def test_102_set_prop_dest(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--testprop', '-T', dest='otherprop',
|
parser.add_argument('--testprop', '-T', dest='otherprop',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction)
|
action=qubesadmin.tools.SinglePropertyAction)
|
||||||
args = parser.parse_args(['-T', 'testvalue'])
|
args = parser.parse_args(['-T', 'testvalue'])
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
{'otherprop': 'testvalue'}, args.properties)
|
{'otherprop': 'testvalue'}, args.properties)
|
||||||
@ -123,7 +123,7 @@ class TC_01_SinglePropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_103_set_prop_const(self):
|
def test_103_set_prop_const(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--testprop', '-T',
|
parser.add_argument('--testprop', '-T',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction,
|
action=qubesadmin.tools.SinglePropertyAction,
|
||||||
const='testvalue')
|
const='testvalue')
|
||||||
args = parser.parse_args(['-T'])
|
args = parser.parse_args(['-T'])
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
@ -132,7 +132,7 @@ class TC_01_SinglePropertyAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_104_set_prop_positional(self):
|
def test_104_set_prop_positional(self):
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('testprop',
|
parser.add_argument('testprop',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction)
|
action=qubesadmin.tools.SinglePropertyAction)
|
||||||
args = parser.parse_args(['testvalue'])
|
args = parser.parse_args(['testvalue'])
|
||||||
self.assertDictContainsSubset(
|
self.assertDictContainsSubset(
|
||||||
{'testprop': 'testvalue'}, args.properties)
|
{'testprop': 'testvalue'}, args.properties)
|
@ -18,12 +18,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qubes_prefs
|
import qubesadmin.tools.qubes_prefs
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qubes_prefs(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qubes_prefs(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.property.List', None, None)] = \
|
('dom0', 'mgmt.property.List', None, None)] = \
|
||||||
@ -34,8 +34,8 @@ class TC_00_qubes_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.property.Get', 'prop2', None)] = \
|
('dom0', 'mgmt.property.Get', 'prop2', None)] = \
|
||||||
b'0\x00default=False type=str value2'
|
b'0\x00default=False type=str value2'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0, qubesmgmt.tools.qubes_prefs.main([], app=self.app))
|
self.assertEqual(0, qubesadmin.tools.qubes_prefs.main([], app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'prop1 D value1\n'
|
'prop1 D value1\n'
|
||||||
'prop2 - value2\n')
|
'prop2 - value2\n')
|
||||||
@ -45,7 +45,7 @@ class TC_00_qubes_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.property.Set', 'default_user', b'testuser')]\
|
('dom0', 'mgmt.property.Set', 'default_user', b'testuser')]\
|
||||||
= b'0\x00'
|
= b'0\x00'
|
||||||
self.assertEqual(0, qubesmgmt.tools.qubes_prefs.main([
|
self.assertEqual(0, qubesadmin.tools.qubes_prefs.main([
|
||||||
'default_user', 'testuser'], app=self.app))
|
'default_user', 'testuser'], app=self.app))
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ class TC_00_qubes_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.property.Get', 'no_such_property', None)] = \
|
('dom0', 'mgmt.property.Get', 'no_such_property', None)] = \
|
||||||
b'2\x00AttributeError\x00\x00no_such_property\x00'
|
b'2\x00AttributeError\x00\x00no_such_property\x00'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qubes_prefs.main([
|
qubesadmin.tools.qubes_prefs.main([
|
||||||
'no_such_property'], app=self.app)
|
'no_such_property'], app=self.app)
|
||||||
self.assertIn('no such property: \'no_such_property\'',
|
self.assertIn('no such property: \'no_such_property\'',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
@ -66,8 +66,8 @@ class TC_00_qubes_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.property.Set', 'no_such_property', b'value')]\
|
('dom0', 'mgmt.property.Set', 'no_such_property', b'value')]\
|
||||||
= b'2\x00AttributeError\x00\x00no_such_property\x00'
|
= b'2\x00AttributeError\x00\x00no_such_property\x00'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qubes_prefs.main([
|
qubesadmin.tools.qubes_prefs.main([
|
||||||
'no_such_property', 'value'], app=self.app)
|
'no_such_property', 'value'], app=self.app)
|
||||||
self.assertIn('no such property: \'no_such_property\'',
|
self.assertIn('no such property: \'no_such_property\'',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
@ -18,16 +18,16 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tools.qvm_check
|
import qubesadmin.tools.qvm_check
|
||||||
|
|
||||||
class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_exists(self):
|
def test_000_exists(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_check.main(['some-vm'], app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'other-vm class=AppVM state=Running\n'
|
b'other-vm class=AppVM state=Running\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['some-vm', 'other-vm'],
|
qubesadmin.tools.qvm_check.main(['some-vm', 'other-vm'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -46,9 +46,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_check.main(['some-vm'], app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'VM some-vm exists\n')
|
'VM some-vm exists\n')
|
||||||
@ -59,9 +59,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'other-vm class=AppVM state=Running\n'
|
b'other-vm class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['some-vm', 'other-vm'],
|
qubesadmin.tools.qvm_check.main(['some-vm', 'other-vm'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
@ -77,9 +77,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.List', None, None)] = \
|
('some-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'some-vm'], app=self.app),
|
'some-vm'], app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
@ -98,9 +98,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm2 class=AppVM state=Running\n'
|
b'0\x00some-vm2 class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'some-vm', 'some-vm2'],
|
'some-vm', 'some-vm2'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -123,9 +123,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'--all'],
|
'--all'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -142,9 +142,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'some-vm3'],
|
'some-vm3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
1)
|
1)
|
||||||
@ -161,9 +161,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm2 class=AppVM state=Paused\n'
|
b'0\x00some-vm2 class=AppVM state=Paused\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--paused',
|
qubesadmin.tools.qvm_check.main(['--paused',
|
||||||
'some-vm2'],
|
'some-vm2'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -183,9 +183,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.List', None, None)] = \
|
('some-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--paused',
|
qubesadmin.tools.qvm_check.main(['--paused',
|
||||||
'some-vm2', 'some-vm'],
|
'some-vm2', 'some-vm'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -200,9 +200,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'some-vm2 class=AppVM state=Paused\n' \
|
b'some-vm2 class=AppVM state=Paused\n' \
|
||||||
b'some-vm3 class=TemplateVM state=Halted\n'
|
b'some-vm3 class=TemplateVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--template',
|
qubesadmin.tools.qvm_check.main(['--template',
|
||||||
'some-vm3'],
|
'some-vm3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -216,9 +216,9 @@ class TC_00_qvm_check(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'some-vm2 class=AppVM state=Paused\n' \
|
b'some-vm2 class=AppVM state=Paused\n' \
|
||||||
b'some-vm3 class=TemplateVM state=Halted\n'
|
b'some-vm3 class=TemplateVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--template',
|
qubesadmin.tools.qvm_check.main(['--template',
|
||||||
'some-vm2', 'some-vm3'],
|
'some-vm2', 'some-vm3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
@ -17,25 +17,25 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_clone
|
import qubesadmin.tools.qvm_clone
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_clone(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_clone(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_simple(self):
|
def test_000_simple(self):
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.Clone', None,
|
self.app.expected_calls[('test-vm', 'mgmt.vm.Clone', None,
|
||||||
b'name=new-vm')] = b'0\x00'
|
b'name=new-vm')] = b'0\x00'
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n' \
|
b'0\x00new-vm class=AppVM state=Halted\n' \
|
||||||
b'test-vm class=AppVM state=Halted\n'
|
b'test-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_clone.main(['test-vm', 'new-vm'], app=self.app)
|
qubesadmin.tools.qvm_clone.main(['test-vm', 'new-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_clone.main(['test-vm'], app=self.app)
|
qubesadmin.tools.qvm_clone.main(['test-vm'], app=self.app)
|
||||||
self.assertIn('NAME', stderr.getvalue())
|
self.assertIn('NAME', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class TC_00_qvm_clone(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n' \
|
b'0\x00new-vm class=AppVM state=Halted\n' \
|
||||||
b'test-vm class=AppVM state=Halted\n'
|
b'test-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_clone.main(['-P', 'some-pool', 'test-vm', 'new-vm'],
|
qubesadmin.tools.qvm_clone.main(['-P', 'some-pool', 'test-vm', 'new-vm'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TC_00_qvm_clone(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n' \
|
b'0\x00new-vm class=AppVM state=Halted\n' \
|
||||||
b'test-vm class=AppVM state=Halted\n'
|
b'test-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_clone.main(['--pool', 'private=some-pool',
|
qubesadmin.tools.qvm_clone.main(['--pool', 'private=some-pool',
|
||||||
'--pool', 'volatile=other-pool', 'test-vm', 'new-vm'],
|
'--pool', 'volatile=other-pool', 'test-vm', 'new-vm'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
@ -17,12 +17,12 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_create
|
import qubesadmin.tools.qvm_create
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_create(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_create(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_just_appvm(self):
|
def test_000_just_appvm(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', None,
|
self.app.expected_calls[('dom0', 'mgmt.vm.Create.AppVM', None,
|
||||||
b'name=new-vm label=red')] = b'0\x00'
|
b'name=new-vm label=red')] = b'0\x00'
|
||||||
@ -30,13 +30,13 @@ class TC_00_qvm_create(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00red\nblue\n'
|
b'0\x00red\nblue\n'
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n'
|
b'0\x00new-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_create.main(['-l', 'red', 'new-vm'], app=self.app)
|
qubesadmin.tools.qvm_create.main(['-l', 'red', 'new-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_create.main(['-l', 'red'], app=self.app)
|
qubesadmin.tools.qvm_create.main(['-l', 'red'], app=self.app)
|
||||||
self.assertIn('NAME', stderr.getvalue())
|
self.assertIn('NAME', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class TC_00_qvm_create(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00red\nblue\n'
|
b'0\x00red\nblue\n'
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n'
|
b'0\x00new-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_create.main(['-l', 'red', '-t',
|
qubesadmin.tools.qvm_create.main(['-l', 'red', '-t',
|
||||||
'some-template', 'new-vm'], app=self.app)
|
'some-template', 'new-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class TC_00_qvm_create(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00new-vm class=AppVM state=Halted\n'
|
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', 'mgmt.vm.property.Set',
|
||||||
'netvm', b'sys-whonix')] = b'0\x00'
|
'netvm', b'sys-whonix')] = b'0\x00'
|
||||||
qubesmgmt.tools.qvm_create.main(['-l', 'red', '--prop',
|
qubesadmin.tools.qvm_create.main(['-l', 'red', '--prop',
|
||||||
'netvm=sys-whonix', 'new-vm'],
|
'netvm=sys-whonix', 'new-vm'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -72,7 +72,7 @@ class TC_00_qvm_create(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00red\nblue\n'
|
b'0\x00red\nblue\n'
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n'
|
b'0\x00new-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_create.main(['-l', 'red', '-P', 'some-pool',
|
qubesadmin.tools.qvm_create.main(['-l', 'red', '-P', 'some-pool',
|
||||||
'new-vm'],
|
'new-vm'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -85,7 +85,7 @@ class TC_00_qvm_create(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00red\nblue\n'
|
b'0\x00red\nblue\n'
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00new-vm class=AppVM state=Halted\n'
|
b'0\x00new-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_create.main(['-l', 'red', '--pool',
|
qubesadmin.tools.qvm_create.main(['-l', 'red', '--pool',
|
||||||
'private=some-pool', '--pool', 'volatile=other-pool', 'new-vm'],
|
'private=some-pool', '--pool', 'volatile=other-pool', 'new-vm'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
@ -24,13 +24,13 @@
|
|||||||
''' Tests for the `qvm-device` tool. '''
|
''' Tests for the `qvm-device` tool. '''
|
||||||
|
|
||||||
import unittest.mock as mock
|
import unittest.mock as mock
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.devices
|
import qubesadmin.devices
|
||||||
import qubesmgmt.tools.qvm_device
|
import qubesadmin.tools.qvm_device
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_device(qubesadmin.tests.QubesTestCase):
|
||||||
''' Tests the output logic of the qvm-device tool '''
|
''' Tests the output logic of the qvm-device tool '''
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_00_qvm_device, self).setUp()
|
super(TC_00_qvm_device, self).setUp()
|
||||||
@ -63,8 +63,8 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.List',
|
self.app.expected_calls[('test-vm3', 'mgmt.vm.device.test.List',
|
||||||
None, None)] = b'0\0'
|
None, None)] = b'0\0'
|
||||||
|
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as buf:
|
with qubesadmin.tests.tools.StdoutBuffer() as buf:
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'list'], app=self.app)
|
['test', 'list'], app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[x.rstrip() for x in buf.getvalue().splitlines()],
|
[x.rstrip() for x in buf.getvalue().splitlines()],
|
||||||
@ -89,8 +89,8 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
None, None)] = \
|
None, None)] = \
|
||||||
b'0\0test-vm1+dev1 persistent=yes\n'
|
b'0\0test-vm1+dev1 persistent=yes\n'
|
||||||
|
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as buf:
|
with qubesadmin.tests.tools.StdoutBuffer() as buf:
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'list', 'test-vm3'], app=self.app)
|
['test', 'list', 'test-vm3'], app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
buf.getvalue(),
|
buf.getvalue(),
|
||||||
@ -116,8 +116,8 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
None, None)] = \
|
None, None)] = \
|
||||||
b'0\0test-vm1+dev1\n'
|
b'0\0test-vm1+dev1\n'
|
||||||
|
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as buf:
|
with qubesadmin.tests.tools.StdoutBuffer() as buf:
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'list', 'test-vm3'], app=self.app)
|
['test', 'list', 'test-vm3'], app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
buf.getvalue(),
|
buf.getvalue(),
|
||||||
@ -128,7 +128,7 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
''' Test attach action '''
|
''' Test attach action '''
|
||||||
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach',
|
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach',
|
||||||
'test-vm1+dev1', b'')] = b'0\0'
|
'test-vm1+dev1', b'')] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'attach', 'test-vm2', 'test-vm1:dev1'], app=self.app)
|
['test', 'attach', 'test-vm2', 'test-vm1:dev1'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
''' Test attach action '''
|
''' Test attach action '''
|
||||||
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach',
|
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach',
|
||||||
'test-vm1+dev1', b'ro=True')] = b'0\0'
|
'test-vm1+dev1', b'ro=True')] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'attach', '-o', 'ro=True', 'test-vm2', 'test-vm1:dev1'],
|
['test', 'attach', '-o', 'ro=True', 'test-vm2', 'test-vm1:dev1'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -145,16 +145,16 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
''' Test attach action '''
|
''' Test attach action '''
|
||||||
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach',
|
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Attach',
|
||||||
'test-vm1+dev1', b'persistent=yes')] = b'0\0'
|
'test-vm1+dev1', b'persistent=yes')] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'attach', '-p', 'test-vm2', 'test-vm1:dev1'],
|
['test', 'attach', '-p', 'test-vm2', 'test-vm1:dev1'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_012_attach_invalid(self):
|
def test_012_attach_invalid(self):
|
||||||
''' Test attach action '''
|
''' Test attach action '''
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'attach', '-p', 'test-vm2', 'dev1'],
|
['test', 'attach', '-p', 'test-vm2', 'dev1'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertIn('expected a backend vm & device id',
|
self.assertIn('expected a backend vm & device id',
|
||||||
@ -163,9 +163,9 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_013_attach_invalid2(self):
|
def test_013_attach_invalid2(self):
|
||||||
''' Test attach action '''
|
''' Test attach action '''
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'attach', '-p', 'test-vm2', 'test-vm1:invalid'],
|
['test', 'attach', '-p', 'test-vm2', 'test-vm1:invalid'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertIn('doesn\'t expose device',
|
self.assertIn('doesn\'t expose device',
|
||||||
@ -174,9 +174,9 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_014_attach_invalid3(self):
|
def test_014_attach_invalid3(self):
|
||||||
''' Test attach action '''
|
''' Test attach action '''
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'attach', '-p', 'test-vm2', 'no-such-vm:dev3'],
|
['test', 'attach', '-p', 'test-vm2', 'no-such-vm:dev3'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertIn('no backend vm',
|
self.assertIn('no backend vm',
|
||||||
@ -187,7 +187,7 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
''' Test detach action '''
|
''' Test detach action '''
|
||||||
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Detach',
|
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Detach',
|
||||||
'test-vm1+dev1', None)] = b'0\0'
|
'test-vm1+dev1', None)] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'detach', 'test-vm2', 'test-vm1:dev1'], app=self.app)
|
['test', 'detach', 'test-vm2', 'test-vm1:dev1'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ class TC_00_qvm_device(qubesmgmt.tests.QubesTestCase):
|
|||||||
''' Test detach action '''
|
''' Test detach action '''
|
||||||
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Detach',
|
self.app.expected_calls[('test-vm2', 'mgmt.vm.device.test.Detach',
|
||||||
'test-vm1+dev7', None)] = b'0\0'
|
'test-vm1+dev7', None)] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_device.main(
|
qubesadmin.tools.qvm_device.main(
|
||||||
['test', 'detach', 'test-vm2', 'test-vm1:dev7'], app=self.app)
|
['test', 'detach', 'test-vm2', 'test-vm1:dev7'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
@ -18,11 +18,11 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tools.qvm_features
|
import qubesadmin.tools.qvm_features
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_features(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -36,9 +36,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.feature.Get', 'feature2', None)] = \
|
('some-vm', 'mgmt.vm.feature.Get', 'feature2', None)] = \
|
||||||
b'0\x00value2 with spaces'
|
b'0\x00value2 with spaces'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_features.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_features.main(['some-vm'], app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'feature1 value1\n'
|
'feature1 value1\n'
|
||||||
@ -53,7 +53,7 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
('some-vm', 'mgmt.vm.feature.Set',
|
('some-vm', 'mgmt.vm.feature.Set',
|
||||||
'feature3', 'value of feature')] = b'0\x00'
|
'feature3', 'value of feature')] = b'0\x00'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_features.main(['some-vm', 'feature3',
|
qubesadmin.tools.qvm_features.main(['some-vm', 'feature3',
|
||||||
'value of feature'],
|
'value of feature'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -66,9 +66,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.feature.Get', 'feature3', None)] = \
|
('some-vm', 'mgmt.vm.feature.Get', 'feature3', None)] = \
|
||||||
b'0\x00value2 with spaces'
|
b'0\x00value2 with spaces'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_features.main(['some-vm', 'feature3'],
|
qubesadmin.tools.qvm_features.main(['some-vm', 'feature3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
@ -82,9 +82,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.feature.Remove', 'feature4', None)] = \
|
('some-vm', 'mgmt.vm.feature.Remove', 'feature4', None)] = \
|
||||||
b'0\x00'
|
b'0\x00'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_features.main(['--unset', 'some-vm',
|
qubesadmin.tools.qvm_features.main(['--unset', 'some-vm',
|
||||||
'feature4'],
|
'feature4'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -101,9 +101,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.List', None, None)] = \
|
('some-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'some-vm'], app=self.app),
|
'some-vm'], app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
@ -122,9 +122,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm2 class=AppVM state=Running\n'
|
b'0\x00some-vm2 class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'some-vm', 'some-vm2'],
|
'some-vm', 'some-vm2'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -147,9 +147,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'--all'],
|
'--all'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -166,9 +166,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
('some-vm3', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
b'0\x00some-vm3 class=AppVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--running',
|
qubesadmin.tools.qvm_check.main(['--running',
|
||||||
'some-vm3'],
|
'some-vm3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
1)
|
1)
|
||||||
@ -185,9 +185,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
('some-vm2', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm2 class=AppVM state=Paused\n'
|
b'0\x00some-vm2 class=AppVM state=Paused\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--paused',
|
qubesadmin.tools.qvm_check.main(['--paused',
|
||||||
'some-vm2'],
|
'some-vm2'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -207,9 +207,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.List', None, None)] = \
|
('some-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--paused',
|
qubesadmin.tools.qvm_check.main(['--paused',
|
||||||
'some-vm2', 'some-vm'],
|
'some-vm2', 'some-vm'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -224,9 +224,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'some-vm2 class=AppVM state=Paused\n' \
|
b'some-vm2 class=AppVM state=Paused\n' \
|
||||||
b'some-vm3 class=TemplateVM state=Halted\n'
|
b'some-vm3 class=TemplateVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--template',
|
qubesadmin.tools.qvm_check.main(['--template',
|
||||||
'some-vm3'],
|
'some-vm3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
@ -240,9 +240,9 @@ class TC_00_qvm_features(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'some-vm2 class=AppVM state=Paused\n' \
|
b'some-vm2 class=AppVM state=Paused\n' \
|
||||||
b'some-vm3 class=TemplateVM state=Halted\n'
|
b'some-vm3 class=TemplateVM state=Halted\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_check.main(['--template',
|
qubesadmin.tools.qvm_check.main(['--template',
|
||||||
'some-vm2', 'some-vm3'],
|
'some-vm2', 'some-vm3'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
@ -22,30 +22,30 @@
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import qubesmgmt.firewall
|
import qubesadmin.firewall
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_firewall
|
import qubesadmin.tools.qvm_firewall
|
||||||
|
|
||||||
|
|
||||||
class TC_00_RuleAction(qubesmgmt.tests.QubesTestCase):
|
class TC_00_RuleAction(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_00_RuleAction, self).setUp()
|
super(TC_00_RuleAction, self).setUp()
|
||||||
self.action = qubesmgmt.tools.qvm_firewall.RuleAction(
|
self.action = qubesadmin.tools.qvm_firewall.RuleAction(
|
||||||
None, dest='rule')
|
None, dest='rule')
|
||||||
|
|
||||||
def test_000_named_opts(self):
|
def test_000_named_opts(self):
|
||||||
ns = argparse.Namespace()
|
ns = argparse.Namespace()
|
||||||
self.action(None, ns, ['dsthost=127.0.0.1', 'action=accept'])
|
self.action(None, ns, ['dsthost=127.0.0.1', 'action=accept'])
|
||||||
self.assertEqual(ns.rule,
|
self.assertEqual(ns.rule,
|
||||||
qubesmgmt.firewall.Rule(
|
qubesadmin.firewall.Rule(
|
||||||
None, action='accept', dsthost='127.0.0.1/32'))
|
None, action='accept', dsthost='127.0.0.1/32'))
|
||||||
|
|
||||||
def test_001_unnamed_opts(self):
|
def test_001_unnamed_opts(self):
|
||||||
ns = argparse.Namespace()
|
ns = argparse.Namespace()
|
||||||
self.action(None, ns, ['accept', '127.0.0.1', 'tcp', '80'])
|
self.action(None, ns, ['accept', '127.0.0.1', 'tcp', '80'])
|
||||||
self.assertEqual(ns.rule,
|
self.assertEqual(ns.rule,
|
||||||
qubesmgmt.firewall.Rule(
|
qubesadmin.firewall.Rule(
|
||||||
None, action='accept', dsthost='127.0.0.1/32',
|
None, action='accept', dsthost='127.0.0.1/32',
|
||||||
proto='tcp', dstports=80))
|
proto='tcp', dstports=80))
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class TC_00_RuleAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
ns = argparse.Namespace()
|
ns = argparse.Namespace()
|
||||||
self.action(None, ns, ['accept', '127.0.0.1', 'icmp', '8'])
|
self.action(None, ns, ['accept', '127.0.0.1', 'icmp', '8'])
|
||||||
self.assertEqual(ns.rule,
|
self.assertEqual(ns.rule,
|
||||||
qubesmgmt.firewall.Rule(
|
qubesadmin.firewall.Rule(
|
||||||
None, action='accept', dsthost='127.0.0.1/32',
|
None, action='accept', dsthost='127.0.0.1/32',
|
||||||
proto='icmp', icmptype=8))
|
proto='icmp', icmptype=8))
|
||||||
|
|
||||||
@ -62,12 +62,12 @@ class TC_00_RuleAction(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.action(None, ns, ['dsthost=127.0.0.1', 'accept',
|
self.action(None, ns, ['dsthost=127.0.0.1', 'accept',
|
||||||
'dstports=443', 'tcp'])
|
'dstports=443', 'tcp'])
|
||||||
self.assertEqual(ns.rule,
|
self.assertEqual(ns.rule,
|
||||||
qubesmgmt.firewall.Rule(
|
qubesadmin.firewall.Rule(
|
||||||
None, action='accept', dsthost='127.0.0.1/32',
|
None, action='accept', dsthost='127.0.0.1/32',
|
||||||
proto='tcp', dstports=443))
|
proto='tcp', dstports=443))
|
||||||
|
|
||||||
|
|
||||||
class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
class TC_10_qvm_firewall(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_10_qvm_firewall, self).setUp()
|
super(TC_10_qvm_firewall, self).setUp()
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -78,8 +78,8 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
None, None)] = \
|
None, None)] = \
|
||||||
b'0\0action=accept dsthost=qubes-os.org\n' \
|
b'0\0action=accept dsthost=qubes-os.org\n' \
|
||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_firewall.main(['test-vm', 'list'], app=self.app)
|
qubesadmin.tools.qvm_firewall.main(['test-vm', 'list'], app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[l.strip() for l in stdout.getvalue().splitlines()],
|
[l.strip() for l in stdout.getvalue().splitlines()],
|
||||||
['NO ACTION HOST PROTOCOL PORT(S) SPECIAL '
|
['NO ACTION HOST PROTOCOL PORT(S) SPECIAL '
|
||||||
@ -97,8 +97,8 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'dstports=443-443\n' \
|
b'dstports=443-443\n' \
|
||||||
b'action=drop proto=icmp icmptype=8\n' \
|
b'action=drop proto=icmp icmptype=8\n' \
|
||||||
b'action=accept specialtarget=dns comment=Allow DNS\n'
|
b'action=accept specialtarget=dns comment=Allow DNS\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_firewall.main(['test-vm', 'list'], app=self.app)
|
qubesadmin.tools.qvm_firewall.main(['test-vm', 'list'], app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[l.strip() for l in stdout.getvalue().splitlines()],
|
[l.strip() for l in stdout.getvalue().splitlines()],
|
||||||
['NO ACTION HOST PROTOCOL PORT(S) SPECIAL '
|
['NO ACTION HOST PROTOCOL PORT(S) SPECIAL '
|
||||||
@ -116,8 +116,8 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
None, None)] = \
|
None, None)] = \
|
||||||
b'0\0action=accept dsthost=qubes-os.org\n' \
|
b'0\0action=accept dsthost=qubes-os.org\n' \
|
||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_firewall.main(['test-vm', '--raw', 'list'],
|
qubesadmin.tools.qvm_firewall.main(['test-vm', '--raw', 'list'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[l.strip() for l in stdout.getvalue().splitlines()],
|
[l.strip() for l in stdout.getvalue().splitlines()],
|
||||||
@ -132,8 +132,8 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Reload',
|
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Reload',
|
||||||
None, None)] = b'0\0'
|
None, None)] = b'0\0'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', '--raw', '--reload', 'list'],
|
['test-vm', '--raw', '--reload', 'list'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
@ -152,7 +152,7 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
b'action=accept dst4=192.168.0.0/24 comment=Allow LAN\n')] = \
|
b'action=accept dst4=192.168.0.0/24 comment=Allow LAN\n')] = \
|
||||||
b'0\0'
|
b'0\0'
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', 'add', 'accept', '192.168.0.0/24', 'comment=Allow LAN'],
|
['test-vm', 'add', 'accept', '192.168.0.0/24', 'comment=Allow LAN'],
|
||||||
app=self.app
|
app=self.app
|
||||||
)
|
)
|
||||||
@ -166,7 +166,7 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'action=accept dsthost=qubes-os.org\n'
|
b'action=accept dsthost=qubes-os.org\n'
|
||||||
b'action=accept dst4=192.168.0.0/24 comment=Allow LAN\n'
|
b'action=accept dst4=192.168.0.0/24 comment=Allow LAN\n'
|
||||||
b'action=drop proto=icmp\n')] = b'0\0'
|
b'action=drop proto=icmp\n')] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', 'add', '--before', '1', 'accept', '192.168.0.0/24',
|
['test-vm', 'add', '--before', '1', 'accept', '192.168.0.0/24',
|
||||||
'comment=Allow LAN'],
|
'comment=Allow LAN'],
|
||||||
app=self.app
|
app=self.app
|
||||||
@ -179,7 +179,7 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None,
|
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None,
|
||||||
b'action=accept dsthost=qubes-os.org\n')] = b'0\0'
|
b'action=accept dsthost=qubes-os.org\n')] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', 'del', '--rule-no', '1'],
|
['test-vm', 'del', '--rule-no', '1'],
|
||||||
app=self.app
|
app=self.app
|
||||||
)
|
)
|
||||||
@ -191,7 +191,7 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'action=drop proto=icmp\n'
|
b'action=drop proto=icmp\n'
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None,
|
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.Set', None,
|
||||||
b'action=accept dsthost=qubes-os.org\n')] = b'0\0'
|
b'action=accept dsthost=qubes-os.org\n')] = b'0\0'
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', 'del', 'drop', 'proto=icmp'],
|
['test-vm', 'del', 'drop', 'proto=icmp'],
|
||||||
app=self.app
|
app=self.app
|
||||||
)
|
)
|
||||||
@ -199,8 +199,8 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_030_policy_get(self):
|
def test_030_policy_get(self):
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.GetPolicy',
|
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.GetPolicy',
|
||||||
None, None)] = b'0\0accept'
|
None, None)] = b'0\0accept'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', 'policy'],
|
['test-vm', 'policy'],
|
||||||
app=self.app
|
app=self.app
|
||||||
)
|
)
|
||||||
@ -209,8 +209,8 @@ class TC_10_qvm_firewall(qubesmgmt.tests.QubesTestCase):
|
|||||||
def test_031_policy_set(self):
|
def test_031_policy_set(self):
|
||||||
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy',
|
self.app.expected_calls[('test-vm', 'mgmt.vm.firewall.SetPolicy',
|
||||||
None, b'accept')] = b'0\0'
|
None, b'accept')] = b'0\0'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_firewall.main(
|
qubesadmin.tools.qvm_firewall.main(
|
||||||
['test-vm', 'policy', 'accept'],
|
['test-vm', 'policy', 'accept'],
|
||||||
app=self.app
|
app=self.app
|
||||||
)
|
)
|
@ -18,25 +18,25 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_kill
|
import qubesadmin.tools.qvm_kill
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_kill(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_with_vm(self):
|
def test_000_with_vm(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.Kill', None, None)] = b'0\x00'
|
('some-vm', 'mgmt.vm.Kill', None, None)] = b'0\x00'
|
||||||
qubesmgmt.tools.qvm_kill.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_kill.main([], app=self.app)
|
qubesadmin.tools.qvm_kill.main([], app=self.app)
|
||||||
self.assertIn('one of the arguments --all VMNAME is required',
|
self.assertIn('one of the arguments --all VMNAME is required',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -46,8 +46,8 @@ class TC_00_qvm_kill(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_kill.main(['no-such-vm'], app=self.app)
|
qubesadmin.tools.qvm_kill.main(['no-such-vm'], app=self.app)
|
||||||
self.assertIn('no such domain', stderr.getvalue())
|
self.assertIn('no such domain', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class TC_00_qvm_kill(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_kill.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app),
|
||||||
1)
|
1)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
@ -20,14 +20,14 @@
|
|||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
import qubesmgmt.tools.qvm_ls
|
import qubesadmin.tools.qvm_ls
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
|
|
||||||
from qubesmgmt.tests import TestVM, TestVMCollection
|
from qubesadmin.tests import TestVM, TestVMCollection
|
||||||
|
|
||||||
|
|
||||||
class TestApp(object):
|
class TestApp(object):
|
||||||
@ -39,21 +39,21 @@ class TestApp(object):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
class TC_00_Column(qubesmgmt.tests.QubesTestCase):
|
class TC_00_Column(qubesadmin.tests.QubesTestCase):
|
||||||
def test_100_init(self):
|
def test_100_init(self):
|
||||||
try:
|
try:
|
||||||
testcolumn = qubesmgmt.tools.qvm_ls.Column('TESTCOLUMN')
|
testcolumn = qubesadmin.tools.qvm_ls.Column('TESTCOLUMN')
|
||||||
self.assertEqual(testcolumn.ls_head, 'TESTCOLUMN')
|
self.assertEqual(testcolumn.ls_head, 'TESTCOLUMN')
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
qubesmgmt.tools.qvm_ls.Column.columns['TESTCOLUMN']
|
qubesadmin.tools.qvm_ls.Column.columns['TESTCOLUMN']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TC_10_globals(qubesmgmt.tests.QubesTestCase):
|
class TC_10_globals(qubesadmin.tests.QubesTestCase):
|
||||||
def test_100_simple_flag(self):
|
def test_100_simple_flag(self):
|
||||||
flag = qubesmgmt.tools.qvm_ls.simple_flag(1, 'T', 'internal')
|
flag = qubesadmin.tools.qvm_ls.simple_flag(1, 'T', 'internal')
|
||||||
|
|
||||||
# TODO after serious testing of QubesVM and Qubes app, this should be
|
# TODO after serious testing of QubesVM and Qubes app, this should be
|
||||||
# using normal components
|
# using normal components
|
||||||
@ -65,12 +65,12 @@ class TC_10_globals(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
@unittest.skip('column list generated dynamically')
|
@unittest.skip('column list generated dynamically')
|
||||||
def test_900_formats_columns(self):
|
def test_900_formats_columns(self):
|
||||||
for fmt in qubesmgmt.tools.qvm_ls.formats:
|
for fmt in qubesadmin.tools.qvm_ls.formats:
|
||||||
for col in qubesmgmt.tools.qvm_ls.formats[fmt]:
|
for col in qubesadmin.tools.qvm_ls.formats[fmt]:
|
||||||
self.assertIn(col.upper(), qubesmgmt.tools.qvm_ls.Column.columns)
|
self.assertIn(col.upper(), qubesadmin.tools.qvm_ls.Column.columns)
|
||||||
|
|
||||||
|
|
||||||
class TC_50_List(qubesmgmt.tests.QubesTestCase):
|
class TC_50_List(qubesadmin.tests.QubesTestCase):
|
||||||
def test_100_list_with_status(self):
|
def test_100_list_with_status(self):
|
||||||
app = TestApp()
|
app = TestApp()
|
||||||
app.domains['test-vm'].internal = False
|
app.domains['test-vm'].internal = False
|
||||||
@ -79,15 +79,15 @@ class TC_50_List(qubesmgmt.tests.QubesTestCase):
|
|||||||
app.domains['test-vm'].netvm = TestVM('sys-net')
|
app.domains['test-vm'].netvm = TestVM('sys-net')
|
||||||
app.domains['test-vm'].label = 'green'
|
app.domains['test-vm'].label = 'green'
|
||||||
app.domains['dom0'].label = 'black'
|
app.domains['dom0'].label = 'black'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_ls.main([], app=app)
|
qubesadmin.tools.qvm_ls.main([], app=app)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'NAME STATUS LABEL TEMPLATE NETVM\n'
|
'NAME STATUS LABEL TEMPLATE NETVM\n'
|
||||||
'dom0 -r------ black - -\n'
|
'dom0 -r------ black - -\n'
|
||||||
'test-vm -r------ green template sys-net\n')
|
'test-vm -r------ green template sys-net\n')
|
||||||
|
|
||||||
|
|
||||||
class TC_90_List_with_qubesd_calls(qubesmgmt.tests.QubesTestCase):
|
class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
|
||||||
def test_100_list_with_status(self):
|
def test_100_list_with_status(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -143,8 +143,8 @@ class TC_90_List_with_qubesd_calls(qubesmgmt.tests.QubesTestCase):
|
|||||||
('sys-net', 'mgmt.vm.property.Get', key, None)] = \
|
('sys-net', 'mgmt.vm.property.Get', key, None)] = \
|
||||||
b'0\x00default=True ' + value
|
b'0\x00default=True ' + value
|
||||||
|
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
qubesmgmt.tools.qvm_ls.main([], app=self.app)
|
qubesadmin.tools.qvm_ls.main([], app=self.app)
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'NAME STATUS LABEL TEMPLATE NETVM\n'
|
'NAME STATUS LABEL TEMPLATE NETVM\n'
|
||||||
'sys-net ar-N---- red template1 sys-net\n'
|
'sys-net ar-N---- red template1 sys-net\n'
|
@ -18,25 +18,25 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_pause
|
import qubesadmin.tools.qvm_pause
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_pause(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_pause(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_with_vm(self):
|
def test_000_with_vm(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.Pause', None, None)] = b'0\x00'
|
('some-vm', 'mgmt.vm.Pause', None, None)] = b'0\x00'
|
||||||
qubesmgmt.tools.qvm_pause.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_pause.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_pause.main([], app=self.app)
|
qubesadmin.tools.qvm_pause.main([], app=self.app)
|
||||||
self.assertIn('one of the arguments --all VMNAME is required',
|
self.assertIn('one of the arguments --all VMNAME is required',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -46,8 +46,8 @@ class TC_00_qvm_pause(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_pause.main(['no-such-vm'], app=self.app)
|
qubesadmin.tools.qvm_pause.main(['no-such-vm'], app=self.app)
|
||||||
self.assertIn('no such domain', stderr.getvalue())
|
self.assertIn('no such domain', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class TC_00_qvm_pause(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_pause.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_pause.main(['some-vm'], app=self.app),
|
||||||
1)
|
1)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class TC_00_qvm_pause(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'other-vm class=AppVM state=Running\n'
|
b'other-vm class=AppVM state=Running\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_pause.main(['some-vm', 'other-vm'],
|
qubesadmin.tools.qvm_pause.main(['some-vm', 'other-vm'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
@ -18,12 +18,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_pool
|
import qubesadmin.tools.qvm_pool
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_pool(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_pool(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.pool.List', None, None)] = \
|
||||||
b'0\x00pool-file\npool-lvm\n'
|
b'0\x00pool-file\npool-lvm\n'
|
||||||
@ -33,9 +33,9 @@ class TC_00_qvm_pool(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.pool.Info', 'pool-lvm', None)] = \
|
('dom0', 'mgmt.pool.Info', 'pool-lvm', None)] = \
|
||||||
b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n'
|
b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_pool.main(['-l'], app=self.app))
|
qubesadmin.tools.qvm_pool.main(['-l'], app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'NAME DRIVER\n'
|
'NAME DRIVER\n'
|
||||||
'pool-file file\n'
|
'pool-file file\n'
|
||||||
@ -47,9 +47,9 @@ class TC_00_qvm_pool(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.pool.ListDrivers', None, None)] = \
|
('dom0', 'mgmt.pool.ListDrivers', None, None)] = \
|
||||||
b'0\x00file dir_path revisions_to_keep\n' \
|
b'0\x00file dir_path revisions_to_keep\n' \
|
||||||
b'lvm volume_group thin_pool revisions_to_keep\n'
|
b'lvm volume_group thin_pool revisions_to_keep\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_pool.main(['--help-drivers'], app=self.app))
|
qubesadmin.tools.qvm_pool.main(['--help-drivers'], app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'DRIVER OPTIONS\n'
|
'DRIVER OPTIONS\n'
|
||||||
'file dir_path, revisions_to_keep\n'
|
'file dir_path, revisions_to_keep\n'
|
||||||
@ -62,7 +62,7 @@ class TC_00_qvm_pool(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.pool.Add', 'file',
|
('dom0', 'mgmt.pool.Add', 'file',
|
||||||
b'name=test-pool\ndir_path=/some/path\n')] = b'0\x00'
|
b'name=test-pool\ndir_path=/some/path\n')] = b'0\x00'
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_pool.main(
|
qubesadmin.tools.qvm_pool.main(
|
||||||
['--add', 'test-pool', 'file', '-o', 'dir_path=/some/path'],
|
['--add', 'test-pool', 'file', '-o', 'dir_path=/some/path'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -71,7 +71,7 @@ class TC_00_qvm_pool(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.pool.Remove', 'test-pool', None)] = b'0\x00'
|
('dom0', 'mgmt.pool.Remove', 'test-pool', None)] = b'0\x00'
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_pool.main(['--remove', 'test-pool'],
|
qubesadmin.tools.qvm_pool.main(['--remove', 'test-pool'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -81,9 +81,9 @@ class TC_00_qvm_pool(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.pool.Info', 'pool-lvm', None)] = \
|
('dom0', 'mgmt.pool.Info', 'pool-lvm', None)] = \
|
||||||
b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n'
|
b'0\x00driver=lvm\nvolume_group=qubes_dom0\nthin_pool=pool00\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_pool.main(['-i', 'pool-lvm'],
|
qubesadmin.tools.qvm_pool.main(['-i', 'pool-lvm'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'name pool-lvm\n'
|
'name pool-lvm\n'
|
@ -19,12 +19,12 @@
|
|||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_prefs
|
import qubesadmin.tools.qvm_prefs
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_prefs(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_prefs(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -38,8 +38,8 @@ class TC_00_qvm_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.property.Get', 'prop2', None)] = \
|
('dom0', 'mgmt.vm.property.Get', 'prop2', None)] = \
|
||||||
b'0\x00default=False type=str value2'
|
b'0\x00default=False type=str value2'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0, qubesmgmt.tools.qvm_prefs.main([
|
self.assertEqual(0, qubesadmin.tools.qvm_prefs.main([
|
||||||
'dom0'], app=self.app))
|
'dom0'], app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'prop1 D value1\n'
|
'prop1 D value1\n'
|
||||||
@ -48,8 +48,8 @@ class TC_00_qvm_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_001_no_vm(self):
|
def test_001_no_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_prefs.main([], app=self.app)
|
qubesadmin.tools.qvm_prefs.main([], app=self.app)
|
||||||
if sys.version_info[0] == 2:
|
if sys.version_info[0] == 2:
|
||||||
self.assertIn('too few arguments', stderr.getvalue())
|
self.assertIn('too few arguments', stderr.getvalue())
|
||||||
else:
|
else:
|
||||||
@ -64,7 +64,7 @@ class TC_00_qvm_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.property.Set', 'default_user', b'testuser')] = \
|
('dom0', 'mgmt.vm.property.Set', 'default_user', b'testuser')] = \
|
||||||
b'0\x00'
|
b'0\x00'
|
||||||
self.assertEqual(0, qubesmgmt.tools.qvm_prefs.main([
|
self.assertEqual(0, qubesadmin.tools.qvm_prefs.main([
|
||||||
'dom0', 'default_user', 'testuser'], app=self.app))
|
'dom0', 'default_user', 'testuser'], app=self.app))
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -76,8 +76,8 @@ class TC_00_qvm_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.property.Get', 'no_such_property', None)] = \
|
('dom0', 'mgmt.vm.property.Get', 'no_such_property', None)] = \
|
||||||
b'2\x00AttributeError\x00\x00no_such_property\x00'
|
b'2\x00AttributeError\x00\x00no_such_property\x00'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_prefs.main([
|
qubesadmin.tools.qvm_prefs.main([
|
||||||
'dom0', 'no_such_property'], app=self.app)
|
'dom0', 'no_such_property'], app=self.app)
|
||||||
self.assertIn('no such property: \'no_such_property\'',
|
self.assertIn('no such property: \'no_such_property\'',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
@ -91,8 +91,8 @@ class TC_00_qvm_prefs(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.property.Set', 'no_such_property', b'value')] = \
|
('dom0', 'mgmt.vm.property.Set', 'no_such_property', b'value')] = \
|
||||||
b'2\x00AttributeError\x00\x00no_such_property\x00'
|
b'2\x00AttributeError\x00\x00no_such_property\x00'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_prefs.main([
|
qubesadmin.tools.qvm_prefs.main([
|
||||||
'dom0', 'no_such_property', 'value'], app=self.app)
|
'dom0', 'no_such_property', 'value'], app=self.app)
|
||||||
self.assertIn('no such property: \'no_such_property\'',
|
self.assertIn('no such property: \'no_such_property\'',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
@ -18,12 +18,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_remove
|
import qubesadmin.tools.qvm_remove
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_remove(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_remove(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_single(self):
|
def test_000_single(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
@ -31,5 +31,5 @@ class TC_00_qvm_remove(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.Remove', None, None)] = \
|
('some-vm', 'mgmt.vm.Remove', None, None)] = \
|
||||||
b'0\x00\n'
|
b'0\x00\n'
|
||||||
qubesmgmt.tools.qvm_remove.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_remove.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
@ -24,11 +24,11 @@ import unittest.mock
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tools.qvm_run
|
import qubesadmin.tools.qvm_run
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_run(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
if sys.stdout is not sys.__stdout__ or \
|
if sys.stdout is not sys.__stdout__ or \
|
||||||
sys.stderr is not sys.__stderr__:
|
sys.stderr is not sys.__stderr__:
|
||||||
@ -41,7 +41,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
# self.app.expected_calls[
|
# self.app.expected_calls[
|
||||||
# ('test-vm', 'mgmt.vm.List', None, None)] = \
|
# ('test-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
# b'0\x00test-vm class=AppVM state=Running\n'
|
# b'0\x00test-vm class=AppVM state=Running\n'
|
||||||
ret = qubesmgmt.tools.qvm_run.main(['test-vm', 'command'], app=self.app)
|
ret = qubesadmin.tools.qvm_run.main(['test-vm', 'command'], app=self.app)
|
||||||
self.assertEqual(ret, 0)
|
self.assertEqual(ret, 0)
|
||||||
# make sure we have the same instance below
|
# make sure we have the same instance below
|
||||||
null = self.app.service_calls[0][2]['stdout']
|
null = self.app.service_calls[0][2]['stdout']
|
||||||
@ -66,7 +66,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
# self.app.expected_calls[
|
# self.app.expected_calls[
|
||||||
# ('test-vm', 'mgmt.vm.List', None, None)] = \
|
# ('test-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
# b'0\x00test-vm class=AppVM state=Running\n'
|
# b'0\x00test-vm class=AppVM state=Running\n'
|
||||||
ret = qubesmgmt.tools.qvm_run.main(['test-vm', 'test-vm2', 'command'],
|
ret = qubesadmin.tools.qvm_run.main(['test-vm', 'test-vm2', 'command'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
self.assertEqual(ret, 0)
|
self.assertEqual(ret, 0)
|
||||||
for i in range(0, len(self.app.service_calls), 2):
|
for i in range(0, len(self.app.service_calls), 2):
|
||||||
@ -106,7 +106,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
# b'0\x00test-vm class=AppVM state=Running\n'
|
# b'0\x00test-vm class=AppVM state=Running\n'
|
||||||
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
||||||
with unittest.mock.patch('sys.stdin', echo.stdout):
|
with unittest.mock.patch('sys.stdin', echo.stdout):
|
||||||
ret = qubesmgmt.tools.qvm_run.main(
|
ret = qubesadmin.tools.qvm_run.main(
|
||||||
['--pass-io', 'test-vm', 'command'],
|
['--pass-io', 'test-vm', 'command'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
||||||
with unittest.mock.patch('sys.stdin', echo.stdout):
|
with unittest.mock.patch('sys.stdin', echo.stdout):
|
||||||
with unittest.mock.patch('sys.stdout', stdout):
|
with unittest.mock.patch('sys.stdout', stdout):
|
||||||
ret = qubesmgmt.tools.qvm_run.main(
|
ret = qubesadmin.tools.qvm_run.main(
|
||||||
['--pass-io', 'test-vm', 'command'],
|
['--pass-io', 'test-vm', 'command'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
||||||
with unittest.mock.patch('sys.stdin', echo.stdout):
|
with unittest.mock.patch('sys.stdin', echo.stdout):
|
||||||
with unittest.mock.patch('sys.stdout', stdout):
|
with unittest.mock.patch('sys.stdout', stdout):
|
||||||
ret = qubesmgmt.tools.qvm_run.main(
|
ret = qubesadmin.tools.qvm_run.main(
|
||||||
['--pass-io', '--no-color-output', 'test-vm', 'command'],
|
['--pass-io', '--no-color-output', 'test-vm', 'command'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
echo = subprocess.Popen(['echo', 'some-data'], stdout=subprocess.PIPE)
|
||||||
with unittest.mock.patch('sys.stdin', echo.stdout):
|
with unittest.mock.patch('sys.stdin', echo.stdout):
|
||||||
with unittest.mock.patch('sys.stdout', stdout):
|
with unittest.mock.patch('sys.stdout', stdout):
|
||||||
ret = qubesmgmt.tools.qvm_run.main(
|
ret = qubesadmin.tools.qvm_run.main(
|
||||||
['--pass-io', '--no-filter-esc', 'test-vm', 'command'],
|
['--pass-io', '--no-filter-esc', 'test-vm', 'command'],
|
||||||
app=self.app)
|
app=self.app)
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ class TC_00_qvm_run(qubesmgmt.tests.QubesTestCase):
|
|||||||
# self.app.expected_calls[
|
# self.app.expected_calls[
|
||||||
# ('test-vm', 'mgmt.vm.List', None, None)] = \
|
# ('test-vm', 'mgmt.vm.List', None, None)] = \
|
||||||
# b'0\x00test-vm class=AppVM state=Running\n'
|
# b'0\x00test-vm class=AppVM state=Running\n'
|
||||||
ret = qubesmgmt.tools.qvm_run.main(
|
ret = qubesadmin.tools.qvm_run.main(
|
||||||
['--pass-io', '--localcmd', 'local-command',
|
['--pass-io', '--localcmd', 'local-command',
|
||||||
'test-vm', 'command'],
|
'test-vm', 'command'],
|
||||||
app=self.app)
|
app=self.app)
|
@ -18,24 +18,24 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tools.qvm_shutdown
|
import qubesadmin.tools.qvm_shutdown
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_shutdown(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_with_vm(self):
|
def test_000_with_vm(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.Shutdown', None, None)] = b'0\x00'
|
('some-vm', 'mgmt.vm.Shutdown', None, None)] = b'0\x00'
|
||||||
qubesmgmt.tools.qvm_shutdown.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_shutdown.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_shutdown.main([], app=self.app)
|
qubesadmin.tools.qvm_shutdown.main([], app=self.app)
|
||||||
self.assertIn('one of the arguments --all VMNAME is required',
|
self.assertIn('one of the arguments --all VMNAME is required',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -45,8 +45,8 @@ class TC_00_qvm_shutdown(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_shutdown.main(['no-such-vm'], app=self.app)
|
qubesadmin.tools.qvm_shutdown.main(['no-such-vm'], app=self.app)
|
||||||
self.assertIn('no such domain', stderr.getvalue())
|
self.assertIn('no such domain', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class TC_00_qvm_shutdown(qubesmgmt.tests.QubesTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||||
qubesmgmt.tools.qvm_shutdown.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_shutdown.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_004_multiple_vms(self):
|
def test_004_multiple_vms(self):
|
||||||
@ -73,7 +73,7 @@ class TC_00_qvm_shutdown(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'other-vm class=AppVM state=Running\n'
|
b'other-vm class=AppVM state=Running\n'
|
||||||
qubesmgmt.tools.qvm_shutdown.main(['some-vm', 'other-vm'], app=self.app),
|
qubesadmin.tools.qvm_shutdown.main(['some-vm', 'other-vm'], app=self.app),
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_010_wait(self):
|
def test_010_wait(self):
|
@ -18,25 +18,25 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_start
|
import qubesadmin.tools.qvm_start
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_start(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_with_vm(self):
|
def test_000_with_vm(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.Start', None, None)] = b'0\x00'
|
('some-vm', 'mgmt.vm.Start', None, None)] = b'0\x00'
|
||||||
qubesmgmt.tools.qvm_start.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_start.main([], app=self.app)
|
qubesadmin.tools.qvm_start.main([], app=self.app)
|
||||||
self.assertIn('one of the arguments --all VMNAME is required',
|
self.assertIn('one of the arguments --all VMNAME is required',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -46,8 +46,8 @@ class TC_00_qvm_start(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_start.main(['no-such-vm'], app=self.app)
|
qubesadmin.tools.qvm_start.main(['no-such-vm'], app=self.app)
|
||||||
self.assertIn('no such domain', stderr.getvalue())
|
self.assertIn('no such domain', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class TC_00_qvm_start(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_start.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app),
|
||||||
1)
|
1)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
@ -23,14 +23,14 @@ import unittest.mock
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tools.qvm_start_gui
|
import qubesadmin.tools.qvm_start_gui
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_start_gui(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TC_00_qvm_start_gui, self).setUp()
|
super(TC_00_qvm_start_gui, self).setUp()
|
||||||
self.launcher = qubesmgmt.tools.qvm_start_gui.GUILauncher(self.app)
|
self.launcher = qubesadmin.tools.qvm_start_gui.GUILauncher(self.app)
|
||||||
|
|
||||||
@unittest.mock.patch('subprocess.check_output')
|
@unittest.mock.patch('subprocess.check_output')
|
||||||
def test_000_kde_args(self, proc_mock):
|
def test_000_kde_args(self, proc_mock):
|
||||||
@ -329,7 +329,7 @@ HDMI2 disconnected (normal left inverted right x axis y axis)
|
|||||||
VGA1 disconnected (normal left inverted right x axis y axis)
|
VGA1 disconnected (normal left inverted right x axis y axis)
|
||||||
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
|
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
|
||||||
'''.splitlines()
|
'''.splitlines()
|
||||||
self.assertEqual(qubesmgmt.tools.qvm_start_gui.get_monitor_layout(),
|
self.assertEqual(qubesadmin.tools.qvm_start_gui.get_monitor_layout(),
|
||||||
['1920 1200 0 0\n'])
|
['1920 1200 0 0\n'])
|
||||||
|
|
||||||
@unittest.mock.patch('subprocess.Popen')
|
@unittest.mock.patch('subprocess.Popen')
|
||||||
@ -338,7 +338,7 @@ VIRTUAL1 disconnected (normal left inverted right x axis y axis)
|
|||||||
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis)
|
LVDS1 connected 1600x900+0+0 (normal left inverted right x axis y axis)
|
||||||
VGA1 connected 1280x1024+1600+0 (normal left inverted right x axis y axis)
|
VGA1 connected 1280x1024+1600+0 (normal left inverted right x axis y axis)
|
||||||
'''.splitlines()
|
'''.splitlines()
|
||||||
self.assertEqual(qubesmgmt.tools.qvm_start_gui.get_monitor_layout(),
|
self.assertEqual(qubesadmin.tools.qvm_start_gui.get_monitor_layout(),
|
||||||
['1600 900 0 0\n', '1280 1024 1600 0\n'])
|
['1600 900 0 0\n', '1280 1024 1600 0\n'])
|
||||||
|
|
||||||
@unittest.mock.patch('subprocess.Popen')
|
@unittest.mock.patch('subprocess.Popen')
|
||||||
@ -348,7 +348,7 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 372mm x
|
|||||||
1920x1200 60.00*+
|
1920x1200 60.00*+
|
||||||
'''.splitlines()
|
'''.splitlines()
|
||||||
dpi = 150
|
dpi = 150
|
||||||
self.assertEqual(qubesmgmt.tools.qvm_start_gui.get_monitor_layout(),
|
self.assertEqual(qubesadmin.tools.qvm_start_gui.get_monitor_layout(),
|
||||||
['2560 1920 0 0 {} {}\n'.format(
|
['2560 1920 0 0 {} {}\n'.format(
|
||||||
int(2560/dpi*254/10), int(1920/dpi*254/10))])
|
int(2560/dpi*254/10), int(1920/dpi*254/10))])
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 310mm x
|
|||||||
1920x1200 60.00*+
|
1920x1200 60.00*+
|
||||||
'''.splitlines()
|
'''.splitlines()
|
||||||
dpi = 200
|
dpi = 200
|
||||||
self.assertEqual(qubesmgmt.tools.qvm_start_gui.get_monitor_layout(),
|
self.assertEqual(qubesadmin.tools.qvm_start_gui.get_monitor_layout(),
|
||||||
['2560 1920 0 0 {} {}\n'.format(
|
['2560 1920 0 0 {} {}\n'.format(
|
||||||
int(2560/dpi*254/10), int(1920/dpi*254/10))])
|
int(2560/dpi*254/10), int(1920/dpi*254/10))])
|
||||||
|
|
||||||
@ -370,6 +370,6 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
|
|||||||
1920x1200 60.00*+
|
1920x1200 60.00*+
|
||||||
'''.splitlines()
|
'''.splitlines()
|
||||||
dpi = 300
|
dpi = 300
|
||||||
self.assertEqual(qubesmgmt.tools.qvm_start_gui.get_monitor_layout(),
|
self.assertEqual(qubesadmin.tools.qvm_start_gui.get_monitor_layout(),
|
||||||
['2560 1920 0 0 {} {}\n'.format(
|
['2560 1920 0 0 {} {}\n'.format(
|
||||||
int(2560/dpi*254/10), int(1920/dpi*254/10))])
|
int(2560/dpi*254/10), int(1920/dpi*254/10))])
|
@ -18,24 +18,24 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tools.qvm_unpause
|
import qubesadmin.tools.qvm_unpause
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_unpause(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_unpause(qubesadmin.tests.QubesTestCase):
|
||||||
def test_000_with_vm(self):
|
def test_000_with_vm(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('some-vm', 'mgmt.vm.Unpause', None, None)] = b'0\x00'
|
('some-vm', 'mgmt.vm.Unpause', None, None)] = b'0\x00'
|
||||||
qubesmgmt.tools.qvm_unpause.main(['some-vm'], app=self.app)
|
qubesadmin.tools.qvm_unpause.main(['some-vm'], app=self.app)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_001_missing_vm(self):
|
def test_001_missing_vm(self):
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_unpause.main([], app=self.app)
|
qubesadmin.tools.qvm_unpause.main([], app=self.app)
|
||||||
self.assertIn('one of the arguments --all VMNAME is required',
|
self.assertIn('one of the arguments --all VMNAME is required',
|
||||||
stderr.getvalue())
|
stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -45,8 +45,8 @@ class TC_00_qvm_unpause(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Running\n'
|
b'0\x00some-vm class=AppVM state=Running\n'
|
||||||
with self.assertRaises(SystemExit):
|
with self.assertRaises(SystemExit):
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
qubesmgmt.tools.qvm_unpause.main(['no-such-vm'], app=self.app)
|
qubesadmin.tools.qvm_unpause.main(['no-such-vm'], app=self.app)
|
||||||
self.assertIn('no such domain', stderr.getvalue())
|
self.assertIn('no such domain', stderr.getvalue())
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class TC_00_qvm_unpause(qubesmgmt.tests.QubesTestCase):
|
|||||||
('dom0', 'mgmt.vm.List', None, None)] = \
|
('dom0', 'mgmt.vm.List', None, None)] = \
|
||||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_unpause.main(['some-vm'], app=self.app),
|
qubesadmin.tools.qvm_unpause.main(['some-vm'], app=self.app),
|
||||||
1)
|
1)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class TC_00_qvm_unpause(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00some-vm class=AppVM state=Running\n' \
|
b'0\x00some-vm class=AppVM state=Running\n' \
|
||||||
b'other-vm class=AppVM state=Running\n'
|
b'other-vm class=AppVM state=Running\n'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
qubesmgmt.tools.qvm_unpause.main(['some-vm', 'other-vm'],
|
qubesadmin.tools.qvm_unpause.main(['some-vm', 'other-vm'],
|
||||||
app=self.app),
|
app=self.app),
|
||||||
0)
|
0)
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
@ -18,12 +18,12 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
import qubesmgmt.tests.tools
|
import qubesadmin.tests.tools
|
||||||
import qubesmgmt.tools.qvm_volume
|
import qubesadmin.tools.qvm_volume
|
||||||
|
|
||||||
|
|
||||||
class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
class TC_00_qvm_volume(qubesadmin.tests.QubesTestCase):
|
||||||
|
|
||||||
def setup_expected_calls_for_list(self, vms=('vm1', 'sys-net')):
|
def setup_expected_calls_for_list(self, vms=('vm1', 'sys-net')):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
@ -49,9 +49,9 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.setup_expected_calls_for_list()
|
self.setup_expected_calls_for_list()
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_volume.main(['ls', '-i'], app=self.app))
|
qubesadmin.tools.qvm_volume.main(['ls', '-i'], app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'POOL:VOLUME VMNAME VOLUME_NAME '
|
'POOL:VOLUME VMNAME VOLUME_NAME '
|
||||||
'REVERT_POSSIBLE\n'
|
'REVERT_POSSIBLE\n'
|
||||||
@ -64,9 +64,9 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
|
|
||||||
def test_001_list_domain(self):
|
def test_001_list_domain(self):
|
||||||
self.setup_expected_calls_for_list(vms=('vm1',))
|
self.setup_expected_calls_for_list(vms=('vm1',))
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_volume.main(['ls', '-i', 'vm1'],
|
qubesadmin.tools.qvm_volume.main(['ls', '-i', 'vm1'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'POOL:VOLUME VMNAME VOLUME_NAME REVERT_POSSIBLE\n'
|
'POOL:VOLUME VMNAME VOLUME_NAME REVERT_POSSIBLE\n'
|
||||||
@ -81,9 +81,9 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00pool-file\nother-pool\n'
|
b'0\x00pool-file\nother-pool\n'
|
||||||
del self.app.expected_calls[
|
del self.app.expected_calls[
|
||||||
('vm1', 'mgmt.vm.volume.ListSnapshots', 'private', None)]
|
('vm1', 'mgmt.vm.volume.ListSnapshots', 'private', None)]
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_volume.main(
|
qubesadmin.tools.qvm_volume.main(
|
||||||
['ls', '-i', '-p', 'pool-file', 'vm1'],
|
['ls', '-i', '-p', 'pool-file', 'vm1'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
@ -101,9 +101,9 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
del self.app.expected_calls[
|
del self.app.expected_calls[
|
||||||
('sys-net', 'mgmt.vm.volume.ListSnapshots', 'private', None)]
|
('sys-net', 'mgmt.vm.volume.ListSnapshots', 'private', None)]
|
||||||
|
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_volume.main(
|
qubesadmin.tools.qvm_volume.main(
|
||||||
['ls', '-i', '-p', 'pool-file'],
|
['ls', '-i', '-p', 'pool-file'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
@ -120,9 +120,9 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
b'0\x00vm1 class=AppVM state=Running\n' \
|
b'0\x00vm1 class=AppVM state=Running\n' \
|
||||||
b'vm2 class=AppVM state=Running\n' \
|
b'vm2 class=AppVM state=Running\n' \
|
||||||
b'vm3 class=AppVM state=Running\n'
|
b'vm3 class=AppVM state=Running\n'
|
||||||
with qubesmgmt.tests.tools.StdoutBuffer() as stdout:
|
with qubesadmin.tests.tools.StdoutBuffer() as stdout:
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_volume.main(
|
qubesadmin.tools.qvm_volume.main(
|
||||||
['ls', '-i', 'vm1', 'vm2'], app=self.app))
|
['ls', '-i', 'vm1', 'vm2'], app=self.app))
|
||||||
self.assertEqual(stdout.getvalue(),
|
self.assertEqual(stdout.getvalue(),
|
||||||
'POOL:VOLUME VMNAME VOLUME_NAME REVERT_POSSIBLE\n'
|
'POOL:VOLUME VMNAME VOLUME_NAME REVERT_POSSIBLE\n'
|
||||||
@ -143,7 +143,7 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
('testvm', 'mgmt.vm.volume.Resize', 'private', b'10737418240')] = \
|
('testvm', 'mgmt.vm.volume.Resize', 'private', b'10737418240')] = \
|
||||||
b'0\x00'
|
b'0\x00'
|
||||||
self.assertEqual(0,
|
self.assertEqual(0,
|
||||||
qubesmgmt.tools.qvm_volume.main(
|
qubesadmin.tools.qvm_volume.main(
|
||||||
['extend', 'testvm:private', '10GiB'],
|
['extend', 'testvm:private', '10GiB'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
@ -158,9 +158,9 @@ class TC_00_qvm_volume(qubesmgmt.tests.QubesTestCase):
|
|||||||
('testvm', 'mgmt.vm.volume.Resize', 'private', b'1073741824')] = \
|
('testvm', 'mgmt.vm.volume.Resize', 'private', b'1073741824')] = \
|
||||||
b'2\x00StoragePoolException\x00\x00Failed to resize volume: ' \
|
b'2\x00StoragePoolException\x00\x00Failed to resize volume: ' \
|
||||||
b'shrink not allowed\x00'
|
b'shrink not allowed\x00'
|
||||||
with qubesmgmt.tests.tools.StderrBuffer() as stderr:
|
with qubesadmin.tests.tools.StderrBuffer() as stderr:
|
||||||
self.assertEqual(1,
|
self.assertEqual(1,
|
||||||
qubesmgmt.tools.qvm_volume.main(
|
qubesadmin.tools.qvm_volume.main(
|
||||||
['extend', 'testvm:private', '1GiB'],
|
['extend', 'testvm:private', '1GiB'],
|
||||||
app=self.app))
|
app=self.app))
|
||||||
self.assertIn('shrink not allowed', stderr.getvalue())
|
self.assertIn('shrink not allowed', stderr.getvalue())
|
@ -18,10 +18,10 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests
|
import qubesadmin.tests
|
||||||
|
|
||||||
|
|
||||||
class VMTestCase(qubesmgmt.tests.QubesTestCase):
|
class VMTestCase(qubesadmin.tests.QubesTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(VMTestCase, self).setUp()
|
super(VMTestCase, self).setUp()
|
||||||
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
self.app.expected_calls[('dom0', 'mgmt.vm.List', None, None)] = \
|
@ -19,10 +19,10 @@
|
|||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import qubesmgmt.tests.vm
|
import qubesadmin.tests.vm
|
||||||
|
|
||||||
|
|
||||||
class TC_00_Actions(qubesmgmt.tests.vm.VMTestCase):
|
class TC_00_Actions(qubesadmin.tests.vm.VMTestCase):
|
||||||
def test_000_start(self):
|
def test_000_start(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.Start', None, None)] = \
|
('test-vm', 'mgmt.vm.Start', None, None)] = \
|
@ -18,10 +18,10 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests.vm
|
import qubesadmin.tests.vm
|
||||||
|
|
||||||
|
|
||||||
class TC_00_Properties(qubesmgmt.tests.vm.VMTestCase):
|
class TC_00_Properties(qubesadmin.tests.vm.VMTestCase):
|
||||||
|
|
||||||
def test_000_list(self):
|
def test_000_list(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
@ -57,7 +57,7 @@ class TC_00_Properties(qubesmgmt.tests.vm.VMTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \
|
('test-vm', 'mgmt.vm.property.Get', 'prop1', None)] = \
|
||||||
b'0\x00default=False type=vm test-vm'
|
b'0\x00default=False type=vm test-vm'
|
||||||
self.assertIsInstance(self.vm.prop1, qubesmgmt.vm.QubesVM)
|
self.assertIsInstance(self.vm.prop1, qubesadmin.vm.QubesVM)
|
||||||
self.assertEqual(self.vm.prop1.name, 'test-vm')
|
self.assertEqual(self.vm.prop1.name, 'test-vm')
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ class TC_00_Properties(qubesmgmt.tests.vm.VMTestCase):
|
|||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.property.Reset', 'prop1', None)] = \
|
('test-vm', 'mgmt.vm.property.Reset', 'prop1', None)] = \
|
||||||
b'0\x00'
|
b'0\x00'
|
||||||
self.vm.prop1 = qubesmgmt.DEFAULT
|
self.vm.prop1 = qubesadmin.DEFAULT
|
||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
def test_031_reset(self):
|
def test_031_reset(self):
|
||||||
@ -155,7 +155,7 @@ class TC_00_Properties(qubesmgmt.tests.vm.VMTestCase):
|
|||||||
self.assertAllCalled()
|
self.assertAllCalled()
|
||||||
|
|
||||||
|
|
||||||
class TC_01_SpecialCases(qubesmgmt.tests.vm.VMTestCase):
|
class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase):
|
||||||
def test_000_get_name(self):
|
def test_000_get_name(self):
|
||||||
# should not make any mgmt call
|
# should not make any mgmt call
|
||||||
self.assertEqual(self.vm.name, 'test-vm')
|
self.assertEqual(self.vm.name, 'test-vm')
|
@ -18,10 +18,10 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License along
|
# You should have received a copy of the GNU Lesser General Public License along
|
||||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import qubesmgmt.tests.vm
|
import qubesadmin.tests.vm
|
||||||
|
|
||||||
|
|
||||||
class TestVMVolumes(qubesmgmt.tests.vm.VMTestCase):
|
class TestVMVolumes(qubesadmin.tests.vm.VMTestCase):
|
||||||
def test_000_list_volumes(self):
|
def test_000_list_volumes(self):
|
||||||
self.app.expected_calls[
|
self.app.expected_calls[
|
||||||
('test-vm', 'mgmt.vm.volume.List', None, None)] = \
|
('test-vm', 'mgmt.vm.volume.List', None, None)] = \
|
@ -31,9 +31,9 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import qubesmgmt.log
|
import qubesadmin.log
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
|
|
||||||
#: constant returned when some action should be performed on all qubes
|
#: constant returned when some action should be performed on all qubes
|
||||||
VM_ALL = object()
|
VM_ALL = object()
|
||||||
@ -156,7 +156,7 @@ class VmNameAction(QubesAction):
|
|||||||
namespace.domains = [
|
namespace.domains = [
|
||||||
vm
|
vm
|
||||||
for vm in app.domains
|
for vm in app.domains
|
||||||
if not isinstance(vm, qubesmgmt.vm.AdminVM) and
|
if not isinstance(vm, qubesadmin.vm.AdminVM) and
|
||||||
vm.name not in namespace.exclude
|
vm.name not in namespace.exclude
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
@ -303,7 +303,7 @@ class PoolsAction(QubesAction):
|
|||||||
try:
|
try:
|
||||||
pools = [app.pools[name] for name in pool_names]
|
pools = [app.pools[name] for name in pool_names]
|
||||||
setattr(namespace, self.dest, pools)
|
setattr(namespace, self.dest, pools)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
parser.error(str(e))
|
parser.error(str(e))
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ class QubesArgumentParser(argparse.ArgumentParser):
|
|||||||
if app is not None:
|
if app is not None:
|
||||||
namespace.app = app
|
namespace.app = app
|
||||||
else:
|
else:
|
||||||
namespace.app = qubesmgmt.Qubes()
|
namespace.app = qubesadmin.Qubes()
|
||||||
|
|
||||||
for action in self._actions:
|
for action in self._actions:
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
@ -414,9 +414,9 @@ class QubesArgumentParser(argparse.ArgumentParser):
|
|||||||
verbose = namespace.verbose - namespace.quiet
|
verbose = namespace.verbose - namespace.quiet
|
||||||
|
|
||||||
if verbose >= 2:
|
if verbose >= 2:
|
||||||
qubesmgmt.log.enable_debug()
|
qubesadmin.log.enable_debug()
|
||||||
elif verbose >= 1:
|
elif verbose >= 1:
|
||||||
qubesmgmt.log.enable()
|
qubesadmin.log.enable()
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
# pylint: disable=no-self-use
|
||||||
def print_error(self, *args, **kwargs):
|
def print_error(self, *args, **kwargs):
|
||||||
@ -473,7 +473,7 @@ def get_parser_for_command(command):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
module = importlib.import_module(
|
module = importlib.import_module(
|
||||||
'.' + command.replace('-', '_'), 'qubesmgmt.tools')
|
'.' + command.replace('-', '_'), 'qubesadmin.tools')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
parser = module.parser
|
parser = module.parser
|
@ -40,7 +40,7 @@ import sphinx.errors
|
|||||||
import sphinx.locale
|
import sphinx.locale
|
||||||
import sphinx.util.docfields
|
import sphinx.util.docfields
|
||||||
|
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
SUBCOMMANDS_TITLE = 'COMMANDS'
|
SUBCOMMANDS_TITLE = 'COMMANDS'
|
||||||
OPTIONS_TITLE = 'OPTIONS'
|
OPTIONS_TITLE = 'OPTIONS'
|
||||||
@ -53,7 +53,7 @@ def make_rst_section(heading, char):
|
|||||||
|
|
||||||
def prepare_manpage(command):
|
def prepare_manpage(command):
|
||||||
'''Build a man page skeleton'''
|
'''Build a man page skeleton'''
|
||||||
parser = qubesmgmt.tools.get_parser_for_command(command)
|
parser = qubesadmin.tools.get_parser_for_command(command)
|
||||||
stream = io.StringIO()
|
stream = io.StringIO()
|
||||||
stream.write('.. program:: {}\n\n'.format(command))
|
stream.write('.. program:: {}\n\n'.format(command))
|
||||||
stream.write(make_rst_section(
|
stream.write(make_rst_section(
|
||||||
@ -221,7 +221,7 @@ class ManpageCheckVisitor(docutils.nodes.SparseNodeVisitor):
|
|||||||
def __init__(self, app, command, document):
|
def __init__(self, app, command, document):
|
||||||
docutils.nodes.SparseNodeVisitor.__init__(self, document)
|
docutils.nodes.SparseNodeVisitor.__init__(self, document)
|
||||||
try:
|
try:
|
||||||
parser = qubesmgmt.tools.get_parser_for_command(command)
|
parser = qubesadmin.tools.get_parser_for_command(command)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
app.warn('cannot import module for command')
|
app.warn('cannot import module for command')
|
||||||
self.parser = None
|
self.parser = None
|
||||||
@ -241,7 +241,7 @@ class ManpageCheckVisitor(docutils.nodes.SparseNodeVisitor):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if issubclass(action.__class__,
|
if issubclass(action.__class__,
|
||||||
qubesmgmt.tools.AliasedSubParsersAction):
|
qubesadmin.tools.AliasedSubParsersAction):
|
||||||
for cmd, cmd_parser in action._name_parser_map.items():
|
for cmd, cmd_parser in action._name_parser_map.items():
|
||||||
self.sub_commands[cmd] = set()
|
self.sub_commands[cmd] = set()
|
||||||
for sub_action in cmd_parser._actions:
|
for sub_action in cmd_parser._actions:
|
@ -27,20 +27,20 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.tools.qvm_prefs
|
import qubesadmin.tools.qvm_prefs
|
||||||
|
|
||||||
|
|
||||||
def get_parser():
|
def get_parser():
|
||||||
'''Prepare argument parser'''
|
'''Prepare argument parser'''
|
||||||
return qubesmgmt.tools.qvm_prefs.get_parser(None)
|
return qubesadmin.tools.qvm_prefs.get_parser(None)
|
||||||
|
|
||||||
|
|
||||||
def main(args=None, app=None): # pylint: disable=missing-docstring
|
def main(args=None, app=None): # pylint: disable=missing-docstring
|
||||||
parser = get_parser()
|
parser = get_parser()
|
||||||
args = parser.parse_args(args, app=app)
|
args = parser.parse_args(args, app=app)
|
||||||
target = args.app
|
target = args.app
|
||||||
return qubesmgmt.tools.qvm_prefs.process_actions(parser, args, target)
|
return qubesadmin.tools.qvm_prefs.process_actions(parser, args, target)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
@ -25,10 +25,10 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(description=__doc__,
|
parser = qubesadmin.tools.QubesArgumentParser(description=__doc__,
|
||||||
vmname_nargs='+')
|
vmname_nargs='+')
|
||||||
parser.add_argument("--running", action="store_true", dest="running",
|
parser.add_argument("--running", action="store_true", dest="running",
|
||||||
default=False, help="Determine if (any of given) VM is running")
|
default=False, help="Determine if (any of given) VM is running")
|
||||||
@ -65,7 +65,7 @@ def main(args=None, app=None):
|
|||||||
return 0 if paused else 1
|
return 0 if paused else 1
|
||||||
elif args.template:
|
elif args.template:
|
||||||
template = [vm for vm in domains if isinstance(vm,
|
template = [vm for vm in domains if isinstance(vm,
|
||||||
qubesmgmt.vm.TemplateVM)]
|
qubesadmin.vm.TemplateVM)]
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print_msg(template, "is a template", "are templates")
|
print_msg(template, "is a template", "are templates")
|
||||||
return 0 if template else 1
|
return 0 if template else 1
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from qubesmgmt.tools import QubesArgumentParser
|
from qubesadmin.tools import QubesArgumentParser
|
||||||
|
|
||||||
parser = QubesArgumentParser(description=__doc__, vmname_nargs=1)
|
parser = QubesArgumentParser(description=__doc__, vmname_nargs=1)
|
||||||
parser.add_argument('new_name',
|
parser.add_argument('new_name',
|
@ -32,18 +32,18 @@ from __future__ import print_function
|
|||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser()
|
parser = qubesadmin.tools.QubesArgumentParser()
|
||||||
|
|
||||||
parser.add_argument('--class', '-C', dest='cls',
|
parser.add_argument('--class', '-C', dest='cls',
|
||||||
default='AppVM',
|
default='AppVM',
|
||||||
help='specify the class of the new domain (default: %(default)s)')
|
help='specify the class of the new domain (default: %(default)s)')
|
||||||
|
|
||||||
parser.add_argument('--property', '--prop',
|
parser.add_argument('--property', '--prop',
|
||||||
action=qubesmgmt.tools.PropertyAction,
|
action=qubesadmin.tools.PropertyAction,
|
||||||
help='set domain\'s property, like "internal", "memory" or "vcpus"')
|
help='set domain\'s property, like "internal", "memory" or "vcpus"')
|
||||||
|
|
||||||
parser.add_argument('--pool', '-p',
|
parser.add_argument('--pool', '-p',
|
||||||
@ -58,11 +58,11 @@ parser.add_argument('-P',
|
|||||||
help='change all volume pools to specified pool')
|
help='change all volume pools to specified pool')
|
||||||
|
|
||||||
parser.add_argument('--template', '-t',
|
parser.add_argument('--template', '-t',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction,
|
action=qubesadmin.tools.SinglePropertyAction,
|
||||||
help='specify the TemplateVM to use')
|
help='specify the TemplateVM to use')
|
||||||
|
|
||||||
parser.add_argument('--label', '-l',
|
parser.add_argument('--label', '-l',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction,
|
action=qubesadmin.tools.SinglePropertyAction,
|
||||||
help='specify the label to use for the new domain'
|
help='specify the label to use for the new domain'
|
||||||
' (e.g. red, yellow, green, ...)')
|
' (e.g. red, yellow, green, ...)')
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ parser_root.add_argument('--no-root',
|
|||||||
help=argparse.SUPPRESS)
|
help=argparse.SUPPRESS)
|
||||||
|
|
||||||
parser.add_argument('name', metavar='VMNAME',
|
parser.add_argument('name', metavar='VMNAME',
|
||||||
action=qubesmgmt.tools.SinglePropertyAction,
|
action=qubesadmin.tools.SinglePropertyAction,
|
||||||
nargs='?',
|
nargs='?',
|
||||||
help='name of the domain to create')
|
help='name of the domain to create')
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ def main(args=None, app=None):
|
|||||||
template=args.properties.pop('template', None),
|
template=args.properties.pop('template', None),
|
||||||
pool=pool,
|
pool=pool,
|
||||||
pools=pools)
|
pools=pools)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
args.app.log.error('Error creating VM: {!s}'.format(e))
|
args.app.log.error('Error creating VM: {!s}'.format(e))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ def main(args=None, app=None):
|
|||||||
for prop, value in args.properties.items():
|
for prop, value in args.properties.items():
|
||||||
try:
|
try:
|
||||||
setattr(vm, prop, value)
|
setattr(vm, prop, value)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
args.app.log.error(
|
args.app.log.error(
|
||||||
'Error setting property {} (but VM created): {!s}'.
|
'Error setting property {} (but VM created): {!s}'.
|
||||||
format(prop, e))
|
format(prop, e))
|
@ -27,10 +27,10 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.devices
|
import qubesadmin.devices
|
||||||
|
|
||||||
|
|
||||||
def prepare_table(dev_list):
|
def prepare_table(dev_list):
|
||||||
@ -62,7 +62,7 @@ def prepare_table(dev_list):
|
|||||||
class Line(object):
|
class Line(object):
|
||||||
'''Helper class to hold single device info for listing'''
|
'''Helper class to hold single device info for listing'''
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
def __init__(self, device: qubesmgmt.devices.DeviceInfo, attached_to=None):
|
def __init__(self, device: qubesadmin.devices.DeviceInfo, attached_to=None):
|
||||||
self.ident = "{!s}:{!s}".format(device.backend_domain, device.ident)
|
self.ident = "{!s}:{!s}".format(device.backend_domain, device.ident)
|
||||||
self.description = device.description
|
self.description = device.description
|
||||||
self.attached_to = attached_to if attached_to else ""
|
self.attached_to = attached_to if attached_to else ""
|
||||||
@ -103,7 +103,7 @@ def list_devices(args):
|
|||||||
result[dev].frontends.append(str(domain))
|
result[dev].frontends.append(str(domain))
|
||||||
|
|
||||||
|
|
||||||
qubesmgmt.tools.print_table(prepare_table(result.values()))
|
qubesadmin.tools.print_table(prepare_table(result.values()))
|
||||||
|
|
||||||
|
|
||||||
def attach_device(args):
|
def attach_device(args):
|
||||||
@ -133,16 +133,16 @@ def init_list_parser(sub_parsers):
|
|||||||
list_parser = sub_parsers.add_parser('list', aliases=('ls', 'l'),
|
list_parser = sub_parsers.add_parser('list', aliases=('ls', 'l'),
|
||||||
help='list devices')
|
help='list devices')
|
||||||
|
|
||||||
vm_name_group = qubesmgmt.tools.VmNameGroup(
|
vm_name_group = qubesadmin.tools.VmNameGroup(
|
||||||
list_parser, required=False, vm_action=qubesmgmt.tools.VmNameAction,
|
list_parser, required=False, vm_action=qubesadmin.tools.VmNameAction,
|
||||||
help='list devices assigned to specific domain(s)')
|
help='list devices assigned to specific domain(s)')
|
||||||
list_parser._mutually_exclusive_groups.append(vm_name_group)
|
list_parser._mutually_exclusive_groups.append(vm_name_group)
|
||||||
list_parser.set_defaults(func=list_devices)
|
list_parser.set_defaults(func=list_devices)
|
||||||
|
|
||||||
|
|
||||||
class DeviceAction(qubesmgmt.tools.QubesAction):
|
class DeviceAction(qubesadmin.tools.QubesAction):
|
||||||
''' Action for argument parser that gets the
|
''' Action for argument parser that gets the
|
||||||
:py:class:``qubesmgmt.device.DeviceAssignment`` from a
|
:py:class:``qubesadmin.device.DeviceAssignment`` from a
|
||||||
BACKEND:DEVICE_ID string.
|
BACKEND:DEVICE_ID string.
|
||||||
''' # pylint: disable=too-few-public-methods
|
''' # pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
@ -172,13 +172,13 @@ class DeviceAction(qubesmgmt.tools.QubesAction):
|
|||||||
try:
|
try:
|
||||||
dev = vm.devices[devclass][device_id]
|
dev = vm.devices[devclass][device_id]
|
||||||
if not self.allow_unknown and isinstance(dev,
|
if not self.allow_unknown and isinstance(dev,
|
||||||
qubesmgmt.devices.UnknownDevice):
|
qubesadmin.devices.UnknownDevice):
|
||||||
raise KeyError(device_id)
|
raise KeyError(device_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
parser.error_runtime(
|
parser.error_runtime(
|
||||||
"backend vm {!r} doesn't expose device {!r}"
|
"backend vm {!r} doesn't expose device {!r}"
|
||||||
.format(vmname, device_id))
|
.format(vmname, device_id))
|
||||||
device_assignment = qubesmgmt.devices.DeviceAssignment(vm,
|
device_assignment = qubesadmin.devices.DeviceAssignment(vm,
|
||||||
device_id)
|
device_id)
|
||||||
setattr(namespace, self.dest, device_assignment)
|
setattr(namespace, self.dest, device_assignment)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -190,10 +190,10 @@ def get_parser(device_class=None):
|
|||||||
'''Create :py:class:`argparse.ArgumentParser` suitable for
|
'''Create :py:class:`argparse.ArgumentParser` suitable for
|
||||||
:program:`qvm-block`.
|
:program:`qvm-block`.
|
||||||
'''
|
'''
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(description=__doc__,
|
parser = qubesadmin.tools.QubesArgumentParser(description=__doc__,
|
||||||
want_app=True)
|
want_app=True)
|
||||||
parser.register('action', 'parsers',
|
parser.register('action', 'parsers',
|
||||||
qubesmgmt.tools.AliasedSubParsersAction)
|
qubesadmin.tools.AliasedSubParsersAction)
|
||||||
if device_class:
|
if device_class:
|
||||||
parser.add_argument('devclass', const=device_class,
|
parser.add_argument('devclass', const=device_class,
|
||||||
action='store_const',
|
action='store_const',
|
||||||
@ -212,9 +212,9 @@ def get_parser(device_class=None):
|
|||||||
"detach", help="Detach device from domain", aliases=('d', 'dt'))
|
"detach", help="Detach device from domain", aliases=('d', 'dt'))
|
||||||
|
|
||||||
attach_parser.add_argument('VMNAME', nargs=1,
|
attach_parser.add_argument('VMNAME', nargs=1,
|
||||||
action=qubesmgmt.tools.VmNameAction)
|
action=qubesadmin.tools.VmNameAction)
|
||||||
detach_parser.add_argument('VMNAME', nargs=1,
|
detach_parser.add_argument('VMNAME', nargs=1,
|
||||||
action=qubesmgmt.tools.VmNameAction)
|
action=qubesadmin.tools.VmNameAction)
|
||||||
|
|
||||||
attach_parser.add_argument(metavar='BACKEND:DEVICE_ID',
|
attach_parser.add_argument(metavar='BACKEND:DEVICE_ID',
|
||||||
dest='device_assignment',
|
dest='device_assignment',
|
||||||
@ -246,7 +246,7 @@ def main(args=None, app=None):
|
|||||||
args = get_parser(devclass).parse_args(args, app=app)
|
args = get_parser(devclass).parse_args(args, app=app)
|
||||||
try:
|
try:
|
||||||
args.func(args)
|
args.func(args)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
print(str(e), file=sys.stderr)
|
print(str(e), file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
@ -28,10 +28,10 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
vmname_nargs=1,
|
vmname_nargs=1,
|
||||||
description='manage domain\'s features')
|
description='manage domain\'s features')
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ def main(args=None, app=None):
|
|||||||
parser.error('--unset requires a feature')
|
parser.error('--unset requires a feature')
|
||||||
|
|
||||||
features = [(feat, vm.features[feat]) for feat in vm.features]
|
features = [(feat, vm.features[feat]) for feat in vm.features]
|
||||||
qubesmgmt.tools.print_table(features)
|
qubesadmin.tools.print_table(features)
|
||||||
|
|
||||||
elif args.delete:
|
elif args.delete:
|
||||||
if args.value is not None:
|
if args.value is not None:
|
@ -25,9 +25,9 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.firewall
|
import qubesadmin.firewall
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
|
|
||||||
class RuleAction(argparse.Action):
|
class RuleAction(argparse.Action):
|
||||||
@ -65,10 +65,10 @@ class RuleAction(argparse.Action):
|
|||||||
assumed_order.remove('icmptype')
|
assumed_order.remove('icmptype')
|
||||||
elif key == 'proto' and value in ['icmp']:
|
elif key == 'proto' and value in ['icmp']:
|
||||||
assumed_order.remove('dstports')
|
assumed_order.remove('dstports')
|
||||||
rule = qubesmgmt.firewall.Rule(None, **kwargs)
|
rule = qubesadmin.firewall.Rule(None, **kwargs)
|
||||||
setattr(namespace, self.dest, rule)
|
setattr(namespace, self.dest, rule)
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(vmname_nargs=1)
|
parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs=1)
|
||||||
|
|
||||||
action = parser.add_subparsers(dest='command', help='action to perform')
|
action = parser.add_subparsers(dest='command', help='action to perform')
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ def rules_list_table(vm):
|
|||||||
rule.comment,
|
rule.comment,
|
||||||
]]
|
]]
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
qubesmgmt.tools.print_table([header] + rows)
|
qubesadmin.tools.print_table([header] + rows)
|
||||||
|
|
||||||
|
|
||||||
def rules_list_raw(vm):
|
def rules_list_raw(vm):
|
||||||
@ -176,7 +176,7 @@ def main(args=None, app=None):
|
|||||||
rules_list_table(vm)
|
rules_list_table(vm)
|
||||||
if args.reload:
|
if args.reload:
|
||||||
vm.firewall.reload()
|
vm.firewall.reload()
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
description='forceful shutdown of a domain', vmname_nargs='+')
|
description='forceful shutdown of a domain', vmname_nargs='+')
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ def main(args=None, app=None):
|
|||||||
for domain in args.domains:
|
for domain in args.domains:
|
||||||
try:
|
try:
|
||||||
domain.kill()
|
domain.kill()
|
||||||
except (IOError, OSError, qubesmgmt.exc.QubesException) as e:
|
except (IOError, OSError, qubesadmin.exc.QubesException) as e:
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
|
|
@ -33,10 +33,10 @@ import collections
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.utils
|
import qubesadmin.utils
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
|
|
||||||
#
|
#
|
||||||
# columns
|
# columns
|
||||||
@ -57,7 +57,7 @@ class Column(object):
|
|||||||
|
|
||||||
def __init__(self, head, attr=None, doc=None):
|
def __init__(self, head, attr=None, doc=None):
|
||||||
self.ls_head = head
|
self.ls_head = head
|
||||||
self.__doc__ = doc if doc is None else qubesmgmt.utils.format_doc(doc)
|
self.__doc__ = doc if doc is None else qubesadmin.utils.format_doc(doc)
|
||||||
|
|
||||||
# intentionally not always do set self._attr,
|
# intentionally not always do set self._attr,
|
||||||
# to cause AttributeError in self.format()
|
# to cause AttributeError in self.format()
|
||||||
@ -213,18 +213,18 @@ class StatusColumn(Column):
|
|||||||
When it is HVM (optimised VM), the letter is capital.
|
When it is HVM (optimised VM), the letter is capital.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if isinstance(vm, qubesmgmt.vm.AdminVM):
|
if isinstance(vm, qubesadmin.vm.AdminVM):
|
||||||
return '0'
|
return '0'
|
||||||
|
|
||||||
ret = None
|
ret = None
|
||||||
# TODO right order, depending on inheritance
|
# TODO right order, depending on inheritance
|
||||||
if isinstance(vm, qubesmgmt.vm.TemplateVM):
|
if isinstance(vm, qubesadmin.vm.TemplateVM):
|
||||||
ret = 't'
|
ret = 't'
|
||||||
if isinstance(vm, qubesmgmt.vm.AppVM):
|
if isinstance(vm, qubesadmin.vm.AppVM):
|
||||||
ret = 'a'
|
ret = 'a'
|
||||||
if isinstance(vm, qubesmgmt.vm.StandaloneVM):
|
if isinstance(vm, qubesadmin.vm.StandaloneVM):
|
||||||
ret = 's'
|
ret = 's'
|
||||||
if isinstance(vm, qubesmgmt.vm.DispVM):
|
if isinstance(vm, qubesadmin.vm.DispVM):
|
||||||
ret = 'd'
|
ret = 'd'
|
||||||
|
|
||||||
if ret is not None:
|
if ret is not None:
|
||||||
@ -405,7 +405,7 @@ class Table(object):
|
|||||||
table_data.append(self.get_head())
|
table_data.append(self.get_head())
|
||||||
for vm in sorted(self.app.domains):
|
for vm in sorted(self.app.domains):
|
||||||
table_data.append(self.get_row(vm))
|
table_data.append(self.get_row(vm))
|
||||||
qubesmgmt.tools.print_table(table_data, stream=stream)
|
qubesadmin.tools.print_table(table_data, stream=stream)
|
||||||
else:
|
else:
|
||||||
for vm in sorted(self.app.domains):
|
for vm in sorted(self.app.domains):
|
||||||
stream.write('|'.join(self.get_row(vm)) + '\n')
|
stream.write('|'.join(self.get_row(vm)) + '\n')
|
||||||
@ -488,7 +488,7 @@ def get_parser():
|
|||||||
wrapper = textwrap.TextWrapper(width=80, break_on_hyphens=False,
|
wrapper = textwrap.TextWrapper(width=80, break_on_hyphens=False,
|
||||||
initial_indent=' ', subsequent_indent=' ')
|
initial_indent=' ', subsequent_indent=' ')
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
formatter_class=argparse.RawTextHelpFormatter,
|
formatter_class=argparse.RawTextHelpFormatter,
|
||||||
description='List Qubes domains and their parametres.',
|
description='List Qubes domains and their parametres.',
|
||||||
epilog='available formats (see --help-formats):\n{}\n\n'
|
epilog='available formats (see --help-formats):\n{}\n\n'
|
||||||
@ -533,7 +533,7 @@ def main(args=None, app=None):
|
|||||||
parser = get_parser()
|
parser = get_parser()
|
||||||
try:
|
try:
|
||||||
args = parser.parse_args(args, app=app)
|
args = parser.parse_args(args, app=app)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -21,10 +21,10 @@
|
|||||||
'''qvm-pause - Pause a domain'''
|
'''qvm-pause - Pause a domain'''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
|
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(vmname_nargs='+',
|
parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs='+',
|
||||||
description='pause a domain')
|
description='pause a domain')
|
||||||
|
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ def main(args=None, app=None):
|
|||||||
for domain in args.domains:
|
for domain in args.domains:
|
||||||
try:
|
try:
|
||||||
domain.pause()
|
domain.pause()
|
||||||
except (IOError, OSError, qubesmgmt.exc.QubesException) as e:
|
except (IOError, OSError, qubesadmin.exc.QubesException) as e:
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
|
|
@ -25,13 +25,13 @@ from __future__ import print_function
|
|||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.storage
|
import qubesadmin.storage
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
|
|
||||||
class _Info(qubesmgmt.tools.PoolsAction):
|
class _Info(qubesadmin.tools.PoolsAction):
|
||||||
''' Action for argument parser that displays pool info and exits. '''
|
''' Action for argument parser that displays pool info and exits. '''
|
||||||
|
|
||||||
def __init__(self, option_strings, help='print pool info and exit',
|
def __init__(self, option_strings, help='print pool info and exit',
|
||||||
@ -48,7 +48,7 @@ def pool_info(pool):
|
|||||||
''' Prints out pool name and config '''
|
''' Prints out pool name and config '''
|
||||||
data = [("name", pool.name)]
|
data = [("name", pool.name)]
|
||||||
data += [i for i in sorted(pool.config.items()) if i[0] != 'name']
|
data += [i for i in sorted(pool.config.items()) if i[0] != 'name']
|
||||||
qubesmgmt.tools.print_table(data)
|
qubesadmin.tools.print_table(data)
|
||||||
|
|
||||||
|
|
||||||
def list_pools(app):
|
def list_pools(app):
|
||||||
@ -56,7 +56,7 @@ def list_pools(app):
|
|||||||
result = [('NAME', 'DRIVER')]
|
result = [('NAME', 'DRIVER')]
|
||||||
for pool in app.pools:
|
for pool in app.pools:
|
||||||
result += [(pool.name, pool.driver)]
|
result += [(pool.name, pool.driver)]
|
||||||
qubesmgmt.tools.print_table(result)
|
qubesadmin.tools.print_table(result)
|
||||||
|
|
||||||
|
|
||||||
class _Remove(argparse.Action):
|
class _Remove(argparse.Action):
|
||||||
@ -110,7 +110,7 @@ class _Options(argparse.Action):
|
|||||||
|
|
||||||
def get_parser():
|
def get_parser():
|
||||||
''' Parses the provided args '''
|
''' Parses the provided args '''
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(description=__doc__)
|
parser = qubesadmin.tools.QubesArgumentParser(description=__doc__)
|
||||||
parser.add_argument('-o', action=_Options, dest='options', default={})
|
parser.add_argument('-o', action=_Options, dest='options', default={})
|
||||||
group = parser.add_mutually_exclusive_group()
|
group = parser.add_mutually_exclusive_group()
|
||||||
group.add_argument('-l',
|
group.add_argument('-l',
|
||||||
@ -144,7 +144,7 @@ def main(args=None, app=None):
|
|||||||
parser = get_parser()
|
parser = get_parser()
|
||||||
try:
|
try:
|
||||||
args = parser.parse_args(args, app=app)
|
args = parser.parse_args(args, app=app)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@ -156,12 +156,12 @@ def main(args=None, app=None):
|
|||||||
params = args.app.pool_driver_parameters(driver)
|
params = args.app.pool_driver_parameters(driver)
|
||||||
driver_options = ', '.join(params)
|
driver_options = ', '.join(params)
|
||||||
result += [(driver, driver_options)]
|
result += [(driver, driver_options)]
|
||||||
qubesmgmt.tools.print_table(result)
|
qubesadmin.tools.print_table(result)
|
||||||
elif args.command == 'add':
|
elif args.command == 'add':
|
||||||
try:
|
try:
|
||||||
args.app.add_pool(name=args.name, driver=args.driver,
|
args.app.add_pool(name=args.name, driver=args.driver,
|
||||||
**args.options)
|
**args.options)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
parser.error('failed to add pool %s: %s\n' % (args.name, str(e)))
|
parser.error('failed to add pool %s: %s\n' % (args.name, str(e)))
|
||||||
elif args.command == 'remove':
|
elif args.command == 'remove':
|
||||||
try:
|
try:
|
@ -26,15 +26,15 @@ from __future__ import print_function
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.utils
|
import qubesadmin.utils
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
|
|
||||||
|
|
||||||
def get_parser(vmname_nargs=1):
|
def get_parser(vmname_nargs=1):
|
||||||
'''Return argument parser for generic property-related tool'''
|
'''Return argument parser for generic property-related tool'''
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
vmname_nargs=vmname_nargs)
|
vmname_nargs=vmname_nargs)
|
||||||
|
|
||||||
parser.add_argument('--help-properties',
|
parser.add_argument('--help-properties',
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from qubesmgmt.tools import QubesArgumentParser
|
from qubesadmin.tools import QubesArgumentParser
|
||||||
|
|
||||||
parser = QubesArgumentParser(description=__doc__,
|
parser = QubesArgumentParser(description=__doc__,
|
||||||
want_app=True,
|
want_app=True,
|
@ -30,10 +30,10 @@ import functools
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(vmname_nargs='+')
|
parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs='+')
|
||||||
|
|
||||||
parser.add_argument('--user', '-u', metavar='USER',
|
parser.add_argument('--user', '-u', metavar='USER',
|
||||||
help='run command in a qube as USER (available only from dom0)')
|
help='run command in a qube as USER (available only from dom0)')
|
||||||
@ -169,7 +169,7 @@ def main(args=None, app=None):
|
|||||||
loop.close()
|
loop.close()
|
||||||
proc.stdin.close()
|
proc.stdin.close()
|
||||||
procs.append(proc)
|
procs.append(proc)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
if args.color_output:
|
if args.color_output:
|
||||||
sys.stdout.write('\033[0m')
|
sys.stdout.write('\033[0m')
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
@ -27,10 +27,10 @@ from __future__ import print_function
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
description=__doc__, vmname_nargs='+')
|
description=__doc__, vmname_nargs='+')
|
||||||
|
|
||||||
parser.add_argument('--force',
|
parser.add_argument('--force',
|
||||||
@ -55,7 +55,7 @@ def main(args=None, app=None): # pylint: disable=missing-docstring
|
|||||||
for vm in args.domains:
|
for vm in args.domains:
|
||||||
try:
|
try:
|
||||||
vm.shutdown(force=args.force)
|
vm.shutdown(force=args.force)
|
||||||
except qubesmgmt.exc.QubesVMNotStartedError:
|
except qubesadmin.exc.QubesVMNotStartedError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if not args.wait:
|
if not args.wait:
|
@ -22,10 +22,10 @@
|
|||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
description='start a domain', vmname_nargs='+')
|
description='start a domain', vmname_nargs='+')
|
||||||
|
|
||||||
parser.add_argument('--skip-if-running',
|
parser.add_argument('--skip-if-running',
|
||||||
@ -47,7 +47,7 @@ def main(args=None, app=None):
|
|||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
domain.start()
|
domain.start()
|
||||||
except (IOError, OSError, qubesmgmt.exc.QubesException) as e:
|
except (IOError, OSError, qubesadmin.exc.QubesException) as e:
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
|
|
@ -29,10 +29,10 @@ import asyncio
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
import daemon.pidfile
|
import daemon.pidfile
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.events
|
import qubesadmin.events
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.vm
|
import qubesadmin.vm
|
||||||
|
|
||||||
GUI_DAEMON_PATH = '/usr/bin/qubes-guid'
|
GUI_DAEMON_PATH = '/usr/bin/qubes-guid'
|
||||||
QUBES_ICON_DIR = '/usr/share/icons/hicolor/128x128/devices'
|
QUBES_ICON_DIR = '/usr/share/icons/hicolor/128x128/devices'
|
||||||
@ -104,10 +104,10 @@ def get_monitor_layout():
|
|||||||
|
|
||||||
class GUILauncher(object):
|
class GUILauncher(object):
|
||||||
'''Launch GUI daemon for VMs'''
|
'''Launch GUI daemon for VMs'''
|
||||||
def __init__(self, app: qubesmgmt.app.QubesBase):
|
def __init__(self, app: qubesadmin.app.QubesBase):
|
||||||
''' Initialize GUILauncher.
|
''' Initialize GUILauncher.
|
||||||
|
|
||||||
:param app: :py:class:`qubesmgmt.Qubes` instance
|
:param app: :py:class:`qubesadmin.Qubes` instance
|
||||||
'''
|
'''
|
||||||
self.app = app
|
self.app = app
|
||||||
self.started_processes = {}
|
self.started_processes = {}
|
||||||
@ -269,7 +269,7 @@ class GUILauncher(object):
|
|||||||
'''Send monitor layout to all (running) VMs'''
|
'''Send monitor layout to all (running) VMs'''
|
||||||
monitor_layout = get_monitor_layout()
|
monitor_layout = get_monitor_layout()
|
||||||
for vm in self.app.domains:
|
for vm in self.app.domains:
|
||||||
if isinstance(vm, qubesmgmt.vm.AdminVM):
|
if isinstance(vm, qubesadmin.vm.AdminVM):
|
||||||
continue
|
continue
|
||||||
if vm.is_running():
|
if vm.is_running():
|
||||||
if not vm.features.check_with_template('gui', True):
|
if not vm.features.check_with_template('gui', True):
|
||||||
@ -297,7 +297,7 @@ class GUILauncher(object):
|
|||||||
|
|
||||||
monitor_layout = get_monitor_layout()
|
monitor_layout = get_monitor_layout()
|
||||||
for vm in self.app.domains:
|
for vm in self.app.domains:
|
||||||
if isinstance(vm, qubesmgmt.vm.AdminVM):
|
if isinstance(vm, qubesadmin.vm.AdminVM):
|
||||||
continue
|
continue
|
||||||
if vm.is_running():
|
if vm.is_running():
|
||||||
asyncio.ensure_future(self.start_gui(vm,
|
asyncio.ensure_future(self.start_gui(vm,
|
||||||
@ -318,7 +318,7 @@ else:
|
|||||||
pidfile_path = os.path.join(os.environ.get('HOME', '/'),
|
pidfile_path = os.path.join(os.environ.get('HOME', '/'),
|
||||||
'.qvm-start-gui.pid')
|
'.qvm-start-gui.pid')
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
description='start GUI for qube(s)', vmname_nargs='*')
|
description='start GUI for qube(s)', vmname_nargs='*')
|
||||||
parser.add_argument('--watch', action='store_true',
|
parser.add_argument('--watch', action='store_true',
|
||||||
help='Keep watching for further domains startups, must be used with --all')
|
help='Keep watching for further domains startups, must be used with --all')
|
||||||
@ -339,7 +339,7 @@ def main(args=None):
|
|||||||
if args.watch:
|
if args.watch:
|
||||||
with daemon.pidfile.TimeoutPIDLockFile(args.pidfile):
|
with daemon.pidfile.TimeoutPIDLockFile(args.pidfile):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
events = qubesmgmt.events.EventsDispatcher(args.app)
|
events = qubesadmin.events.EventsDispatcher(args.app)
|
||||||
launcher.register_events(events)
|
launcher.register_events(events)
|
||||||
|
|
||||||
events_listener = asyncio.ensure_future(events.listen_for_events())
|
events_listener = asyncio.ensure_future(events.listen_for_events())
|
@ -21,10 +21,10 @@
|
|||||||
'''qvm-unpause - Unpause a domain'''
|
'''qvm-unpause - Unpause a domain'''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
|
|
||||||
|
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(
|
parser = qubesadmin.tools.QubesArgumentParser(
|
||||||
vmname_nargs='+',
|
vmname_nargs='+',
|
||||||
description='unpause a domain')
|
description='unpause a domain')
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ def main(args=None, app=None):
|
|||||||
for domain in args.domains:
|
for domain in args.domains:
|
||||||
try:
|
try:
|
||||||
domain.unpause()
|
domain.unpause()
|
||||||
except (IOError, OSError, qubesmgmt.exc.QubesException) as e:
|
except (IOError, OSError, qubesadmin.exc.QubesException) as e:
|
||||||
exit_code = 1
|
exit_code = 1
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
|
|
@ -26,10 +26,10 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import qubesmgmt
|
import qubesadmin
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.tools
|
import qubesadmin.tools
|
||||||
import qubesmgmt.utils
|
import qubesadmin.utils
|
||||||
|
|
||||||
|
|
||||||
def prepare_table(vd_list, full=False):
|
def prepare_table(vd_list, full=False):
|
||||||
@ -129,7 +129,7 @@ def list_volumes(args):
|
|||||||
if x.domains]
|
if x.domains]
|
||||||
else:
|
else:
|
||||||
result = [x for p in vd_dict.values() for x in p.values()]
|
result = [x for p in vd_dict.values() for x in p.values()]
|
||||||
qubesmgmt.tools.print_table(prepare_table(result, full=args.full))
|
qubesadmin.tools.print_table(prepare_table(result, full=args.full))
|
||||||
|
|
||||||
|
|
||||||
def revert_volume(args):
|
def revert_volume(args):
|
||||||
@ -139,7 +139,7 @@ def revert_volume(args):
|
|||||||
try:
|
try:
|
||||||
pool = app.pools[volume.pool]
|
pool = app.pools[volume.pool]
|
||||||
pool.revert(volume)
|
pool.revert(volume)
|
||||||
except qubesmgmt.exc.StoragePoolException as e:
|
except qubesadmin.exc.StoragePoolException as e:
|
||||||
print(str(e), file=sys.stderr)
|
print(str(e), file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ def extend_volumes(args):
|
|||||||
subcommand
|
subcommand
|
||||||
'''
|
'''
|
||||||
volume = args.volume
|
volume = args.volume
|
||||||
size = qubesmgmt.utils.parse_size(args.size)
|
size = qubesadmin.utils.parse_size(args.size)
|
||||||
volume.resize(size)
|
volume.resize(size)
|
||||||
|
|
||||||
|
|
||||||
@ -159,15 +159,15 @@ def init_list_parser(sub_parsers):
|
|||||||
list_parser = sub_parsers.add_parser('list', aliases=('ls', 'l'),
|
list_parser = sub_parsers.add_parser('list', aliases=('ls', 'l'),
|
||||||
help='list storage volumes')
|
help='list storage volumes')
|
||||||
list_parser.add_argument('-p', '--pool', dest='pools',
|
list_parser.add_argument('-p', '--pool', dest='pools',
|
||||||
action=qubesmgmt.tools.PoolsAction)
|
action=qubesadmin.tools.PoolsAction)
|
||||||
list_parser.add_argument('-i', '--internal', action='store_true',
|
list_parser.add_argument('-i', '--internal', action='store_true',
|
||||||
help='Show internal volumes')
|
help='Show internal volumes')
|
||||||
list_parser.add_argument(
|
list_parser.add_argument(
|
||||||
'--full', action='store_true',
|
'--full', action='store_true',
|
||||||
help='print full line for each POOL_NAME:VOLUME_ID & vm combination')
|
help='print full line for each POOL_NAME:VOLUME_ID & vm combination')
|
||||||
|
|
||||||
vm_name_group = qubesmgmt.tools.VmNameGroup(
|
vm_name_group = qubesadmin.tools.VmNameGroup(
|
||||||
list_parser, required=False, vm_action=qubesmgmt.tools.VmNameAction,
|
list_parser, required=False, vm_action=qubesadmin.tools.VmNameAction,
|
||||||
help='list volumes from specified domain(s)')
|
help='list volumes from specified domain(s)')
|
||||||
list_parser._mutually_exclusive_groups.append(vm_name_group)
|
list_parser._mutually_exclusive_groups.append(vm_name_group)
|
||||||
list_parser.set_defaults(func=list_volumes)
|
list_parser.set_defaults(func=list_volumes)
|
||||||
@ -179,7 +179,7 @@ def init_revert_parser(sub_parsers):
|
|||||||
'revert', aliases=('rv', 'r'),
|
'revert', aliases=('rv', 'r'),
|
||||||
help='revert volume to previous revision')
|
help='revert volume to previous revision')
|
||||||
revert_parser.add_argument(metavar='VM:VOLUME', dest='volume',
|
revert_parser.add_argument(metavar='VM:VOLUME', dest='volume',
|
||||||
action=qubesmgmt.tools.VMVolumeAction)
|
action=qubesadmin.tools.VMVolumeAction)
|
||||||
revert_parser.set_defaults(func=revert_volume)
|
revert_parser.set_defaults(func=revert_volume)
|
||||||
|
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ def init_extend_parser(sub_parsers):
|
|||||||
extend_parser = sub_parsers.add_parser(
|
extend_parser = sub_parsers.add_parser(
|
||||||
"extend", help="extend volume from domain")
|
"extend", help="extend volume from domain")
|
||||||
extend_parser.add_argument(metavar='VM:VOLUME', dest='volume',
|
extend_parser.add_argument(metavar='VM:VOLUME', dest='volume',
|
||||||
action=qubesmgmt.tools.VMVolumeAction)
|
action=qubesadmin.tools.VMVolumeAction)
|
||||||
extend_parser.add_argument('size', help='New size in bytes')
|
extend_parser.add_argument('size', help='New size in bytes')
|
||||||
extend_parser.set_defaults(func=extend_volumes)
|
extend_parser.set_defaults(func=extend_volumes)
|
||||||
|
|
||||||
@ -196,10 +196,10 @@ def get_parser():
|
|||||||
'''Create :py:class:`argparse.ArgumentParser` suitable for
|
'''Create :py:class:`argparse.ArgumentParser` suitable for
|
||||||
:program:`qvm-block`.
|
:program:`qvm-block`.
|
||||||
'''
|
'''
|
||||||
parser = qubesmgmt.tools.QubesArgumentParser(description=__doc__,
|
parser = qubesadmin.tools.QubesArgumentParser(description=__doc__,
|
||||||
want_app=True)
|
want_app=True)
|
||||||
parser.register('action', 'parsers',
|
parser.register('action', 'parsers',
|
||||||
qubesmgmt.tools.AliasedSubParsersAction)
|
qubesadmin.tools.AliasedSubParsersAction)
|
||||||
sub_parsers = parser.add_subparsers(
|
sub_parsers = parser.add_subparsers(
|
||||||
title='commands',
|
title='commands',
|
||||||
description="For more information see qvm-block command -h",
|
description="For more information see qvm-block command -h",
|
||||||
@ -217,7 +217,7 @@ def main(args=None, app=None):
|
|||||||
try:
|
try:
|
||||||
args = parser.parse_args(args, app=app)
|
args = parser.parse_args(args, app=app)
|
||||||
args.func(args)
|
args.func(args)
|
||||||
except qubesmgmt.exc.QubesException as e:
|
except qubesadmin.exc.QubesException as e:
|
||||||
parser.print_error(str(e))
|
parser.print_error(str(e))
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -29,7 +29,7 @@ import pkg_resources
|
|||||||
import docutils
|
import docutils
|
||||||
import docutils.core
|
import docutils.core
|
||||||
import docutils.io
|
import docutils.io
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
|
|
||||||
|
|
||||||
def format_doc(docstring):
|
def format_doc(docstring):
|
||||||
@ -74,7 +74,7 @@ def parse_size(size):
|
|||||||
size = size[:-len(unit)].strip()
|
size = size[:-len(unit)].strip()
|
||||||
return int(size) * multiplier
|
return int(size) * multiplier
|
||||||
|
|
||||||
raise qubesmgmt.exc.QubesException("Invalid size: {0}.".format(size))
|
raise qubesadmin.exc.QubesException("Invalid size: {0}.".format(size))
|
||||||
|
|
||||||
|
|
||||||
def mbytes_to_kmg(size):
|
def mbytes_to_kmg(size):
|
@ -21,15 +21,15 @@
|
|||||||
'''Qubes VM objects.'''
|
'''Qubes VM objects.'''
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import qubesmgmt.base
|
import qubesadmin.base
|
||||||
import qubesmgmt.exc
|
import qubesadmin.exc
|
||||||
import qubesmgmt.storage
|
import qubesadmin.storage
|
||||||
import qubesmgmt.features
|
import qubesadmin.features
|
||||||
import qubesmgmt.devices
|
import qubesadmin.devices
|
||||||
import qubesmgmt.firewall
|
import qubesadmin.firewall
|
||||||
|
|
||||||
|
|
||||||
class QubesVM(qubesmgmt.base.PropertyHolder):
|
class QubesVM(qubesadmin.base.PropertyHolder):
|
||||||
'''Qubes domain.'''
|
'''Qubes domain.'''
|
||||||
|
|
||||||
log = None
|
log = None
|
||||||
@ -44,9 +44,9 @@ class QubesVM(qubesmgmt.base.PropertyHolder):
|
|||||||
super(QubesVM, self).__init__(app, 'mgmt.vm.property.', name)
|
super(QubesVM, self).__init__(app, 'mgmt.vm.property.', name)
|
||||||
self._volumes = None
|
self._volumes = None
|
||||||
self.log = logging.getLogger(name)
|
self.log = logging.getLogger(name)
|
||||||
self.features = qubesmgmt.features.Features(self)
|
self.features = qubesadmin.features.Features(self)
|
||||||
self.devices = qubesmgmt.devices.DeviceManager(self)
|
self.devices = qubesadmin.devices.DeviceManager(self)
|
||||||
self.firewall = qubesmgmt.firewall.Firewall(self)
|
self.firewall = qubesadmin.firewall.Firewall(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -218,7 +218,7 @@ class QubesVM(qubesmgmt.base.PropertyHolder):
|
|||||||
for volname in volumes_list.decode('ascii').splitlines():
|
for volname in volumes_list.decode('ascii').splitlines():
|
||||||
if not volname:
|
if not volname:
|
||||||
continue
|
continue
|
||||||
self._volumes[volname] = qubesmgmt.storage.Volume(self.app,
|
self._volumes[volname] = qubesadmin.storage.Volume(self.app,
|
||||||
vm=self.name, vm_name=volname)
|
vm=self.name, vm_name=volname)
|
||||||
return self._volumes
|
return self._volumes
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ class QubesVM(qubesmgmt.base.PropertyHolder):
|
|||||||
stdouterr = p.communicate(input=input)
|
stdouterr = p.communicate(input=input)
|
||||||
|
|
||||||
if p.returncode:
|
if p.returncode:
|
||||||
raise qubesmgmt.exc.QubesVMError(self,
|
raise qubesadmin.exc.QubesVMError(self,
|
||||||
'service {!r} failed with retcode {!r}; '
|
'service {!r} failed with retcode {!r}; '
|
||||||
'stdout={!r} stderr={!r}'.format(
|
'stdout={!r} stderr={!r}'.format(
|
||||||
service, p.returncode, *stdouterr))
|
service, p.returncode, *stdouterr))
|
@ -1,7 +1,7 @@
|
|||||||
Name: qubes-core-mgmt-client
|
Name: qubes-core-admin-client
|
||||||
Version: %(cat version)
|
Version: %(cat version)
|
||||||
Release: 0.1%{?dist}
|
Release: 0.1%{?dist}
|
||||||
Summary: Qubes OS management client tools
|
Summary: Qubes OS admin client tools
|
||||||
|
|
||||||
Group: Qubes
|
Group: Qubes
|
||||||
License: LGPLv2.1+
|
License: LGPLv2.1+
|
||||||
@ -13,7 +13,7 @@ BuildRequires: python2-devel
|
|||||||
BuildRequires: python3-devel
|
BuildRequires: python3-devel
|
||||||
BuildRequires: python3-sphinx
|
BuildRequires: python3-sphinx
|
||||||
BuildRequires: python3-dbus
|
BuildRequires: python3-dbus
|
||||||
Requires: python3-qubesmgmt
|
Requires: python3-qubesadmin
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%if 0%{?qubes_builder}
|
%if 0%{?qubes_builder}
|
||||||
@ -23,19 +23,19 @@ BuildArch: noarch
|
|||||||
%description
|
%description
|
||||||
This package include managemt tools, like qvm-*.
|
This package include managemt tools, like qvm-*.
|
||||||
|
|
||||||
%package -n python2-qubesmgmt
|
%package -n python2-qubesadmin
|
||||||
Summary: Python2 module qubesmgmt
|
Summary: Python2 module qubesadmin
|
||||||
Requires: python2-daemon
|
Requires: python2-daemon
|
||||||
|
|
||||||
%description -n python2-qubesmgmt
|
%description -n python2-qubesadmin
|
||||||
Python2 module qubesmgmt.
|
Python2 module qubesadmin.
|
||||||
|
|
||||||
%package -n python3-qubesmgmt
|
%package -n python3-qubesadmin
|
||||||
Summary: Python3 module qubesmgmt
|
Summary: Python3 module qubesadmin
|
||||||
Requires: python3-daemon
|
Requires: python3-daemon
|
||||||
|
|
||||||
%description -n python3-qubesmgmt
|
%description -n python3-qubesadmin
|
||||||
Python3 module qubesmgmt.
|
Python3 module qubesadmin.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%if !0%{?qubes_builder}
|
%if !0%{?qubes_builder}
|
||||||
@ -64,13 +64,13 @@ make -C doc DESTDIR=$RPM_BUILD_ROOT \
|
|||||||
%{_mandir}/man1/qvm-*.1*
|
%{_mandir}/man1/qvm-*.1*
|
||||||
%{_mandir}/man1/qubes*.1*
|
%{_mandir}/man1/qubes*.1*
|
||||||
|
|
||||||
%files -n python2-qubesmgmt
|
%files -n python2-qubesadmin
|
||||||
%{python_sitelib}/qubesmgmt-*egg-info
|
%{python_sitelib}/qubesadmin-*egg-info
|
||||||
%{python_sitelib}/qubesmgmt
|
%{python_sitelib}/qubesadmin
|
||||||
|
|
||||||
%files -n python3-qubesmgmt
|
%files -n python3-qubesadmin
|
||||||
%{python3_sitelib}/qubesmgmt-*egg-info
|
%{python3_sitelib}/qubesadmin-*egg-info
|
||||||
%{python3_sitelib}/qubesmgmt
|
%{python3_sitelib}/qubesadmin
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
@ -10,4 +10,4 @@ export PYTHONPATH
|
|||||||
[ -r version ] || ln -s ${ROOTDIR}/version ./
|
[ -r version ] || ln -s ${ROOTDIR}/version ./
|
||||||
[ -r setup.py ] || ln -s ${ROOTDIR}/setup.py ./
|
[ -r setup.py ] || ln -s ${ROOTDIR}/setup.py ./
|
||||||
"${PYTHON}" ./setup.py egg_info --egg-base "${TESTPYTHONPATH}"
|
"${PYTHON}" ./setup.py egg_info --egg-base "${TESTPYTHONPATH}"
|
||||||
"${PYTHON}" -m coverage run --rcfile=$ROOTDIR/ci/coveragerc -m unittest discover -s qubesmgmt/tests -p '*.py' -v "$@"
|
"${PYTHON}" -m coverage run --rcfile=$ROOTDIR/ci/coveragerc -m unittest discover -s qubesadmin/tests -p '*.py' -v "$@"
|
||||||
|
18
setup.py
18
setup.py
@ -5,25 +5,25 @@ import sys
|
|||||||
|
|
||||||
exclude=[]
|
exclude=[]
|
||||||
if sys.version_info[0:2] < (3, 5):
|
if sys.version_info[0:2] < (3, 5):
|
||||||
exclude = ['qubesmgmt.events', 'qubesmgmt.tools', 'qubesmgmt.tests.tools']
|
exclude = ['qubesadmin.events', 'qubesadmin.tools', 'qubesadmin.tests.tools']
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='qubesmgmt',
|
name='qubesadmin',
|
||||||
version=open('version').read().strip(),
|
version=open('version').read().strip(),
|
||||||
author='Invisible Things Lab',
|
author='Invisible Things Lab',
|
||||||
author_email='marmarek@invisiblethingslab.com',
|
author_email='marmarek@invisiblethingslab.com',
|
||||||
description='Qubes mgmt API package',
|
description='Qubes Admin API package',
|
||||||
license='LGPL2.1+',
|
license='LGPL2.1+',
|
||||||
url='https://www.qubes-os.org/',
|
url='https://www.qubes-os.org/',
|
||||||
packages=setuptools.find_packages(exclude=exclude),
|
packages=setuptools.find_packages(exclude=exclude),
|
||||||
entry_points={
|
entry_points={
|
||||||
'qubesmgmt.vm': [
|
'qubesadmin.vm': [
|
||||||
'AppVM = qubesmgmt.vm:AppVM',
|
'AppVM = qubesadmin.vm:AppVM',
|
||||||
'TemplateVM = qubesmgmt.vm:TemplateVM',
|
'TemplateVM = qubesadmin.vm:TemplateVM',
|
||||||
'StandaloneVM = qubesmgmt.vm:StandaloneVM',
|
'StandaloneVM = qubesadmin.vm:StandaloneVM',
|
||||||
'AdminVM = qubesmgmt.vm:AdminVM',
|
'AdminVM = qubesadmin.vm:AdminVM',
|
||||||
'DispVM = qubesmgmt.vm:DispVM',
|
'DispVM = qubesadmin.vm:DispVM',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
2
test-packages/.gitignore
vendored
2
test-packages/.gitignore
vendored
@ -1 +1 @@
|
|||||||
qubesmgmt.egg-info
|
qubesadmin.egg-info
|
||||||
|
Loading…
Reference in New Issue
Block a user