Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions qubesadmin/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class QubesNoTemplateError(QubesVMError):
"""Cannot start domain, because there is no template"""


class QubesVMAlreadyStartedError(QubesVMError):
"""Requested qube to start, but it's already running"""


class QubesPoolInUseError(QubesException):
"""VM is in use, cannot remove."""

Expand Down Expand Up @@ -236,5 +240,6 @@ def __init__(self, prop: str):
class QubesNotesError(QubesException):
"""Some problem with qube notes."""


# legacy name
QubesDaemonNoResponseError = QubesDaemonAccessError
23 changes: 23 additions & 0 deletions qubesadmin/tests/tools/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,26 @@ def test_105_set_prop_positional(self):
args = parser.parse_args(['testvalue'])
self.assertIn(
('testprop', 'testvalue'), args.properties.items())


class TC_02_QubesArgumentParser(qubesadmin.tests.QubesTestCase):
def test_000_domain_preserve_order(self):
self.app.expected_calls[('dom0', 'admin.vm.List', None, None)] = (
b'0\x00some-vm class=AppVM state=Running\n'
b'some-a class=AppVM state=Halted\n'
b'some-b class=AppVM state=Paused\n'
)

parser = qubesadmin.tools.QubesArgumentParser(vmname_nargs="+")
wanted_args = ["some-vm", "some-a", "some-vm"]
args = parser.parse_args(wanted_args, app=self.app)
self.assertEqual(
["some-a", "some-b", "some-vm"],
[qube.name for qube in self.app.domains],
"app namespace must have domains in alphabetical order",
)
self.assertEqual(
["some-vm", "some-a"],
[qube.name for qube in args.domains],
"args namespace must have domains in input order",
)
10 changes: 5 additions & 5 deletions qubesadmin/tests/tools/qvm_kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def test_004_other_error(self):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
with qubesadmin.tests.tools.StderrBuffer() as stderr:
self.assertEqual(
qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app),
1)
with self.assertRaises(SystemExit):
self.assertEqual(
qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app),
1)
self.assertAllCalled()
self.assertIn("Failed to kill 'some-vm': Error message",
stderr.getvalue())
self.assertIn("Failed to kill: some-vm", stderr.getvalue())
Loading