aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Niedbalski R <jnr@metaklass.org>2014-04-15 13:00:02 -0400
committerJorge Niedbalski R <jnr@metaklass.org>2014-04-15 13:23:44 -0400
commitbfdde0d9cba13b577ddf9ae24f00d8ca920ac211 (patch)
tree21b02b94f0ba00d243ab99ac42d45cc90e854e5d
parenteefc895b1cbfcb347d2f35828e92e606bf8dc457 (diff)
downloadsos-bfdde0d9cba13b577ddf9ae24f00d8ca920ac211.tar.gz
[plugins/maas] added `maas commissioning list` output to the command output list
-rw-r--r--sos/plugins/maas.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/sos/plugins/maas.py b/sos/plugins/maas.py
index 9a9b88ae..8da94498 100644
--- a/sos/plugins/maas.py
+++ b/sos/plugins/maas.py
@@ -16,12 +16,33 @@
from sos.plugins import Plugin, UbuntuPlugin
+
class Maas(Plugin, UbuntuPlugin):
"""MAAS Plugin
"""
plugin_name = 'maas'
+ option_list = [
+ ('profile-name',
+ 'The name with which you will later refer to this remote', '', False),
+ ('url', 'The URL of the remote API', '', False),
+ ('credentials',
+ 'The credentials, also known as the API key', '', False)
+ ]
+
+ def _has_login_options(self):
+ return self.get_option("url") and self.get_option("credentials") \
+ and self.get_option("profile-name")
+
+ def _remote_api_login(self):
+ ret = self.call_ext_prog("maas login %s %s %s" % (
+ self.get_option("profile-name"),
+ self.get_option("url"),
+ self.get_option("credentials")))
+
+ return ret['status'] == 0
+
def setup(self):
self.add_copy_specs([
"/etc/squid-deb-proxy",
@@ -37,4 +58,12 @@ class Maas(Plugin, UbuntuPlugin):
"maas dumpdata"
])
+ if self._has_login_options():
+ if self._remote_api_login():
+ self.add_cmd_output("maas %s commissioning-results list" %
+ self.get_option("profile-name"))
+ else:
+ self.log_error(
+ "Cannot login into Maas remote API with provided creds.")
+
# vim: et ts=4 sw=4