Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #76 from hspencer77/flake8-formatting-fixes
Browse files Browse the repository at this point in the history
Applied PEP8 formatting; updated Makefile to clean cruft correctly
  • Loading branch information
hspencer77 committed Feb 9, 2015
2 parents 61a38ea + c74b736 commit b2389e4
Show file tree
Hide file tree
Showing 8 changed files with 676 additions and 304 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
2 changes: 1 addition & 1 deletion eucalyptus-sos-plugins.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions sos/plugins/eucacluster.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 15 additions & 14 deletions sos/plugins/eucaconsole.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand All @@ -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/*")
Expand Down
35 changes: 20 additions & 15 deletions sos/plugins/eucacore.py
Original file line number Diff line number Diff line change
@@ -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
"""
Expand All @@ -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
165 changes: 128 additions & 37 deletions sos/plugins/eucadb.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Loading

0 comments on commit b2389e4

Please sign in to comment.