Commit Graph

46 Commits

Author SHA1 Message Date
Marek Marczykowski-Górecki
2472be9d61
Implement property_help() method 2017-03-13 04:37:29 +01:00
Marek Marczykowski-Górecki
f027aa5385
Improve handling rejected access to properties
When qubesd reject access to property (do not return anything), it may
mean various things - invalid property, permission denied, or even
invalid VM. Handle all of those with exception inheriting from
AttributeError.
2017-03-13 04:37:29 +01:00
Marek Marczykowski-Górecki
5615510da5
Add specific exception for qubesd communication error 2017-03-13 04:37:28 +01:00
Marek Marczykowski-Górecki
9d5e974c5b
Simplify reading data from local socket 2017-03-13 04:37:28 +01:00
Marek Marczykowski-Górecki
f6e48cb3ff
Rename methods for global properties
Finally we've settled for `mgmt.property.`, instead of
`mgmt.global.property.` prefix.

QubesOS/qubes-issues#853
2017-03-13 04:37:28 +01:00
Marek Marczykowski-Górecki
435a465d70
tools/qvm-ls: kill fixed column width
Calculate column width dynamically, besed on actual contents.
2017-03-13 04:37:28 +01:00
Marek Marczykowski-Górecki
fea3d3391f
tools/qvm-ls: adjust VM classes
QubesOS/qubes-issues#853
2017-03-11 09:40:08 +01:00
Marek Marczykowski-Górecki
554081498d
tools/qvm-ls: assume "unknown" colums being VM properties
Listing VM properties require specific object, so instead of collecting
all properties from all VMs (which may be denied by policy), simply
try to access properties (and display '-' when it fails).

QubesOS/qubes-issues#853
2017-03-11 09:39:09 +01:00
Marek Marczykowski-Górecki
77250ab529
tools/qvm-ls: copy mostly-unmodified version from core-admin 2017-03-09 02:52:37 +01:00
Marek Marczykowski-Górecki
6dd6d9e254
tests: add tests for simple tools
QubesOS/qubes-issues#853
2017-03-09 02:46:13 +01:00
Marek Marczykowski-Górecki
21d60eff4c
Add vm.shutdown(force) parameter
But not it's implementation (currently not specified in API).

QubesOS/qubes-issues#853
2017-03-09 02:39:54 +01:00
Marek Marczykowski-Górecki
795a06e400
tools: pause/unpause/shutdown - don't stop on first failed VM
But still report a failure with exit code if any of them failed.

QubesOS/qubes-issues#853
2017-03-09 02:39:54 +01:00
Marek Marczykowski-Górecki
7baa7e4862
Import full exceptions hierarchy
QubesOS/qubes-issues#853
2017-03-09 02:39:54 +01:00
Marek Marczykowski-Górecki
484743faf0
tests: add qubes-prefs tests
Based on qvm-prefs.
2017-03-09 02:39:53 +01:00
Marek Marczykowski-Górecki
e0af402c16
tools/qvm-kill: don't use deprecated force_shutdown method
QubesOS/qubes-issues#853
2017-03-09 02:39:53 +01:00
Marek Marczykowski-Górecki
69396040fd
Fix global properties handling
API name isn't 'mgmt.global.*' - discussed options are
'mgmt.global.property.*' or 'mgmt.property.*'. Lets settle on the
former.

QubesOS/qubes-issues#853
2017-03-09 02:39:53 +01:00
Marek Marczykowski-Górecki
4ffd44da49
tools/qvm-prefs: handle invalid properties by catching AttributeError
This may avoid unneded qubesd call (listing properties).
2017-03-09 02:39:53 +01:00
Marek Marczykowski-Górecki
e4c2294ce0
tools/qvm-prefs: adjust for qubesmgmt module
list_properties() returns strings, not property objects.
2017-03-09 02:39:52 +01:00
Marek Marczykowski-Górecki
bf03f6630f
Handle python standard exceptions in qubesd response
This may be useful for things like AttributeError, ValueError etc.
Use error name directly as exception name without much validation, as it
comes from dom0.
2017-03-09 02:39:52 +01:00
Marek Marczykowski-Górecki
6b8bbd9c51
tests: adjust StdoutBuffer for python2/python3 compatibility
io.StringIO expects unicode writes, while string literal on python2 are
bytes. Act accordingly.
2017-03-09 02:39:52 +01:00
Marek Marczykowski-Górecki
a575bc3422
tools: allow supplying app object to main function
This is mostly for tests, which use dummy app instance.
2017-03-09 02:39:52 +01:00
Marek Marczykowski-Górecki
61731a9490
tools: kill --force-root and --qubesxml arguments
Those are no longer useful, as all actions are delegated to qubesd. Keep
--force-root argument (but ignore it and hide from help) for backward
compatibility with various scripts.

Fixes QubesOS/qubes-issues#2684
2017-03-09 02:39:51 +01:00
Marek Marczykowski-Górecki
32bd75da77
Update license headers
Update GPL->LGPL for tools moved from core-admin repository.
While at it, change mailing address to www link, as suggested by FSF.

Cc: @woju
Cc: @rootkovska
2017-03-09 02:39:51 +01:00
Marek Marczykowski-Górecki
fe74b05049
tests: migrate basic tools tests 2017-03-09 02:39:51 +01:00
Marek Marczykowski-Górecki
6b8d58885b
tools: reduce code duplication
Have one implementation for all property-related tools.
2017-03-09 02:39:51 +01:00
Marek Marczykowski-Górecki
bb770b4744
tools: include a few simple tools
QubesOS/qubes-issues#853
2017-03-09 02:39:50 +01:00
Marek Marczykowski-Górecki
a813d50267
tools: adjust for qubesmgmt module
For now comment out HelpPropertiesAction, as we don't have VM classes
here and accessing properties help require VM instances.
This needs some better idea...
2017-03-08 15:55:52 +01:00
Marek Marczykowski-Górecki
2e2ce8454b
tools: copy unmodified file from core-admin 2017-03-08 15:55:51 +01:00
Marek Marczykowski-Górecki
7d7f1724ff
make pylint happy
Add mock dbus module
2017-03-02 02:05:35 +01:00
Marek Marczykowski-Górecki
e826ebff53
utils: copy tools-related utility functions 2017-03-02 02:05:35 +01:00
Marek Marczykowski-Górecki
f59ff0c641
mgmt.vm.volume.* API support
QubesOS/qubes-issues#853
2017-03-01 23:49:24 +01:00
Marek Marczykowski-Górecki
5f81b9b809
Fix refreshing VM cache on python3
dict.items() iterator don't like adding/removing items at the same time.
2017-03-01 23:49:23 +01:00
Marek Marczykowski-Górecki
2b1ebba547
vm: add actual VM classes
QubesOS/qubes-issues#853
2017-03-01 23:49:23 +01:00
Marek Marczykowski-Górecki
0abff5b57a
Add logging module
Based on qubes.log module from core-admin
2017-03-01 23:49:23 +01:00
Marek Marczykowski-Górecki
851ba6aedb
Fix handling '%d' in exception message
QubesOS/qubes-issues#853
2017-03-01 23:49:21 +01:00
Marek Marczykowski-Górecki
45ab24ce12
Fix local socket communication
Don't try to send 'None' argument.
Close writing end after sending full request.

QubesOS/qubes-issues#853
2017-03-01 23:49:21 +01:00
Marek Marczykowski-Górecki
3e73b242d1
Add missing docstrings, require them by pylint 2017-03-01 23:49:21 +01:00
Marek Marczykowski-Górecki
61cb9887af
Implement simple VM actions
QubesOS/qubes-issues#853
2017-03-01 23:49:21 +01:00
Marek Marczykowski-Górecki
4bbc7a6b1f
Cache vm.name property
It doesn't make sense to send mgmt call to _named_ VM just to ask for
its name. Use value that QubesVM object already have.
This also means we can safely access vm.name, no need to touch any
private attribute.

QubesOS/qubes-issues#853
2017-03-01 23:49:21 +01:00
Marek Marczykowski-Górecki
c298eddd16
Avoid cyclic imports
QubesOS/qubes-issues#853
2017-03-01 23:49:20 +01:00
Marek Marczykowski-Górecki
8f92250665
Fix py3k compatibility
QubesOS/qubes-issues#853
2017-03-01 23:49:20 +01:00
Marek Marczykowski-Górecki
544870f1ad
make pylint happy again 2017-03-01 23:49:20 +01:00
Marek Marczykowski-Górecki
b4e6089cd5
make pylint happy 2017-03-01 23:49:19 +01:00
Marek Marczykowski-Górecki
745d16a879
Rename '_do_qubesd_call' to 'qubesd_call'
This method don't need to be private. Also the 'do_' prefix is
superfluous - methods typically do something.

QubesOS/qubes-issues#853
2017-03-01 23:49:19 +01:00
Marek Marczykowski-Górecki
58c940b5c0
Rename qubesmgmt.property.DEFAULT to qubesmgmt.DEFAULT
Don't shadow builtin 'property' type. We don't need to kee compatibility
with actual core3 implementation yet, so don't make the same mistake
twice.
2017-03-01 23:49:18 +01:00
Marek Marczykowski-Górecki
3a2e0b770b
Initial commit
First minimal version, with just listing VMs and handling properties.

QubesOS/qubes-issues#853
2017-03-01 23:48:53 +01:00