diff --git a/Makefile b/Makefile index a90664b..0a62a20 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ $(NAME)-$(VERSION).tar.gz: clean clean: @rm -fv *~ .*~ changenew ChangeLog.old $(NAME)-$(VERSION).tar.gz + @rm -rfv $(DIST_BUILD_DIR)/* @rm -rf rpm-build @for i in `find . -iname *.pyc`; do \ rm $$i; \ diff --git a/eucalyptus-sos-plugins.spec b/eucalyptus-sos-plugins.spec index 9a45a2a..0d4acfa 100644 --- a/eucalyptus-sos-plugins.spec +++ b/eucalyptus-sos-plugins.spec @@ -8,7 +8,7 @@ Source0: %{name}-%{version}.tar.gz Group: Applications/System License: GPLv2+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot -BuildArch: noarch +BuildArch: x86_64 Url: http://github.com/eucalyptus/eucalyptus-sosreport-plugins BuildRequires: python-devel Requires: sos diff --git a/sos/plugins/eucacluster.py b/sos/plugins/eucacluster.py index e4a0b9d..366483e 100644 --- a/sos/plugins/eucacluster.py +++ b/sos/plugins/eucacluster.py @@ -1,21 +1,21 @@ -## Copyright (C) 2013 Eucalyptus Systems, Inc. +# Copyright (C) 2013 Eucalyptus Systems, Inc. -### This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools -import os + class eucacluster(sos.plugintools.PluginBase): """Eucalyptus Cloud - Cluster Controller diff --git a/sos/plugins/eucaconsole.py b/sos/plugins/eucaconsole.py index 41f9de6..91ad25c 100644 --- a/sos/plugins/eucaconsole.py +++ b/sos/plugins/eucaconsole.py @@ -1,22 +1,23 @@ -## Copyright (C) 2013 Eucalyptus Systems, Inc. +# Copyright (C) 2013 Eucalyptus Systems, Inc. -### This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools import os + class eucaconsole(sos.plugintools.PluginBase): """Eucalyptus Cloud - Console """ @@ -33,8 +34,8 @@ def setup(self): """ self.addCopySpec("/etc/eucalyptus-console") """ - Check to see if /var/log/eucalyptus-console exists - this was a change for Eucalyptus 3.4.0-1 - If it doesn't exists, then the Eucalyptus User Console logs will be in /var/log/messages + Check if /var/log/eucalyptus-console exists (Eucalyptus 3.4.0-1) + If not present, then Console logs are in /var/log/messages """ if os.path.exists('/var/log/eucalyptus-console'): self.addCopySpec("/var/log/eucalyptus-console/*") diff --git a/sos/plugins/eucacore.py b/sos/plugins/eucacore.py index 1b62004..19a68a8 100644 --- a/sos/plugins/eucacore.py +++ b/sos/plugins/eucacore.py @@ -1,23 +1,24 @@ -## Copyright (C) 2013 Eucalyptus Systems, Inc. +# Copyright (C) 2013 Eucalyptus Systems, Inc. -### This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools import os import glob + class eucacore(sos.plugintools.PluginBase): """Eucalyptus Cloud - Core """ @@ -32,10 +33,14 @@ def setup(self): self.addCopySpec("/var/log/eucalyptus/*") self.addCopySpec("/var/lib/eucalyptus/keys") if os.path.isfile('/usr/bin/sha1sum'): - self.collectExtOutput("find /var/lib/eucalyptus/keys -type f -print | xargs -I {} sha1sum {}", suggest_filename="sha1sum-eucalyptus-keys") + self.collectExtOutput("find /var/lib/eucalyptus/keys \ + -type f -print | xargs -I {} sha1sum {}", + suggest_filename="sha1sum-eucalyptus-keys") hprof_list = glob.glob('/var/log/eucalyptus/*.hprof') if hprof_list: - self.collectExtOutput("rm -rf /var/log/eucalyptus/*.hprof", suggest_filename="hprof-removal") + self.collectExtOutput("rm -rf /var/log/eucalyptus/*.hprof", + suggest_filename="hprof-removal") if os.path.isfile('/sbin/iptables-save'): - self.collectExtOutput("/sbin/iptables-save --counters", suggest_filename="iptables-save-counters") + self.collectExtOutput("/sbin/iptables-save --counters", + suggest_filename="iptables-save-counters") return diff --git a/sos/plugins/eucadb.py b/sos/plugins/eucadb.py index 5f8a1af..ad20901 100644 --- a/sos/plugins/eucadb.py +++ b/sos/plugins/eucadb.py @@ -1,76 +1,167 @@ -## Copyright (C) 2013 Eucalyptus Systems, Inc. +# Copyright (C) 2013 Eucalyptus Systems, Inc. -### This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools -import os, subprocess +import os +import subprocess + class eucadb(sos.plugintools.PluginBase): """Eucalyptus Cloud - PostgreSQL """ def checkenabled(self): - if self.isInstalled("postgresql91") and self.isInstalled("postgresql91-server") and self.isInstalled("eucalyptus-cloud"): + if (self.isInstalled("postgresql91") and + self.isInstalled("postgresql91-server") and + self.isInstalled("eucalyptus-cloud")): return True return False def check_postgres(self): """ - Check for postgres process using pgrep (since eucalyptus-cloud controls it and not /sbin/service) + Check postgres process using pgrep (eucalyptus-cloud controls it) """ postgres_pgrep_cmd = ["/usr/bin/pgrep", "postgres"] try: - postgres_pgrep_chk, unused_val = subprocess.Popen(postgres_pgrep_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + postgres_chk, unused_val = subprocess.Popen( + postgres_pgrep_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: - if 'No such' in error_string: + if 'No such' in e.strerror: self.addDiagnose("Error checking postgres process status") raise OSError(e) else: self.addDiagnose("Error: %s" % e) raise OSError(e) - if postgres_pgrep_chk: - for proc in postgres_pgrep_chk.splitlines(): + if postgres_chk: + for proc in postgres_chk.splitlines(): if not proc: raise else: - self.addDiagnose("Postgres services are running: " + proc + ".") + self.addDiagnose("Postgres is running: " + proc + ".") else: self.addDiagnose("Error checking postgres process status") - print "### Postgres process doesn't seem to be running. Make sure eucalyptus-cloud is running." + print "### postgres/eucalyptus-cloud doesn't seem to be running." raise return True def setup(self): - if os.path.isfile('/usr/pgsql-9.1/bin/pg_dump') and self.check_postgres(): - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_auth", suggest_filename="eucalyptus_auth.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_cloud", suggest_filename="eucalyptus_cloud.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_config", suggest_filename="eucalyptus_config.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_dns", suggest_filename="eucalyptus_dns.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root database_events", suggest_filename="database_events.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_faults", suggest_filename="eucalyptus_faults.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_general", suggest_filename="eucalyptus_general.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_records", suggest_filename="eucalyptus_records.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root --exclude-table=reporting_instance_usage_events eucalyptus_reporting", suggest_filename="eucalyptus_reporting.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_storage", suggest_filename="eucalyptus_storage.sql", timeout = 600) - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_walrus", suggest_filename="eucalyptus_walrus.sql", timeout = 600) + if ( + os.path.isfile('/usr/pgsql-9.1/bin/pg_dump') + and self.check_postgres() + ): + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_auth", + suggest_filename="eucalyptus_auth.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_cloud", + suggest_filename="eucalyptus_cloud.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 \ + -U root eucalyptus_config", + suggest_filename="eucalyptus_config.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_dns", + suggest_filename="eucalyptus_dns.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U root database_events", + suggest_filename="database_events.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 \ + -U root eucalyptus_faults", + suggest_filename="eucalyptus_faults.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 \ + -U root eucalyptus_general", + suggest_filename="eucalyptus_general.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 \ + -U root eucalyptus_records", + suggest_filename="eucalyptus_records.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U root \ + --exclude-table=reporting_instance_usage_events \ + eucalyptus_reporting", + suggest_filename="eucalyptus_reporting.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U \ + root eucalyptus_storage", + suggest_filename="eucalyptus_storage.sql", + timeout=600 + ) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U \ + root eucalyptus_walrus", + suggest_filename="eucalyptus_walrus.sql", + timeout=600 + ) if self.isInstalled("eucalyptus-enterprise-vmware-broker"): - self.collectExtOutput("/usr/pgsql-9.1/bin/pg_dump -c -o -h /var/lib/eucalyptus/db/data -p 8777 -U root eucalyptus_vmwarebroker", suggest_filename="eucalyptus_vmwarebroker.sql", timeout = 600) - - if os.path.isfile('/usr/pgsql-9.1/bin/psql') and self.check_postgres(): - self.collectExtOutput("/usr/pgsql-9.1/bin/psql -h /var/lib/eucalyptus/db/data -p 8777 -U root -c \"SELECT pg_database.datname,pg_database_size(pg_database.datname),pg_size_pretty(pg_database_size(pg_database.datname)) FROM pg_database ORDER BY pg_database_size DESC;\" -d database_events", suggest_filename="database_sizes.txt", timeout = 600) + self.collectExtOutput( + "/usr/pgsql-9.1/bin/pg_dump -c -o -h \ + /var/lib/eucalyptus/db/data -p 8777 -U \ + root eucalyptus_vmwarebroker", + suggest_filename="eucalyptus_vmwarebroker.sql", + timeout=600 + ) + + if ( + os.path.isfile('/usr/pgsql-9.1/bin/psql') and + self.check_postgres() + ): + self.collectExtOutput( + "/usr/pgsql-9.1/bin/psql -h /var/lib/eucalyptus/db/data \ + -p 8777 -U root -c \"SELECT \ + pg_database.datname,pg_database_size(pg_database.datname),\ + pg_size_pretty(pg_database_size(pg_database.datname)) \ + FROM pg_database ORDER BY pg_database_size DESC;\" \ + -d database_events", + suggest_filename="database_sizes.txt", + timeout=600 + ) if os.path.isfile('/var/lib/eucalyptus/db/data/pg_hba.conf'): self.addCopySpec('/var/lib/eucalyptus/db/data/pg_hba.conf') diff --git a/sos/plugins/eucafrontend.py b/sos/plugins/eucafrontend.py index 6422afa..89816fd 100644 --- a/sos/plugins/eucafrontend.py +++ b/sos/plugins/eucafrontend.py @@ -1,29 +1,35 @@ -## Copyright (C) 2013 Eucalyptus Systems, Inc. +# Copyright (C) 2013 Eucalyptus Systems, Inc. -### This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools -import os, subprocess +import os +import subprocess import tempfile import re + class eucafrontend(sos.plugintools.PluginBase): """Eucalyptus Cloud - Frontend """ def checkenabled(self): - if self.isInstalled("euca2ools") and self.isInstalled("eucalyptus-admin-tools") and self.isInstalled("eucalyptus-cloud"): + if ( + self.isInstalled("euca2ools") and + self.isInstalled("eucalyptus-admin-tools") and + self.isInstalled("eucalyptus-cloud") + ): return True return False @@ -34,44 +40,52 @@ def checkversion(self, pkg): def clc_status(self): clc_check_cmd = ["/sbin/service", "eucalyptus-cloud", "status"] """ - Check for eucalyptus-cloud process + Check for eucalyptus-cloud process """ try: - clc_check_output,unused_val = subprocess.Popen(clc_check_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + clc_check_output, unused_val = subprocess.Popen( + clc_check_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: + error_string = '%s' % e if 'No such' in error_string: - self.addDiagnose("Error checking eucalyptus-cloud process status") + self.addDiagnose("Error checking eucalyptus-cloud process") raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) + raise OSError(e) if re.match("^Eucalyptus services are running", clc_check_output): self.addDiagnose("Eucalyptus services are running") pass else: """ - Check for eucalyptus-cloud process (in case error with /sbin/service check) + Check eucalyptus-cloud process (in case error with /sbin/service) """ clc_pgrep_cmd = ["/usr/bin/pgrep", "eucalyptus"] try: - clc_pgrep_chk, unused_val = subprocess.Popen(clc_pgrep_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + clc_pgrep_chk, unused_val = subprocess.Popen( + clc_pgrep_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: + error_string = '%s' % e if 'No such' in error_string: - self.addDiagnose("Error checking eucalyptus-cloud process status") + self.addDiagnose("Error eucalyptus-cloud process status") raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + if clc_pgrep_chk: for proc in clc_pgrep_chk.splitlines(): if not proc: raise else: - self.addDiagnose("Eucalyptus services are running: " + proc + ".") + self.addDiagnose("Eucalyptus services: " + proc + ".") else: - self.addDiagnose("Error checking eucalyptus-cloud process status") + self.addDiagnose("Error: eucalyptus-cloud process status") print "### eucalyptus-cloud process doesn't seem to be running" raise @@ -85,20 +99,29 @@ def eucacreds_setup(self): self.addDiagnose("Error creating directory under /tmp") raise OSError(e) - getcreds_cmd = ["/usr/sbin/euca-get-credentials", "-a", "eucalyptus", "-u", "admin", mkdir_output + "/admin.zip"] - unzip_cmd = ["/usr/bin/unzip", mkdir_output + "/admin.zip", "-d", mkdir_output ] + getcreds_cmd = ["/usr/sbin/euca-get-credentials", + "-a", "eucalyptus", "-u", "admin", + mkdir_output + "/admin.zip"] + unzip_cmd = ["/usr/bin/unzip", + mkdir_output + "/admin.zip", + "-d", mkdir_output] try: - getcreds_output = subprocess.Popen(getcreds_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + subprocess.Popen(getcreds_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: error_string = '%s' % e if 'No such' in error_string: - self.addDiagnose("Error grabbing eucalyptus/admin creds. Is CLC up?") + self.addDiagnose("Error grabbing \ + eucalyptus/admin creds. Is CLC up?") raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) + raise OSError(e) try: - unzip_output = subprocess.Popen(unzip_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + subprocess.Popen(unzip_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: error_string = '%s' % e if 'No such' in error_string: @@ -106,7 +129,7 @@ def eucacreds_setup(self): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) + raise OSError(e) return mkdir_output def get_access_key(self, tmp_dir): @@ -118,10 +141,11 @@ def get_access_key(self, tmp_dir): for line in eucarc_file: if re.search("^export EC2_ACCESS_KEY", line): name, var = line.partition("=")[::2] - access_key = var.replace('\'','').strip() + access_key = var.replace('\'', '').strip() return access_key if access_key is None: - self.addDiagnose("Error grabbing EC2_ACCESS_KEY from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing EC2_ACCESS_KEY \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -130,8 +154,8 @@ def get_access_key(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_secret_key(self, tmp_dir): """ Grab EC2_SECRET_KEY from unzip admin/eucalyptus credentials @@ -141,10 +165,11 @@ def get_secret_key(self, tmp_dir): for line in eucarc_file: if re.search("^export EC2_SECRET_KEY", line): name, var = line.partition("=")[::2] - secret_key = var.replace('\'','').strip() + secret_key = var.replace('\'', '').strip() return secret_key if secret_key is None: - self.addDiagnose("Error grabbing EC2_SECRET_KEY from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing EC2_SECRET_KEY \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -153,8 +178,8 @@ def get_secret_key(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_account_id(self, tmp_dir): """ Grab EC2_USER_ID from unzip admin/eucalyptus credentials @@ -164,10 +189,11 @@ def get_account_id(self, tmp_dir): for line in eucarc_file: if re.search("^export EC2_USER_ID", line): name, var = line.partition("=")[::2] - account_id = var.replace('\'','').strip() + account_id = var.replace('\'', '').strip() return account_id if account_id is None: - self.addDiagnose("Error grabbing EC2_USER_ID from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing EC2_USER_ID \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -176,7 +202,7 @@ def get_account_id(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) + raise OSError(e) def get_s3_url(self, tmp_dir): """ @@ -190,7 +216,8 @@ def get_s3_url(self, tmp_dir): s3_url = var.strip() return s3_url if s3_url is None: - self.addDiagnose("Error grabbing S3_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing S3_URL \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -199,8 +226,8 @@ def get_s3_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_ec2_url(self, tmp_dir): """ Grab EC2_URL from unzip admin/eucalyptus credentials @@ -213,7 +240,8 @@ def get_ec2_url(self, tmp_dir): ec2_url = var.strip() return ec2_url if ec2_url is None: - self.addDiagnose("Error grabbing EC2_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing EC2_URL \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -222,8 +250,8 @@ def get_ec2_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_iam_url(self, tmp_dir): """ Grab EUARE_URL from unzip admin/eucalyptus credentials @@ -236,7 +264,8 @@ def get_iam_url(self, tmp_dir): iam_url = var.strip() return iam_url if iam_url is None: - self.addDiagnose("Error grabbing EUARE_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing EUARE_URL \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -245,8 +274,8 @@ def get_iam_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_autoscale_url(self, tmp_dir): """ Grab AWS_AUTO_SCALING_URL from unzip admin/eucalyptus credentials @@ -259,7 +288,8 @@ def get_autoscale_url(self, tmp_dir): autoscale_url = var.strip() return autoscale_url if autoscale_url is None: - self.addDiagnose("Error grabbing AWS_AUTO_SCALING_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing AWS_AUTO_SCALING_URL \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -268,8 +298,8 @@ def get_autoscale_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_elb_url(self, tmp_dir): """ Grab AWS_ELB_URL from unzip admin/eucalyptus credentials @@ -282,7 +312,8 @@ def get_elb_url(self, tmp_dir): elb_url = var.strip() return elb_url if elb_url is None: - self.addDiagnose("Error grabbing AWS_ELB_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing AWS_ELB_URL \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -291,8 +322,8 @@ def get_elb_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_cloudwatch_url(self, tmp_dir): """ Grab AWS_CLOUDWATCH_URL from unzip admin/eucalyptus credentials @@ -305,7 +336,8 @@ def get_cloudwatch_url(self, tmp_dir): cloudwatch_url = var.strip() return cloudwatch_url if cloudwatch_url is None: - self.addDiagnose("Error grabbing AWS_CLOUDWATCH_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing AWS_CLOUDWATCH_URL \ + from " + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -314,8 +346,8 @@ def get_cloudwatch_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def get_sts_url(self, tmp_dir): """ Grab TOKEN_URL from unzip admin/eucalyptus credentials @@ -328,7 +360,8 @@ def get_sts_url(self, tmp_dir): sts_url = var.strip() return sts_url if sts_url is None: - self.addDiagnose("Error grabbing STS_URL from " + tmp_dir + "/eucarc") + self.addDiagnose("Error grabbing STS_URL from " + + tmp_dir + "/eucarc") raise except OSError, e: error_string = '%s' % e @@ -337,27 +370,28 @@ def get_sts_url(self, tmp_dir): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - + raise OSError(e) + def euca2ools_conf_setup(self, tmp_dir): """ Create ini file under /etc/euca2ools/conf.d directory from - information contained in unzip admin/eucalyptus credentials file (eucarc) + information in admin/eucalyptus credentials file (eucarc) """ try: - mkdir_output = os.mkdir("/etc/euca2ools/conf.d") + os.mkdir("/etc/euca2ools/conf.d") except OSError, e: error_string = '%s' % e if 'No such' in error_string: - self.addDiagnose("Error creating /etc/euca2ools/conf.d directory") + self.addDiagnose("Error creating \ + /etc/euca2ools/conf.d directory") raise OSError(e) elif 'File exist' in error_string: self.addDiagnose("WARN: %s" % e) pass else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - access_key = self.get_access_key(tmp_dir) + raise OSError(e) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) account_id = self.get_account_id(tmp_dir) s3_url = self.get_s3_url(tmp_dir) @@ -369,27 +403,41 @@ def euca2ools_conf_setup(self, tmp_dir): sts_url = self.get_sts_url(tmp_dir) euca2ools_conf = open('/etc/euca2ools/conf.d/sos-euca2ools.ini', 'w') try: - euca2ools_conf.write("[user admin]\n") + euca2ools_conf.write("[user admin]\n") euca2ools_conf.write("key-id = " + access_key + "\n") euca2ools_conf.write("secret-key = " + secret_key + "\n") euca2ools_conf.write("account-id = " + account_id + "\n\n") euca2ools_conf.write("[region sosreport]\n") - euca2ools_conf.write("autoscaling-url = " + autoscale_url + "/" + "\n") - euca2ools_conf.write("ec2-url = " + ec2_url + "/" + "\n") - euca2ools_conf.write("elasticloadbalancing-url = " + elb_url + "/" + "\n") - euca2ools_conf.write("iam-url = " + iam_url + "/" + "\n") - euca2ools_conf.write("monitoring-url = " + cloudwatch_url + "/" + "\n") - euca2ools_conf.write("s3-url = " + s3_url + "/" + "\n") - euca2ools_conf.write("sts-url = " + sts_url + "/" + "\n") + euca2ools_conf.write("autoscaling-url = " + autoscale_url + + "\n") + euca2ools_conf.write("ec2-url = " + ec2_url + "\n") + euca2ools_conf.write("elasticloadbalancing-url = " + + elb_url + "/" + "\n") + euca2ools_conf.write("iam-url = " + iam_url + "\n") + euca2ools_conf.write("monitoring-url = " + + cloudwatch_url + "\n") + euca2ools_conf.write("s3-url = " + s3_url + "\n") + euca2ools_conf.write("sts-url = " + sts_url + "\n") euca2ools_conf.write("eustore-url = http://emis.eucalyptus.com/\n") - euca2ools_conf.write("configuration-url = http://127.0.0.1:8773/services/Configuration/\n") - euca2ools_conf.write("empyrean-url = http://127.0.0.1:8773/services/Empyrean/\n") - euca2ools_conf.write("properties-url = http://127.0.0.1:8773/services/Properties/\n") - euca2ools_conf.write("reporting-url = http://127.0.0.1:8773/services/Reporting/\n") - euca2ools_conf.write("certificate = /var/lib/eucalyptus/keys/cloud-cert.pem\n") + euca2ools_conf.write("configuration-url = " + + "http://127.0.0.1:8773/services" + + "/Configuration/\n") + euca2ools_conf.write("empyrean-url = " + + "http://127.0.0.1:8773/services/Empyrean/" + + "\n") + euca2ools_conf.write("properties-url = " + + "http://127.0.0.1:8773/services/Properties/" + + "\n") + euca2ools_conf.write("reporting-url = " + + "http://127.0.0.1:8773/services/Reporting/" + + "\n") + euca2ools_conf.write("certificate = " + + "/var/lib/eucalyptus/keys/cloud-cert.pem" + + "\n") finally: euca2ools_conf.close() - self.addDiagnose("Populated /etc/euca2ools/conf.d/sos-euca2ools.ini with admin creds") + self.addDiagnose("Populated /etc/euca2ools/conf.d/sos-euca2ools.ini \ + with admin creds") def get_accountlist(self, tmp_dir=''): """ @@ -398,15 +446,19 @@ def get_accountlist(self, tmp_dir=''): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version) and tmp_dir: - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) - get_accountlist_cmd = ["/usr/bin/euare-accountlist", "-U", iam_url, "-I", access_key, "-S", secret_key] + get_actlist_cmd = ["/usr/bin/euare-accountlist", "-U", iam_url, + "-I", access_key, "-S", secret_key] else: - get_accountlist_cmd = ["/usr/bin/euare-accountlist", "--region", "admin@sosreport"] + get_actlist_cmd = ["/usr/bin/euare-accountlist", + "--region", "admin@sosreport"] try: - getaccountlist_output,unused_val = subprocess.Popen(get_accountlist_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + actlist, v = subprocess.Popen(get_actlist_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: error_string = '%s' % e if 'No such' in error_string: @@ -414,11 +466,11 @@ def get_accountlist(self, tmp_dir=''): raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - accounts =[] - for account_info in getaccountlist_output.splitlines(): - entry = re.split(r'\t',account_info) - accounts.append(entry[0]) + raise OSError(e) + accounts = [] + for account_info in actlist.splitlines(): + entry = re.split(r'\t', account_info) + accounts.append("\"" + entry[0] + "\"") return accounts def get_account_info(self, account, tmp_dir=''): @@ -428,53 +480,88 @@ def get_account_info(self, account, tmp_dir=''): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version) and tmp_dir: - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) - creds_info = " -U " + iam_url + " -I " + access_key + " -S " + secret_key - self.collectExtOutput("/usr/bin/euare-accountaliaslist --delegate " + account + creds_info, suggest_filename="euare-accountaliaslist-" + account) - self.collectExtOutput("/usr/bin/euare-accountlistpolicies -a " + account + creds_info, suggest_filename="euare-accountlistpolicies-" + account) - self.collectExtOutput("/usr/bin/euare-userlistbypath --delegate " + account + creds_info, suggest_filename="euare-userlistbypath-" + account) - self.collectExtOutput("/usr/bin/euare-grouplistbypath --delegate " + account + creds_info, suggest_filename="euare-grouplistbypath-" + account) + creds_info = (" -U " + iam_url + " -I " + + access_key + " -S " + secret_key) + self.collectExtOutput("/usr/bin/euare-accountaliaslist --delegate " + + account + creds_info, + suggest_filename="euare-accountaliaslist-" + + account) + self.collectExtOutput("/usr/bin/euare-accountlistpolicies -a " + + account + creds_info, + suggest_filename="euare-accountlistpolicies-" + + account) + self.collectExtOutput("/usr/bin/euare-userlistbypath --delegate " + + account + creds_info, + suggest_filename="euare-userlistbypath-" + + account) + self.collectExtOutput("/usr/bin/euare-grouplistbypath --delegate " + + account + creds_info, + suggest_filename="euare-grouplistbypath-" + + account) else: - self.collectExtOutput("/usr/bin/euare-accountaliaslist --as-account " + account + " --region admin@sosreport", suggest_filename="euare-accountaliaslist-" + account) - self.collectExtOutput("/usr/bin/euare-accountlistpolicies -a " + account + " -v --region admin@sosreport", suggest_filename="euare-accountlistpolicies-" + account) - self.collectExtOutput("/usr/bin/euare-userlistbypath --as-account " + account + " --region admin@sosreport", suggest_filename="euare-userlistbypath-" + account) - self.collectExtOutput("/usr/bin/euare-grouplistbypath --as-account " + account + " --region admin@sosreport", suggest_filename="euare-grouplistbypath-" + account) + self.collectExtOutput("/usr/bin/euare-accountaliaslist \ + --as-account " + + account + " --region admin@sosreport", + suggest_filename="euare-accountaliaslist-" + + account) + self.collectExtOutput("/usr/bin/euare-accountlistpolicies -a " + + account + " -v --region admin@sosreport", + suggest_filename="euare-accountlistpolicies-" + + account) + self.collectExtOutput("/usr/bin/euare-userlistbypath --as-account " + + account + " --region admin@sosreport", + suggest_filename="euare-userlistbypath-" + + account) + self.collectExtOutput("/usr/bin/euare-grouplistbypath \ + --as-account " + + account + " --region admin@sosreport", + suggest_filename="euare-grouplistbypath-" + + account) def get_userlist(self, account, tmp_dir=''): """ - Grab list of users of the Euare account passed in and return the list of users + Grab list of users of the Euare account; return the list of users """ self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version) and tmp_dir: - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) if re.match('^eucalyptus', account): - get_userlist_cmd = ["/usr/bin/euare-userlistbypath", "-U", iam_url, "-I", access_key, "-S", secret_key] + get_userlist_cmd = ["/usr/bin/euare-userlistbypath", + "-U", iam_url, "-I", access_key, + "-S", secret_key] else: - get_userlist_cmd = ["/usr/bin/euare-userlistbypath", "--delegate", account, "-U", iam_url, "-I", access_key, "-S", secret_key] + get_userlist_cmd = ["/usr/bin/euare-userlistbypath", + "--delegate", account, "-U", iam_url, + "-I", access_key, "-S", secret_key] else: - get_userlist_cmd = ["/usr/bin/euare-userlistbypath", "--as-account", account, "--region", "admin@sosreport"] + get_userlist_cmd = ["/usr/bin/euare-userlistbypath", + "--as-account", account, "--region", + "admin@sosreport"] try: - getuserlist_output,unused_val = subprocess.Popen(get_userlist_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + usrlist, v = subprocess.Popen(get_userlist_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: error_string = '%s' % e if 'No such' in error_string: - self.addDiagnose("Error grabbing Euare Account " + account + " User List.") + self.addDiagnose("Error: " + account + " User List.") raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - users =[] + raise OSError(e) + users = [] sColon = re.compile('[:]') - for user_info in getuserlist_output.splitlines(): + for user_info in usrlist.splitlines(): entry = sColon.split(user_info) user_id = entry[5].strip().split("/") - users.append(user_id[1]) + users.append(user_id[1]) return users def get_account_user_info(self, account, user, tmp_dir=''): @@ -484,30 +571,88 @@ def get_account_user_info(self, account, user, tmp_dir=''): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version) and tmp_dir: - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) - creds_info = " -U " + iam_url + " -I " + access_key + " -S " + secret_key + creds_info = (" -U " + iam_url + " -I " + + access_key + " -S " + secret_key) if re.match('^eucalyptus', account): delegate = '' else: delegate = "--delegate " + account - self.collectExtOutput("/usr/bin/euare-usergetinfo " + delegate + " -u " + user + creds_info, suggest_filename="euare-usergetinfo-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-usergetloginprofile " + delegate + " -u " + user + creds_info, suggest_filename="euare-usergetloginprofile-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistcerts " + delegate + " -u " + user + creds_info, suggest_filename="euare-userlistcerts-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-usergetattributes " + delegate + " -u " + user + " --show-extra" + creds_info, suggest_filename="euare-usergetattributes-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistgroups " + delegate + " -u " + user + creds_info, suggest_filename="euare-userlistgroups-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistkeys " + delegate + " -u " + user + creds_info, suggest_filename="euare-userlistkeys-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistpolicies " + delegate + " -u " + user + " -v" + creds_info, suggest_filename="euare-userlistpolicies-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetinfo " + + delegate + " -u " + + user + creds_info, + suggest_filename="euare-usergetinfo-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetloginprofile " + + delegate + " -u " + user + creds_info, + suggest_filename="euare-usergetloginprofile-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistcerts " + delegate + + " -u " + + user + creds_info, + suggest_filename="euare-userlistcerts-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetattributes " + + delegate + + " -u " + user + " --show-extra" + + creds_info, + suggest_filename="euare-usergetattributes-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistgroups " + delegate + + " -u " + user + creds_info, + suggest_filename="euare-userlistgroups-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistkeys " + delegate + + " -u " + user + creds_info, + suggest_filename="euare-userlistkeys-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistpolicies " + delegate + + " -u " + user + " -v" + creds_info, + suggest_filename="euare-userlistpolicies-" + + account + "-" + user) else: - self.collectExtOutput("/usr/bin/euare-usergetinfo --as-account " + account + " -u " + user + " --region admin@sosreport", suggest_filename="euare-usergetinfo-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-usergetloginprofile --as-account " + account + " -u " + user + " --region admin@sosreport", suggest_filename="euare-usergetloginprofile-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistcerts --as-account " + account + " -u " + user + " --region admin@sosreport", suggest_filename="euare-userlistcerts-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-usergetattributes --as-account " + account + " -u " + user + " --show-extra --region admin@sosreport", suggest_filename="euare-usergetattributes-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistgroups --as-account " + account + " -u " + user + " --region admin@sosreport", suggest_filename="euare-userlistgroups-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistkeys --as-account " + account + " -u " + user + " --region admin@sosreport", suggest_filename="euare-userlistkeys-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistpolicies --as-account " + account + " -u " + user + " -v --region admin@sosreport", suggest_filename="euare-userlistpolicies-" + account + "-" + user) - + self.collectExtOutput("/usr/bin/euare-usergetinfo --as-account " + + account + " -u " + user + + " --region admin@sosreport", + suggest_filename="euare-usergetinfo-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetloginprofile \ + --as-account " + + account + " -u " + user + + " --region admin@sosreport", + suggest_filename="euare-usergetloginprofile-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistcerts --as-account " + + account + " -u " + user + + " --region admin@sosreport", + suggest_filename="euare-userlistcerts-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetattributes \ + --as-account " + + account + " -u " + user + + " --show-extra --region admin@sosreport", + suggest_filename="euare-usergetattributes-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistgroups \ + --as-account " + + account + " -u " + user + + " --region admin@sosreport", + suggest_filename="euare-userlistgroups-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistkeys --as-account " + + account + " -u " + user + + " --region admin@sosreport", + suggest_filename="euare-userlistkeys-" + + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistpolicies \ + --as-account " + + account + " -u " + user + + " -v --region admin@sosreport", + suggest_filename="euare-userlistpolicies-" + + account + "-" + user) + def get_grouplist(self, account, tmp_dir=''): """ Grab the groups from the Euare account passed in and return the list @@ -515,33 +660,42 @@ def get_grouplist(self, account, tmp_dir=''): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version) and tmp_dir: - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) if re.match('^eucalyptus', account): - get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "-U", iam_url, "-I", access_key, "-S", secret_key] + get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", + "-U", iam_url, + "-I", access_key, "-S", secret_key] else: - get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "--delegate", account, "-U", iam_url, "-I", access_key, "-S", secret_key] + get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", + "--delegate", + account, "-U", iam_url, "-I", + access_key, "-S", secret_key] else: - get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "--as-account", account, "--region", "admin@sosreport"] + get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", + "--as-account", account, "--region", + "admin@sosreport"] try: - getgrouplist_output,unused_val = subprocess.Popen(get_grouplist_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() + grplist, v = subprocess.Popen(get_grouplist_cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() except OSError, e: error_string = '%s' % e if 'No such' in error_string: - self.addDiagnose("Error grabbing Euare Account " + account + " Group List.") + self.addDiagnose("Error: " + account + " Group List.") raise OSError(e) else: self.addDiagnose("Error: %s" % e) - raise OSError(e) - groups =[] + raise OSError(e) + groups = [] sColon = re.compile('[:]') - for group_info in getgrouplist_output.splitlines(): + for group_info in grplist.splitlines(): if re.search('iam', group_info): entry = sColon.split(group_info) group_id = entry[5].strip().split("/") - groups.append(group_id[1]) + groups.append(group_id[1]) return groups def get_account_group_info(self, account, group, tmp_dir=''): @@ -551,66 +705,129 @@ def get_account_group_info(self, account, group, tmp_dir=''): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version): - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) - creds_info = " -U " + iam_url + " -I " + access_key + " -S " + secret_key + creds_info = (" -U " + iam_url + " -I " + access_key + + " -S " + secret_key) if re.match('^eucalyptus', account): delegate = '' else: delegate = "--delegate " + account - self.collectExtOutput("/usr/bin/euare-grouplistusers " + delegate + " -g " + group + creds_info, suggest_filename="euare-grouplistusers-" + account + "-" + group) - self.collectExtOutput("/usr/bin/euare-grouplistpolicies " + delegate + " -g " + group + " -v" + creds_info, suggest_filename="euare-grouplistpolicies-" + account + "-" + group) + self.collectExtOutput("/usr/bin/euare-grouplistusers " + + delegate + + " -g " + group + creds_info, + suggest_filename="euare-grouplistusers-" + + account + "-" + group) + self.collectExtOutput("/usr/bin/euare-grouplistpolicies " + + delegate + + " -g " + group + " -v" + creds_info, + suggest_filename="euare-grouplistpolicies-" + + account + "-" + group) else: - self.collectExtOutput("/usr/bin/euare-grouplistusers --as-account " + account + " -g " + group + " --region admin@sosreport", suggest_filename="euare-grouplistusers-" + account + "-" + group) - self.collectExtOutput("/usr/bin/euare-grouplistpolicies --as-account " + account + " -g " + group + " -v --region admin@sosreport", suggest_filename="euare-grouplistpolicies-" + account + "-" + group) + self.collectExtOutput("/usr/bin/euare-grouplistusers --as-account " + + account + " -g " + group + + " --region admin@sosreport", + suggest_filename="euare-grouplistusers-" + + account + "-" + group) + self.collectExtOutput("/usr/bin/euare-grouplistpolicies \ + --as-account " + + account + " -g " + group + + " -v --region admin@sosreport", + suggest_filename="euare-grouplistpolicies-" + + account + "-" + group) def cleanup(self, tmp_dir): """ Clean up temporary directory and sos-euca2ools.ini file. """ self.addDiagnose("### Cleanup credentials ###") - self.collectExtOutput("rm -rf " + tmp_dir, suggest_filename="cleanup-tmpeucacreds") - self.collectExtOutput("rm -rf /etc/euca2ools/conf.d/sos-euca2ools.ini", suggest_filename="cleanup-sos-euca2ools-config") + self.collectExtOutput("rm -rf " + tmp_dir, + suggest_filename="cleanup-tmpeucacreds") + self.collectExtOutput("rm -rf /etc/euca2ools/conf.d/sos-euca2ools.ini", + suggest_filename="cleanup-sos-euca2ools-config") def eucalyptus_core(self, tmp_dir): self.addDiagnose("### Grabbing eucalyptus/admin credentials ###") - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) empyrean_url = "http://127.0.0.1:8773/services/Empyrean/" creds_info = " -I " + access_key + " -S " + secret_key - self.collectExtOutput("/usr/sbin/euca-describe-arbitrators -U " + empyrean_url + creds_info, suggest_filename="euca-describe-arbitrators") - self.collectExtOutput("/usr/sbin/euca-describe-clouds -U " + empyrean_url + creds_info, suggest_filename="euca-describe-clouds") - self.collectExtOutput("/usr/sbin/euca-describe-clusters -U " + empyrean_url + creds_info, suggest_filename="euca-describe-clusters") - self.collectExtOutput("/usr/sbin/euca-describe-components -U " + empyrean_url + creds_info, suggest_filename="euca-describe-components") - self.collectExtOutput("/usr/sbin/euca-describe-nodes -U " + empyrean_url + creds_info, suggest_filename="euca-describe-nodes") - self.collectExtOutput("/usr/sbin/euca-describe-properties -U " + empyrean_url + creds_info, suggest_filename="euca-describe-properties") - self.collectExtOutput("/usr/sbin/euca-describe-services --all -E", suggest_filename="euca-describe-services-all") - self.collectExtOutput("/usr/sbin/euca-describe-storage-controllers -U " + empyrean_url + creds_info, suggest_filename="euca-describe-storage-controllers") + self.collectExtOutput("/usr/sbin/euca-describe-arbitrators -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-arbitrators") + self.collectExtOutput("/usr/sbin/euca-describe-clouds -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-clouds") + self.collectExtOutput("/usr/sbin/euca-describe-clusters -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-clusters") + self.collectExtOutput("/usr/sbin/euca-describe-components -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-components") + self.collectExtOutput("/usr/sbin/euca-describe-nodes -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-nodes") + self.collectExtOutput("/usr/sbin/euca-describe-properties -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-properties") + self.collectExtOutput("/usr/sbin/euca-describe-services --all -E", + suggest_filename="euca-describe-services-all") + self.collectExtOutput("/usr/sbin/euca-describe-storage-controllers -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-storage-ctrls") if self.isInstalled("eucalyptus-enterprise-vmware-broker"): - self.collectExtOutput("/usr/sbin/euca-describe-vmware-brokers -U " + empyrean_url + creds_info, suggest_filename="euca-describe-vmware-brokers") - self.collectExtOutput("/usr/sbin/euca-describe-walruses -U " + empyrean_url + creds_info, suggest_filename="euca-describe-walruses") + self.collectExtOutput("/usr/sbin/euca-describe-vmware-brokers -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-vmware-brks") + self.collectExtOutput("/usr/sbin/euca-describe-walruses -U " + + empyrean_url + creds_info, + suggest_filename="euca-describe-walruses") self.collectExtOutput("/usr/bin/euca-version") - + def eucalyptus_ec2(self, tmp_dir): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version): - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) ec2_url = self.get_ec2_url(tmp_dir) - creds_info = "-U " + ec2_url + " --access-key " + access_key + " --secret-key " + secret_key - self.collectExtOutput("/usr/bin/euca-describe-addresses verbose " + creds_info, suggest_filename="euca-describe-addresses-verbose") - self.collectExtOutput("/usr/bin/euca-describe-regions " + creds_info, suggest_filename="euca-describe-regions") - self.collectExtOutput("/usr/bin/euca-describe-availability-zones verbose " + creds_info, suggest_filename="euca-describe-availability-zones-verbose") - self.collectExtOutput("/usr/bin/euca-describe-instance-types --show-capacity --by-zone " + creds_info, suggest_filename="euca-describe-instance-types-show-capacity") - self.collectExtOutput("/usr/bin/euca-describe-groups verbose " + creds_info, suggest_filename="euca-describe-groups-verbose") - self.collectExtOutput("/usr/bin/euca-describe-images --all " + creds_info, suggest_filename="euca-describe-images-all") - self.collectExtOutput("/usr/bin/eustore-describe-images -v " + creds_info, suggest_filename="eustore-describe-images") - self.collectExtOutput("/usr/bin/euca-describe-instances verbose " + creds_info, suggest_filename="euca-describe-instances-verbose") - self.collectExtOutput("/usr/bin/euca-describe-keypairs verbose " + creds_info, suggest_filename="euca-describe-keypairs-verbose") - self.collectExtOutput("/usr/bin/euca-describe-snapshots verbose " + creds_info, suggest_filename="euca-describe-snapshots-verbose") - self.collectExtOutput("/usr/bin/euca-describe-volumes verbose " + creds_info, suggest_filename="euca-describe-volumes-verbose") + creds_info = ("-U " + ec2_url + " --access-key " + + access_key + " --secret-key " + secret_key) + self.collectExtOutput("/usr/bin/euca-describe-addresses verbose " + + creds_info, + suggest_filename="euca-describe-addrs-v") + self.collectExtOutput("/usr/bin/euca-describe-regions " + + creds_info, + suggest_filename="euca-describe-regions") + self.collectExtOutput("/usr/bin/euca-describe-availability-zones \ + verbose " + + creds_info, + suggest_filename="euca-describe-a-z-v") + self.collectExtOutput("/usr/bin/euca-describe-instance-types \ + --show-capacity --by-zone " + creds_info, + suggest_filename="euca-describe-inst-types") + self.collectExtOutput("/usr/bin/euca-describe-groups verbose " + + creds_info, + suggest_filename="euca-describe-grps-v") + self.collectExtOutput("/usr/bin/euca-describe-images --all " + + creds_info, + suggest_filename="euca-describe-imgs-all") + self.collectExtOutput("/usr/bin/eustore-describe-images -v " + + creds_info, + suggest_filename="eustore-describe-images") + self.collectExtOutput("/usr/bin/euca-describe-instances verbose " + + creds_info, + suggest_filename="euca-describe-inst-v") + self.collectExtOutput("/usr/bin/euca-describe-keypairs verbose " + + creds_info, + suggest_filename="euca-describe-kyprs-v") + self.collectExtOutput("/usr/bin/euca-describe-snapshots verbose " + + creds_info, + suggest_filename="euca-describe-snpshts-v") + self.collectExtOutput("/usr/bin/euca-describe-volumes verbose " + + creds_info, + suggest_filename="euca-describe-vols-v") else: if not os.path.isfile('/etc/euca2ools/conf.d/sos-euca2ools.ini'): self.addDiagnose("### Setting up sos-euca2ools.ini file ###") @@ -619,27 +836,53 @@ def eucalyptus_ec2(self, tmp_dir): self.addCopySpec("/tmp/eucacreds") self.addDiagnose("### Grabbing Cloud Resource Data ###") - self.collectExtOutput("/usr/bin/euca-describe-addresses verbose --region admin@sosreport", suggest_filename="euca-describe-addresses-verbose") - self.collectExtOutput("/usr/bin/euca-describe-availability-zones verbose --region admin@sosreport", suggest_filename="euca-describe-availability-zones-verbose") - self.collectExtOutput("/usr/bin/euca-describe-instance-types --show-capacity --region admin@sosreport", suggest_filename="euca-describe-instance-types-show-capacity") - self.collectExtOutput("/usr/bin/euca-describe-groups verbose --region admin@sosreport", suggest_filename="euca-describe-groups-verbose") - self.collectExtOutput("/usr/bin/euca-describe-images --all --region admin@sosreport", suggest_filename="euca-describe-images-all") - self.collectExtOutput("/usr/bin/eustore-describe-images -v --region admin@sosreport", suggest_filename="eustore-describe-images") - self.collectExtOutput("/usr/bin/euca-describe-regions --region admin@sosreport", suggest_filename="euca-describe-regions") - self.collectExtOutput("/usr/bin/euca-describe-instances verbose --region admin@sosreport", suggest_filename="euca-describe-instances-verbose") - self.collectExtOutput("/usr/bin/euca-describe-keypairs verbose --region admin@sosreport", suggest_filename="euca-describe-keypairs-verbose") - self.collectExtOutput("/usr/bin/euca-describe-snapshots verbose --region admin@sosreport", suggest_filename="euca-describe-snapshots-verbose") - self.collectExtOutput("/usr/bin/euca-describe-volumes verbose --region admin@sosreport", suggest_filename="euca-describe-volumes-verbose") - self.collectExtOutput("/usr/bin/euca-describe-tags --region admin@sosreport", suggest_filename="euca-describe-tags") + self.collectExtOutput("/usr/bin/euca-describe-addresses verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-addrs-v") + self.collectExtOutput("/usr/bin/euca-describe-availability-zones verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-a-z-v") + self.collectExtOutput("/usr/bin/euca-describe-instance-types --show-capacity \ + --region admin@sosreport", + suggest_filename="euca-describe-inst-types") + self.collectExtOutput("/usr/bin/euca-describe-groups verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-grps-v") + self.collectExtOutput("/usr/bin/euca-describe-images --all \ + --region admin@sosreport", + suggest_filename="euca-describe-images-all") + self.collectExtOutput("/usr/bin/eustore-describe-images -v \ + --region admin@sosreport", + suggest_filename="eustore-describe-images") + self.collectExtOutput("/usr/bin/euca-describe-regions \ + --region admin@sosreport", + suggest_filename="euca-describe-regions") + self.collectExtOutput("/usr/bin/euca-describe-instances verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-insts-v") + self.collectExtOutput("/usr/bin/euca-describe-keypairs verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-kyprs-v") + self.collectExtOutput("/usr/bin/euca-describe-snapshots verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-snpshts-v") + self.collectExtOutput("/usr/bin/euca-describe-volumes verbose \ + --region admin@sosreport", + suggest_filename="euca-describe-vols-v") + self.collectExtOutput("/usr/bin/euca-describe-tags \ + --region admin@sosreport", + suggest_filename="euca-describe-tags") def eucalyptus_iam(self, tmp_dir): self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') if re.match('^2.1+', euca2ools_version): - access_key = self.get_access_key(tmp_dir) + access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) iam_url = self.get_iam_url(tmp_dir) - self.collectExtOutput("/usr/bin/euare-accountlist -U " + iam_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euare-accountlist") + self.collectExtOutput("/usr/bin/euare-accountlist -U " + iam_url + + " -I " + access_key + " -S " + secret_key, + suggest_filename="euare-accountlist") for account in self.get_accountlist(tmp_dir): self.get_account_info(account, tmp_dir) for user in self.get_userlist(account, tmp_dir): @@ -653,7 +896,9 @@ def eucalyptus_iam(self, tmp_dir): self.addCopySpec("/etc/euca2ools") self.addCopySpec("/tmp/eucacreds") - self.collectExtOutput("/usr/bin/euare-accountlist --region admin@sosreport", suggest_filename="euare-accountlist") + self.collectExtOutput("/usr/bin/euare-accountlist \ + --region admin@sosreport", + suggest_filename="euare-accountlist") for account in self.get_accountlist(): self.get_account_info(account) for user in self.get_userlist(account): @@ -662,26 +907,50 @@ def eucalyptus_iam(self, tmp_dir): self.get_account_group_info(account, group) def eucalyptus_autoscaling(self): - self.collectExtOutput("/usr/bin/euscale-describe-auto-scaling-instances verbose --show-long --region admin@sosreport", suggest_filename="euscale-describe-auto-scaling-instances-verbose") - self.collectExtOutput("/usr/bin/euscale-describe-auto-scaling-groups verbose --show-long --region admin@sosreport", suggest_filename="euscale-describe-auto-scaling-groups-verbose") - self.collectExtOutput("/usr/bin/euscale-describe-launch-configs verbose --show-long --region admin@sosreport", suggest_filename="euscale-describe-launch-configs-verbose") - self.collectExtOutput("/usr/bin/euscale-describe-notification-configurations verbose --region admin@sosreport", suggest_filename="euscale-describe-notification-configurations-verbose") - self.collectExtOutput("/usr/bin/euscale-describe-policies verbose --show-long --region admin@sosreport", suggest_filename="euscale-describe-policies-verbose") - self.collectExtOutput("/usr/bin/euscale-describe-scaling-activities verbose --show-long --region admin@sosreport", suggest_filename="euscale-describe-scaling-activities-verbose") - self.collectExtOutput("/usr/bin/euscale-describe-scheduled-actions verbose --show-long --region admin@sosreport", suggest_filename="euscale-describe-scheduled-actions-verbose") + self.collectExtOutput("/usr/bin/euscale-describe-auto-scaling-instances verbose \ + --show-long --region admin@sosreport", + suggest_filename="euscale-describe-a-s-insts-v") + self.collectExtOutput("/usr/bin/euscale-describe-auto-scaling-groups verbose \ + --show-long --region admin@sosreport", + suggest_filename="euscale-describe-a-s-grps-v") + self.collectExtOutput("/usr/bin/euscale-describe-launch-configs verbose \ + --show-long --region admin@sosreport", + suggest_filename="euscale-describe-l-cnfs-v") + self.collectExtOutput("/usr/bin/euscale-describe-notification-configurations verbose \ + --region admin@sosreport", + suggest_filename="euscale-describe-not-cnfs-v") + self.collectExtOutput("/usr/bin/euscale-describe-policies verbose --show-long \ + --region admin@sosreport", + suggest_filename="euscale-describe-pols-v") + self.collectExtOutput("/usr/bin/euscale-describe-scaling-activities verbose \ + --show-long --region admin@sosreport", + suggest_filename="euscale-describe-s-a-v") + self.collectExtOutput("/usr/bin/euscale-describe-scheduled-actions verbose \ + --show-long --region admin@sosreport", + suggest_filename="euscale-describe-sch-a-v") def eucalyptus_elb(self): - self.collectExtOutput("/usr/bin/eulb-describe-lb-policies verbose --show-long --region admin@sosreport", suggest_filename="eulb-describe-lb-policies-verbose") - self.collectExtOutput("/usr/bin/eulb-describe-lb-policy-types verbose --show-long --region admin@sosreport", suggest_filename="eulb-describe-lb-policy-types-verbose") - self.collectExtOutput("/usr/bin/eulb-describe-lbs verbose --show-long --region admin@sosreport", suggest_filename="eulb-describe-lbs-verbose") + self.collectExtOutput("/usr/bin/eulb-describe-lb-policies verbose \ + --show-long --region admin@sosreport", + suggest_filename="eulb-describe-lb-pols-v") + self.collectExtOutput("/usr/bin/eulb-describe-lb-policy-types verbose --show-long \ + --region admin@sosreport", + suggest_filename="eulb-describe-lb-pol-types-v") + self.collectExtOutput("/usr/bin/eulb-describe-lbs verbose --show-long \ + --region admin@sosreport", + suggest_filename="eulb-describe-lbs-v") return def eucalyptus_cloudwatch(self): - self.collectExtOutput("/usr/bin/euwatch-describe-alarms verbose --show-long --region admin@sosreport", suggest_filename="euwatch-describe-alarms-verbose") - self.collectExtOutput("/usr/bin/euwatch-describe-alarm-history verbose --show-long --region admin@sosreport", suggest_filename="euwatch-describe-alarm-history-verbose") + self.collectExtOutput("/usr/bin/euwatch-describe-alarms verbose --show-long \ + --region admin@sosreport", + suggest_filename="euwatch-describe-alrms-v") + self.collectExtOutput("/usr/bin/euwatch-describe-alarm-history verbose --show-long \ + --region admin@sosreport", + suggest_filename="euwatch-describe-alrm-hist-v") def setup(self): - self.addDiagnose("### Check to make sure eucalyptus-cloud is running ###") + self.addDiagnose("### Check eucalyptus-cloud is running ###") self.clc_status() self.addDiagnose("### Grabbing eucalyptus/admin credentials ###") tmp_dir = self.eucacreds_setup() @@ -693,13 +962,12 @@ def setup(self): self.eucalyptus_iam(tmp_dir) euca2ools_version = self.checkversion('euca2ools') if re.match('^3+', euca2ools_version): - self.addDiagnose("### Grab Eucalyptus AutoScaling Service Information ###") + self.addDiagnose("### Grab AutoScaling Service Information ###") self.eucalyptus_autoscaling() - self.addDiagnose("### Grab Eucalyptus Elastic Load Balancing Service Information ###") + self.addDiagnose("### Grab Load Balancing Service Information ###") self.eucalyptus_elb() - self.addDiagnose("### Grab Eucalyptus CloudWatch Service Information ###") + self.addDiagnose("### Grab CloudWatch Service Information ###") self.eucalyptus_cloudwatch() - - self.cleanup(tmp_dir) - return + self.cleanup(tmp_dir) + return diff --git a/sos/plugins/eucanode.py b/sos/plugins/eucanode.py index 844400f..5bcca50 100644 --- a/sos/plugins/eucanode.py +++ b/sos/plugins/eucanode.py @@ -1,23 +1,24 @@ -## Copyright (C) 2014 Eucalyptus Systems, Inc. +# Copyright (C) 2014 Eucalyptus Systems, Inc. -### This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. -## You should have received a copy of the GNU General Public License -## along with this program; if not, write to the Free Software -## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import sos.plugintools import subprocess import csv + class eucanode(sos.plugintools.PluginBase): """Eucalyptus Cloud - Node Controller """ @@ -27,12 +28,17 @@ def checkenabled(self): return False def setup(self): - self.collectExtOutput("/usr/bin/virsh list", suggest_filename="virsh-list") + self.collectExtOutput("/usr/bin/virsh list", + suggest_filename="virsh-list") - virsh_result = subprocess.Popen("virsh list | tail -n +3", stdout=subprocess.PIPE, shell=True) + virsh_result = subprocess.Popen("virsh list | tail -n +3", + stdout=subprocess.PIPE, shell=True) output, err = virsh_result.communicate() - reader = csv.DictReader(output.decode('ascii').splitlines(), delimiter=' ', skipinitialspace=True, fieldnames=['id', 'name', 'state']) + reader = csv.DictReader(output.decode('ascii').splitlines(), + delimiter=' ', + skipinitialspace=True, + fieldnames=['id', 'name', 'state']) for row in reader: - self.collectExtOutput("virsh dumpxml " + row['id'], suggest_filename=row['name'] + "_xml") + self.collectExtOutput("virsh dumpxml " + row['id'], + suggest_filename=row['name'] + "_xml") return -