From 6a14e06c495ecac451e87525c5bb94caeda481c0 Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Sun, 4 May 2014 16:28:23 +0000 Subject: [PATCH 1/9] Grabbed keys per issue https://github.com/eucalyptus/eucalyptus-sosreport-plugins/issues/49 --- sos/plugins/eucacore.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sos/plugins/eucacore.py b/sos/plugins/eucacore.py index ddd82a3..75f5097 100644 --- a/sos/plugins/eucacore.py +++ b/sos/plugins/eucacore.py @@ -30,6 +30,7 @@ def checkenabled(self): def setup(self): self.addCopySpec("/etc/eucalyptus") 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") hprof_list = glob.glob('/var/log/eucalyptus/*.hprof') From bd14666c50533ee282ee5b85e7277db12b7ee9de Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Sun, 4 May 2014 18:01:39 +0000 Subject: [PATCH 2/9] Added fix to grab configuration files under /var/lib/eucalyptus/db/data per issue - https://github.com/eucalyptus/eucalyptus-sosreport-plugins/issues/53 --- sos/plugins/eucadb.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sos/plugins/eucadb.py b/sos/plugins/eucadb.py index cf98cc8..ab91cb1 100644 --- a/sos/plugins/eucadb.py +++ b/sos/plugins/eucadb.py @@ -68,4 +68,20 @@ def setup(self): 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/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') + + if os.path.isfile('/var/lib/eucalyptus/db/data/pg_hba.conf.org'): + self.addCopySpec('/var/lib/eucalyptus/db/data/pg_hba.conf.org') + + if os.path.isfile('/var/lib/eucalyptus/db/data/pg_ident.conf'): + self.addCopySpec('/var/lib/eucalyptus/db/data/pg_ident.conf') + + if os.path.isfile('/var/lib/eucalyptus/db/data/postgresql.conf'): + self.addCopySpec('/var/lib/eucalyptus/db/data/postgresql.conf') + + if os.path.isfile('/var/lib/eucalyptus/db/data/postgresql.conf.org'): + self.addCopySpec('/var/lib/eucalyptus/db/data/postgresql.conf.org') + return From 615375285cb833ecf43c70c991d15d356d127881 Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Tue, 6 May 2014 14:21:33 +0000 Subject: [PATCH 3/9] Added fix for issue https://github.com/eucalyptus/eucalyptus-sosreport-plugins/issues/54 and https://github.com/eucalyptus/eucalyptus-sosreport-plugins/issues/56 --- sos/plugins/eucafrontend.py | 397 ++++++++++++++++++++++++++++++------ 1 file changed, 330 insertions(+), 67 deletions(-) diff --git a/sos/plugins/eucafrontend.py b/sos/plugins/eucafrontend.py index 62a4746..8b1ba7d 100644 --- a/sos/plugins/eucafrontend.py +++ b/sos/plugins/eucafrontend.py @@ -27,6 +27,10 @@ def checkenabled(self): return True return False + def checkversion(self, pkg): + eucapkg = self.policy().pkgByName(pkg) + return eucapkg.version + def clc_status(self): clc_check_cmd = ["/sbin/service", "eucalyptus-cloud", "status"] """ @@ -220,6 +224,121 @@ def get_ec2_url(self, tmp_dir): self.addDiagnose("Error: %s" % e) raise OSError(e) + def get_iam_url(self, tmp_dir): + """ + Grab EUARE_URL from unzip admin/eucalyptus credentials + """ + try: + with open(tmp_dir + "/eucarc") as eucarc_file: + for line in eucarc_file: + if re.search("^export EUARE", line): + name, var = line.partition("=")[::2] + iam_url = var.strip() + return iam_url + if iam_url is None: + self.addDiagnose("Error grabbing EUARE_URL from " + tmp_dir + "/eucarc") + raise + except OSError, e: + error_string = '%s' % e + if 'No such' in error_string: + self.addDiagnose("Error opening " + tmp_dir + "/eucarc") + raise OSError(e) + else: + self.addDiagnose("Error: %s" % e) + raise OSError(e) + + def get_autoscale_url(self, tmp_dir): + """ + Grab AWS_AUTO_SCALING_URL from unzip admin/eucalyptus credentials + """ + try: + with open(tmp_dir + "/eucarc") as eucarc_file: + for line in eucarc_file: + if re.search("^export AWS_AUTO_SCALING", line): + name, var = line.partition("=")[::2] + autoscale_url = var.strip() + return autoscale_url + if autoscale_url is None: + self.addDiagnose("Error grabbing AWS_AUTO_SCALING_URL from " + tmp_dir + "/eucarc") + raise + except OSError, e: + error_string = '%s' % e + if 'No such' in error_string: + self.addDiagnose("Error opening " + tmp_dir + "/eucarc") + raise OSError(e) + else: + self.addDiagnose("Error: %s" % e) + raise OSError(e) + + def get_elb_url(self, tmp_dir): + """ + Grab AWS_ELB_URL from unzip admin/eucalyptus credentials + """ + try: + with open(tmp_dir + "/eucarc") as eucarc_file: + for line in eucarc_file: + if re.search("^export AWS_ELB", line): + name, var = line.partition("=")[::2] + elb_url = var.strip() + return elb_url + if elb_url is None: + self.addDiagnose("Error grabbing AWS_ELB_URL from " + tmp_dir + "/eucarc") + raise + except OSError, e: + error_string = '%s' % e + if 'No such' in error_string: + self.addDiagnose("Error opening " + tmp_dir + "/eucarc") + raise OSError(e) + else: + self.addDiagnose("Error: %s" % e) + raise OSError(e) + + def get_cloudwatch_url(self, tmp_dir): + """ + Grab AWS_CLOUDWATCH_URL from unzip admin/eucalyptus credentials + """ + try: + with open(tmp_dir + "/eucarc") as eucarc_file: + for line in eucarc_file: + if re.search("^export AWS_CLOUDWATCH", line): + name, var = line.partition("=")[::2] + cloudwatch_url = var.strip() + return cloudwatch_url + if cloudwatch_url is None: + self.addDiagnose("Error grabbing AWS_CLOUDWATCH_URL from " + tmp_dir + "/eucarc") + raise + except OSError, e: + error_string = '%s' % e + if 'No such' in error_string: + self.addDiagnose("Error opening " + tmp_dir + "/eucarc") + raise OSError(e) + else: + self.addDiagnose("Error: %s" % e) + raise OSError(e) + + def get_sts_url(self, tmp_dir): + """ + Grab TOKEN_URL from unzip admin/eucalyptus credentials + """ + try: + with open(tmp_dir + "/eucarc") as eucarc_file: + for line in eucarc_file: + if re.search("^export TOKEN", line): + name, var = line.partition("=")[::2] + sts_url = var.strip() + return sts_url + if sts_url is None: + self.addDiagnose("Error grabbing STS_URL from " + tmp_dir + "/eucarc") + raise + except OSError, e: + error_string = '%s' % e + if 'No such' in error_string: + self.addDiagnose("Error opening " + tmp_dir + "/eucarc") + raise OSError(e) + else: + self.addDiagnose("Error: %s" % e) + raise OSError(e) + def euca2ools_conf_setup(self, tmp_dir): """ Create ini file under /etc/euca2ools/conf.d directory from @@ -242,6 +361,12 @@ def euca2ools_conf_setup(self, 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) + ec2_url = self.get_ec2_url(tmp_dir) + iam_url = self.get_iam_url(tmp_dir) + autoscale_url = self.get_autoscale_url(tmp_dir) + elb_url = self.get_elb_url(tmp_dir) + cloudwatch_url = self.get_cloudwatch_url(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") @@ -249,13 +374,13 @@ def euca2ools_conf_setup(self, tmp_dir): 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 = http://127.0.0.1:8773/services/AutoScaling/\n") - euca2ools_conf.write("ec2-url = http://127.0.0.1:8773/services/Eucalyptus/\n") - euca2ools_conf.write("elasticloadbalancing-url = http://127.0.0.1:8773/services/LoadBalancing/\n") - euca2ools_conf.write("iam-url = http://127.0.0.1:8773/services/Euare/\n") - euca2ools_conf.write("monitoring-url = http://127.0.0.1:8773/services/CloudWatch/\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 = http://127.0.0.1:8773/services/Tokens/\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") @@ -270,7 +395,16 @@ def get_accountlist(self): """ Grab a listing of Euare accounts and return the list """ - get_accountlist_cmd = ["/usr/bin/euare-accountlist", "--region", "admin@sosreport"] + 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) + 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] + else: + get_accountlist_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() except OSError, e: @@ -291,16 +425,37 @@ def get_account_info(self, account): """ Grab resources associated with the Euare account passed in """ - 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.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) + 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 --as-account " + account + creds_info, suggest_filename="euare-accountaliaslist-" + account) + self.collectExtOutput("/usr/bin/euare-accountlistpolicies -a " + account + " -v" + creds_info, suggest_filename="euare-accountlistpolicies-" + account) + self.collectExtOutput("/usr/bin/euare-userlistbypath --as-account " + account + creds_info, suggest_filename="euare-userlistbypath-" + account) + self.collectExtOutput("/usr/bin/euare-grouplistbypath --as-account " + 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) def get_userlist(self, account): """ Grab list of users of the Euare account passed in and return the list of users """ - get_userlist_cmd = ["/usr/bin/euare-userlistbypath", "--as-account", account, "--region", "admin@sosreport"] + 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) + secret_key = self.get_secret_key(tmp_dir) + iam_url = self.get_iam_url(tmp_dir) + get_userlist_cmd = ["/usr/bin/euare-userlistbypath", "--as-account", account, "-U", iam_url, "-I", access_key, "-S", secret_key] + else: + 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() except OSError, e: @@ -323,19 +478,43 @@ def get_account_user_info(self, account, user): """ Grab resources of users in the Euare account passed in """ - 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.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) + 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-usergetinfo --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-usergetinfo-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetloginprofile --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-usergetloginprofile-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistcerts --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-userlistcerts-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-usergetattributes --as-account " + account + " -u " + user + " --show-extra" + creds_info, suggest_filename="euare-usergetattributes-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistgroups --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-userlistgroups-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistkeys --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-userlistkeys-" + account + "-" + user) + self.collectExtOutput("/usr/bin/euare-userlistpolicies --as-account " + account + " -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) def get_grouplist(self, account): """ Grab the groups from the Euare account passed in and return the list """ - get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "--as-account", account, "--region", "admin@sosreport"] + 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) + secret_key = self.get_secret_key(tmp_dir) + iam_url = self.get_iam_url(tmp_dir) + get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "--as-account", account, "-U", iam_url, "-I", access_key, "-S", secret_key] + else: + 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() except OSError, e: @@ -359,8 +538,18 @@ def get_account_group_info(self, account, group): """ Grab the resources of the groups in the Euare account passed in """ - 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.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) + 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-grouplistusers --as-account " + account + " -g " + group + creds_info, suggest_filename="euare-grouplistusers-" + account + "-" + group) + self.collectExtOutput("/usr/bin/euare-grouplistpolicies --as-account " + account + " -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) def cleanup(self, tmp_dir): """ @@ -369,28 +558,98 @@ def cleanup(self, tmp_dir): 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") - - def setup(self): - self.addDiagnose("### Check to make sure eucalyptus-cloud is running ###") - self.clc_status() + + def eucalyptus_core(self, tmp_dir): self.addDiagnose("### Grabbing eucalyptus/admin credentials ###") - tmp_dir = self.eucacreds_setup() - self.addDiagnose("### Setting up sos-euca2ools.ini file ###") - self.euca2ools_conf_setup(tmp_dir) - self.addCopySpec("/etc/euca2ools") - 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-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") + 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 = " -I " + access_key + " -S " + secret_key + self.collectExtOutput("/usr/sbin/euca-describe-arbitrators -U " + ec2_url + creds_info, suggest_filename="euca-describe-arbitrators") + self.collectExtOutput("/usr/sbin/euca-describe-clouds -U " + ec2_url + creds_info, suggest_filename="euca-describe-clouds") + self.collectExtOutput("/usr/sbin/euca-describe-clusters -U " + ec2_url + creds_info, suggest_filename="euca-describe-clusters") + self.collectExtOutput("/usr/sbin/euca-describe-components -U " + ec2_url + creds_info, suggest_filename="euca-describe-components") + self.collectExtOutput("/usr/sbin/euca-describe-nodes -U http://127.0.0.1:8773/services/Empyrean/ " + creds_info, suggest_filename="euca-describe-nodes") + self.collectExtOutput("/usr/sbin/euca-describe-properties -U " + ec2_url + creds_info, suggest_filename="euca-describe-properties") + self.collectExtOutput("/usr/bin/euca-describe-regions -U " + ec2_url + creds_info, suggest_filename="euca-describe-regions") + self.collectExtOutput("/usr/sbin/euca-describe-services --all -E", suggest_filename="euca-describe-services-all") + self.collectExtOutput("/usr/sbin/euca-describe-storage-controllers -U " + ec2_url + creds_info, suggest_filename="euca-describe-storage-controllers") + self.collectExtOutput("/usr/sbin/euca-describe-vmware-brokers -U " + ec2_url + creds_info, suggest_filename="euca-describe-vmware-brokers") + self.collectExtOutput("/usr/sbin/euca-describe-walruses -U " + ec2_url + creds_info, suggest_filename="euca-describe-walruses") + self.collectExtOutput("/usr/bin/euca-version") + return + + 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) + secret_key = self.get_secret_key(tmp_dir) + ec2_url = self.get_ec2_url(tmp_dir) + creds_info = "-U " + ec2_url + " -I " + access_key + " -S " + secret_key + self.collectExtOutput("/usr/bin/euca-describe-addresses verbose " + creds_info, suggest_filename="euca-describe-addresses-verbose") + 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") + else: + if not os.path.isfile('/etc/euca2ools/conf.d/sos-euca2ools.ini'): + self.addDiagnose("### Setting up sos-euca2ools.ini file ###") + self.euca2ools_conf_setup(tmp_dir) + self.addCopySpec("/etc/euca2ools") + 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-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") + return + + 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) + 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") + for account in self.get_accountlist(): + self.get_account_info(account) + for user in self.get_userlist(account): + self.get_account_user_info(account, user) + for group in self.get_grouplist(account): + self.get_account_group_info(account, group) + else: + if not os.path.isfile('/etc/euca2ools/conf.d/sos-euca2ools.ini'): + self.addDiagnose("### Setting up sos-euca2ools.ini file ###") + self.euca2ools_conf_setup(tmp_dir) + self.addCopySpec("/etc/euca2ools") + self.addCopySpec("/tmp/eucacreds") + + 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): + self.get_account_user_info(account, user) + for group in self.get_grouplist(account): + self.get_account_group_info(account, group) + + return + + 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") @@ -398,35 +657,39 @@ def setup(self): 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") + return + + 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") + 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/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): - self.get_account_user_info(account, user) - for group in self.get_grouplist(account): - self.get_account_group_info(account, group) + return - self.addDiagnose("### Grabbing Cloud Component Data ###") - access_key = self.get_access_key(tmp_dir) - secret_key = self.get_secret_key(tmp_dir) - ec2_url = self.get_ec2_url(tmp_dir) - self.collectExtOutput("/usr/sbin/euca-describe-arbitrators -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-arbitrators") - self.collectExtOutput("/usr/sbin/euca-describe-clouds -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-clouds") - self.collectExtOutput("/usr/sbin/euca-describe-clusters -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-clusters") - self.collectExtOutput("/usr/sbin/euca-describe-components -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-components") - self.collectExtOutput("/usr/sbin/euca-describe-nodes -U http://127.0.0.1:8773/services/Empyrean/ -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-nodes") - self.collectExtOutput("/usr/sbin/euca-describe-properties -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-properties") - self.collectExtOutput("/usr/bin/euca-describe-regions -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-regions") - self.collectExtOutput("/usr/sbin/euca-describe-services --all -E", suggest_filename="euca-describe-services-all") - self.collectExtOutput("/usr/sbin/euca-describe-storage-controllers -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-storage-controllers") - self.collectExtOutput("/usr/sbin/euca-describe-vmware-brokers -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-vmware-brokers") - self.collectExtOutput("/usr/sbin/euca-describe-walruses -U " + ec2_url + " -I " + access_key + " -S " + secret_key, suggest_filename="euca-describe-walruses") - self.collectExtOutput("/usr/bin/euca-version") - self.cleanup(tmp_dir) + def setup(self): + self.addDiagnose("### Check to make sure eucalyptus-cloud is running ###") + self.clc_status() + self.addDiagnose("### Grabbing eucalyptus/admin credentials ###") + tmp_dir = self.eucacreds_setup() + self.addDiagnose("### Grab Eucalyptus Core Service Information ###") + self.eucalyptus_core(tmp_dir) + self.addDiagnose("### Grab Eucalyptus EC2 Service Information ###") + self.eucalyptus_ec2(tmp_dir) + self.addDiagnose("### Grab Eucalyptus IAM Service Information ###") + self.eucalyptus_iam(tmp_dir) + euca2ools_version = self.checkversion('euca2ools') + if re.match('^3+', euca2ools_version): + self.addDiagnose("### Grab Eucalyptus AutoScaling Service Information ###") + self.eucalyptus_autoscaling() + self.addDiagnose("### Grab Eucalyptus Elastic Load Balancing Service Information ###") + self.eucalyptus_elb() + self.addDiagnose("### Grab Eucalyptus CloudWatch Service Information ###") + self.eucalyptus_cloudwatch() + + self.cleanup(tmp_dir) return From bf07f5bd8b4877e4c95d2a10403fe482663b883b Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Tue, 6 May 2014 16:51:15 +0000 Subject: [PATCH 4/9] Updated get_access_key and get_secret_key to use EC2_SECRET_KEY and EC2_ACCESS_KEY --- sos/plugins/eucafrontend.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sos/plugins/eucafrontend.py b/sos/plugins/eucafrontend.py index 8b1ba7d..179897a 100644 --- a/sos/plugins/eucafrontend.py +++ b/sos/plugins/eucafrontend.py @@ -111,17 +111,17 @@ def eucacreds_setup(self): def get_access_key(self, tmp_dir): """ - Grab AWS_ACCESS_KEY from unzip admin/eucalyptus credentials + Grab EC2_ACCESS_KEY from unzip admin/eucalyptus credentials """ try: with open(tmp_dir + "/eucarc") as eucarc_file: for line in eucarc_file: - if re.search("^export AWS_ACCESS_KEY", line): + if re.search("^export EC2_ACCESS_KEY", line): name, var = line.partition("=")[::2] access_key = var.replace('\'','').strip() return access_key if access_key is None: - self.addDiagnose("Error grabbing AWS_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 @@ -134,17 +134,17 @@ def get_access_key(self, tmp_dir): def get_secret_key(self, tmp_dir): """ - Grab AWS_SECRET_KEY from unzip admin/eucalyptus credentials + Grab EC2_SECRET_KEY from unzip admin/eucalyptus credentials """ try: with open(tmp_dir + "/eucarc") as eucarc_file: for line in eucarc_file: - if re.search("^export AWS_SECRET_KEY", line): + if re.search("^export EC2_SECRET_KEY", line): name, var = line.partition("=")[::2] secret_key = var.replace('\'','').strip() return secret_key if secret_key is None: - self.addDiagnose("Error grabbing AWS_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 From 18d01bfe01dde71b40a6ffe961e13fe22a3ebcf6 Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Tue, 6 May 2014 20:42:14 +0000 Subject: [PATCH 5/9] Added support for Eucalyptus 3.2.2; updated eucacore to grab iptables-save --- sos/plugins/eucacore.py | 2 + sos/plugins/eucafrontend.py | 84 ++++++++++++++++++++----------------- 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/sos/plugins/eucacore.py b/sos/plugins/eucacore.py index 75f5097..1b62004 100644 --- a/sos/plugins/eucacore.py +++ b/sos/plugins/eucacore.py @@ -36,4 +36,6 @@ def setup(self): hprof_list = glob.glob('/var/log/eucalyptus/*.hprof') if hprof_list: 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") return diff --git a/sos/plugins/eucafrontend.py b/sos/plugins/eucafrontend.py index 179897a..c985519 100644 --- a/sos/plugins/eucafrontend.py +++ b/sos/plugins/eucafrontend.py @@ -391,13 +391,13 @@ def euca2ools_conf_setup(self, tmp_dir): euca2ools_conf.close() self.addDiagnose("Populated /etc/euca2ools/conf.d/sos-euca2ools.ini with admin creds") - def get_accountlist(self): + def get_accountlist(self, tmp_dir=''): """ Grab a listing of Euare accounts and return the list """ self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') - if re.match('^2.1+', euca2ools_version): + if re.match('^2.1+', euca2ools_version) and 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) @@ -421,38 +421,41 @@ def get_accountlist(self): accounts.append(entry[0]) return accounts - def get_account_info(self, account): + def get_account_info(self, account, tmp_dir=''): """ Grab resources associated with the Euare account passed in """ self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') - if re.match('^2.1+', euca2ools_version): + if re.match('^2.1+', euca2ools_version) and 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 --as-account " + account + creds_info, suggest_filename="euare-accountaliaslist-" + account) - self.collectExtOutput("/usr/bin/euare-accountlistpolicies -a " + account + " -v" + creds_info, suggest_filename="euare-accountlistpolicies-" + account) - self.collectExtOutput("/usr/bin/euare-userlistbypath --as-account " + account + creds_info, suggest_filename="euare-userlistbypath-" + account) - self.collectExtOutput("/usr/bin/euare-grouplistbypath --as-account " + account + creds_info, suggest_filename="euare-grouplistbypath-" + account) + 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) - def get_userlist(self, account): + def get_userlist(self, account, tmp_dir=''): """ Grab list of users of the Euare account passed in and return the list of users """ self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') - if re.match('^2.1+', euca2ools_version): + if re.match('^2.1+', euca2ools_version) and 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_userlist_cmd = ["/usr/bin/euare-userlistbypath", "--as-account", account, "-U", iam_url, "-I", access_key, "-S", secret_key] + if re.match('^eucalyptus', account): + 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] else: get_userlist_cmd = ["/usr/bin/euare-userlistbypath", "--as-account", account, "--region", "admin@sosreport"] @@ -474,24 +477,28 @@ def get_userlist(self, account): users.append(user_id[1]) return users - def get_account_user_info(self, account, user): + def get_account_user_info(self, account, user, tmp_dir=''): """ Grab resources of users in the Euare account passed in """ self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') - if re.match('^2.1+', euca2ools_version): + if re.match('^2.1+', euca2ools_version) and 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-usergetinfo --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-usergetinfo-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-usergetloginprofile --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-usergetloginprofile-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistcerts --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-userlistcerts-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-usergetattributes --as-account " + account + " -u " + user + " --show-extra" + creds_info, suggest_filename="euare-usergetattributes-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistgroups --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-userlistgroups-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistkeys --as-account " + account + " -u " + user + creds_info, suggest_filename="euare-userlistkeys-" + account + "-" + user) - self.collectExtOutput("/usr/bin/euare-userlistpolicies --as-account " + account + " -u " + user + " -v" + creds_info, suggest_filename="euare-userlistpolicies-" + account + "-" + user) + 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) 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) @@ -501,17 +508,20 @@ def get_account_user_info(self, 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): + def get_grouplist(self, account, tmp_dir=''): """ Grab the groups from the Euare account passed in and return the list """ self.addDiagnose("### Grabbing version of euca2ools ###") euca2ools_version = self.checkversion('euca2ools') - if re.match('^2.1+', euca2ools_version): + if re.match('^2.1+', euca2ools_version) and 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_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "--as-account", account, "-U", iam_url, "-I", access_key, "-S", secret_key] + if re.match('^eucalyptus', account): + 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] else: get_grouplist_cmd = ["/usr/bin/euare-grouplistbypath", "--as-account", account, "--region", "admin@sosreport"] @@ -534,7 +544,7 @@ def get_grouplist(self, account): groups.append(group_id[1]) return groups - def get_account_group_info(self, account, group): + def get_account_group_info(self, account, group, tmp_dir=''): """ Grab the resources of the groups in the Euare account passed in """ @@ -545,8 +555,12 @@ def get_account_group_info(self, account, group): 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-grouplistusers --as-account " + account + " -g " + group + creds_info, suggest_filename="euare-grouplistusers-" + account + "-" + group) - self.collectExtOutput("/usr/bin/euare-grouplistpolicies --as-account " + account + " -g " + group + " -v" + creds_info, suggest_filename="euare-grouplistpolicies-" + account + "-" + group) + 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) 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) @@ -577,7 +591,6 @@ def eucalyptus_core(self, tmp_dir): self.collectExtOutput("/usr/sbin/euca-describe-vmware-brokers -U " + ec2_url + creds_info, suggest_filename="euca-describe-vmware-brokers") self.collectExtOutput("/usr/sbin/euca-describe-walruses -U " + ec2_url + creds_info, suggest_filename="euca-describe-walruses") self.collectExtOutput("/usr/bin/euca-version") - return def eucalyptus_ec2(self, tmp_dir): self.addDiagnose("### Grabbing version of euca2ools ###") @@ -616,7 +629,6 @@ def eucalyptus_ec2(self, tmp_dir): 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") - return def eucalyptus_iam(self, tmp_dir): self.addDiagnose("### Grabbing version of euca2ools ###") @@ -626,12 +638,12 @@ def eucalyptus_iam(self, 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") - for account in self.get_accountlist(): - self.get_account_info(account) - for user in self.get_userlist(account): - self.get_account_user_info(account, user) - for group in self.get_grouplist(account): - self.get_account_group_info(account, group) + for account in self.get_accountlist(tmp_dir): + self.get_account_info(account, tmp_dir) + for user in self.get_userlist(account, tmp_dir): + self.get_account_user_info(account, user, tmp_dir) + for group in self.get_grouplist(account, tmp_dir): + self.get_account_group_info(account, group, tmp_dir) else: if not os.path.isfile('/etc/euca2ools/conf.d/sos-euca2ools.ini'): self.addDiagnose("### Setting up sos-euca2ools.ini file ###") @@ -647,8 +659,6 @@ def eucalyptus_iam(self, tmp_dir): for group in self.get_grouplist(account): self.get_account_group_info(account, group) - return - 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") @@ -657,7 +667,6 @@ def eucalyptus_autoscaling(self): 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") - return 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") @@ -668,7 +677,6 @@ def eucalyptus_elb(self): 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") - return def setup(self): self.addDiagnose("### Check to make sure eucalyptus-cloud is running ###") From a09f56f80d92e3e5889745ce7c6ef2390ee888fc Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Wed, 7 May 2014 00:05:21 +0000 Subject: [PATCH 6/9] Added minor fixes for eucalyptus_ec2 to take into account the differences between 2.1 euca2ools and 3.x euca2ools --- sos/plugins/eucafrontend.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sos/plugins/eucafrontend.py b/sos/plugins/eucafrontend.py index c985519..ea5c8e1 100644 --- a/sos/plugins/eucafrontend.py +++ b/sos/plugins/eucafrontend.py @@ -577,19 +577,18 @@ def eucalyptus_core(self, tmp_dir): self.addDiagnose("### Grabbing eucalyptus/admin credentials ###") access_key = self.get_access_key(tmp_dir) secret_key = self.get_secret_key(tmp_dir) - ec2_url = self.get_ec2_url(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 " + ec2_url + creds_info, suggest_filename="euca-describe-arbitrators") - self.collectExtOutput("/usr/sbin/euca-describe-clouds -U " + ec2_url + creds_info, suggest_filename="euca-describe-clouds") - self.collectExtOutput("/usr/sbin/euca-describe-clusters -U " + ec2_url + creds_info, suggest_filename="euca-describe-clusters") - self.collectExtOutput("/usr/sbin/euca-describe-components -U " + ec2_url + creds_info, suggest_filename="euca-describe-components") - self.collectExtOutput("/usr/sbin/euca-describe-nodes -U http://127.0.0.1:8773/services/Empyrean/ " + creds_info, suggest_filename="euca-describe-nodes") - self.collectExtOutput("/usr/sbin/euca-describe-properties -U " + ec2_url + creds_info, suggest_filename="euca-describe-properties") - self.collectExtOutput("/usr/bin/euca-describe-regions -U " + ec2_url + creds_info, suggest_filename="euca-describe-regions") + 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 " + ec2_url + creds_info, suggest_filename="euca-describe-storage-controllers") - self.collectExtOutput("/usr/sbin/euca-describe-vmware-brokers -U " + ec2_url + creds_info, suggest_filename="euca-describe-vmware-brokers") - self.collectExtOutput("/usr/sbin/euca-describe-walruses -U " + ec2_url + creds_info, suggest_filename="euca-describe-walruses") + 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-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/bin/euca-version") def eucalyptus_ec2(self, tmp_dir): @@ -599,8 +598,9 @@ def eucalyptus_ec2(self, 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 + " -I " + access_key + " -S " + secret_key + 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") @@ -624,6 +624,7 @@ def eucalyptus_ec2(self, tmp_dir): 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") From 4469b2291638223a4924306b3c55ca7fbcaead83 Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Wed, 7 May 2014 00:13:05 +0000 Subject: [PATCH 7/9] Added ability to grab vmwarebroker table in eucadb module - issue https://github.com/eucalyptus/eucalyptus-sosreport-plugins/issues/51 --- sos/plugins/eucadb.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sos/plugins/eucadb.py b/sos/plugins/eucadb.py index ab91cb1..5f8a1af 100644 --- a/sos/plugins/eucadb.py +++ b/sos/plugins/eucadb.py @@ -66,6 +66,9 @@ def setup(self): 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) From ca22046b0d6d120d26daf334d76841f62f48c5dc Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Wed, 7 May 2014 00:16:58 +0000 Subject: [PATCH 8/9] Updated eucafrontend so that euca-describe-vmwarebrokers is only called when eucalyptus-enterprise-vmware-broker package is present --- sos/plugins/eucafrontend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sos/plugins/eucafrontend.py b/sos/plugins/eucafrontend.py index ea5c8e1..6422afa 100644 --- a/sos/plugins/eucafrontend.py +++ b/sos/plugins/eucafrontend.py @@ -587,7 +587,8 @@ def eucalyptus_core(self, tmp_dir): 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-vmware-brokers -U " + empyrean_url + creds_info, suggest_filename="euca-describe-vmware-brokers") + 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/bin/euca-version") From b8f04a360823b641210262e46998ff64f08c7bc7 Mon Sep 17 00:00:00 2001 From: "Harold Spencer, Jr" Date: Wed, 7 May 2014 02:36:08 +0000 Subject: [PATCH 9/9] Updated spec to version 0.1.6 --- eucalyptus-sos-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eucalyptus-sos-plugins.spec b/eucalyptus-sos-plugins.spec index ea04e74..9a45a2a 100644 --- a/eucalyptus-sos-plugins.spec +++ b/eucalyptus-sos-plugins.spec @@ -2,7 +2,7 @@ Summary: A plugin to sosreport to collect data about Eucalyptus clouds Name: eucalyptus-sos-plugins -Version: 0.1.5 +Version: 0.1.6 Release: 0%{?dist} Source0: %{name}-%{version}.tar.gz Group: Applications/System