aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhjaggars <jhjaggars@gmail.com>2012-02-06 08:33:58 -0800
committerjhjaggars <jhjaggars@gmail.com>2012-02-06 08:33:58 -0800
commit1fdeee626a27a37cbf8e6408b186611932535212 (patch)
treeb21a986f9a05e27da0820270d87b78eb210050da
parent6cc17fe29ea342110e627a741ef25dd3cbb7af03 (diff)
parent9046f1851cbcff30c1684b6a60d87ac1d0e33789 (diff)
downloadsos-1fdeee626a27a37cbf8e6408b186611932535212.tar.gz
Merge pull request #19 from jhjaggars/master
Rename eap6 to as7 and add deployed archive listing to as7 plugin
-rw-r--r--Makefile9
-rw-r--r--sos/plugins/as7.py61
2 files changed, 62 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index a4b8513f..1e1b249a 100644
--- a/Makefile
+++ b/Makefile
@@ -79,14 +79,15 @@ gpgkey:
po: clean
mkdir -p $(PO_DIR)
for po in `ls po/*.po`; do \
- $(MSGCAT) -p -o $(PO_DIR)/$$(basename $$po | awk -F. '{print $$1}').properties $$po; \
+ $(MSGCAT) -p -o $(PO_DIR)/sos_$$(basename $$po | awk -F. '{print $$1}').properties $$po; \
done; \
- cp $(PO_DIR)/en.properties $(PO_DIR)/en_US.properties
+ cp $(PO_DIR)/sos_en.properties $(PO_DIR)/sos_en_US.properties
+ cp $(PO_DIR)/sos_en.properties $(PO_DIR)/sos.properties
-eap6: po
+as7: po
cp -r sos/* $(SRC_BUILD)/sos/
- find $(SRC_BUILD)/sos/plugins/ -not -name "*eap6.py" -not -name "*__init__.py" -type f -delete
+ find $(SRC_BUILD)/sos/plugins/ -not -name "*as7.py" -not -name "*__init__.py" -type f -delete
zip: po
zip -r $(ZIP_DEST) sos
diff --git a/sos/plugins/as7.py b/sos/plugins/as7.py
index d5abea22..c31696ef 100644
--- a/sos/plugins/as7.py
+++ b/sos/plugins/as7.py
@@ -1,7 +1,11 @@
import os
+import sys
import re
import zipfile
import urllib2
+import tempfile
+from xml.etree import ElementTree
+from itertools import chain
try:
import json
@@ -137,7 +141,6 @@ class AS7(Plugin, IndependentPlugin):
else:
self.addAlert("WARN: No jars found in JBoss system path (" + self.__jbossHome + ").")
-
def query(self, request_obj):
try:
return self.query_java(request_obj)
@@ -274,14 +277,64 @@ class AS7(Plugin, IndependentPlugin):
self.addForbiddenPath(os.path.join(confDir, 'mgmt-users.properties'))
self.doCopyFileOrDir(confDir, sub=(self.__jbossHome, 'JBOSSHOME'))
- ## Log dir next
- logDir = os.path.join(path, "log")
- for logFile in find("*", logDir):
+ for logFile in find("*.log", path):
self.addCopySpecLimit(logFile,
self.getOption("logsize"),
sub=(self.__jbossHome, 'JBOSSHOME'))
+ deployment_info = self.__get_deployment_info(confDir)
+ deployments = self.__get_deployments(path)
+ for deployment in deployments:
+ self.__get_listing_from_deployment(deployment, deployment_info)
+
+ def __get_deployment_info(self, dir_):
+ """Gets the deployment name to sha1 mapping for all deployments defined
+ in configs under dir_"""
+ deployment_info = {}
+ for config in find("*.xml", dir_):
+ root = ElementTree.parse(config).getroot()
+ # the namespace is harder to fetch than it should be
+ ns = root.tag.rpartition("}")[0]
+ ns += "}"
+ for deployment in root.findall("./%sdeployments/%sdeployment" % (ns, ns)):
+ name = deployment.attrib.get("name")
+ sha1 = deployment.getchildren()[0].attrib.get("sha1")
+ deployment_info[sha1] = name
+ return deployment_info
+
+ def __get_deployments(self, path):
+ return list(chain(
+ find("*", os.path.join(path, "deployments")),
+ find("content", path)))
+
+ def __get_listing_from_deployment(self, path, mapping):
+ try:
+ zf = zipfile.ZipFile(path)
+ contents = []
+ for zipinfo in zf.infolist():
+ if zipinfo.filename.endswith("/"):
+ continue
+ contents.append((zipinfo.filename, zipinfo.file_size))
+ zf.close()
+ contents.sort()
+ output = "\n".join(["%s:%d" % (fn, fs) for fn, fs in contents])
+
+ path_to = path.replace(self.__jbossHome, '')
+ if 'content' in path:
+ path_to = path_to.strip(os.path.sep).rstrip("content")
+ path_to = os.path.join(*path_to.split(os.path.sep)[:-2])
+ sha1 = "".join(path.split(os.path.sep)[-3:-1])
+ name = mapping.get(sha1, sha1)
+ else:
+ path_to, name = os.path.split(path_to)
+
+ self.addStringAsFile(output, os.path.join(path_to, "%s.txt" % name))
+ except:
+ # this is probably not a zipfile so we don't care
+ pass
+
+
def setup(self):
## We need to know where JBoss is installed and if we can't find it we