Author: tmckay
Date: 2012-04-09 21:21:50 +0000 (Mon, 09 Apr 2012)
New Revision: 5288
Modified:
branches/play_plumage/cumin/etc/cumin.conf
branches/play_plumage/cumin/model/plumage/plumage.xml
branches/play_plumage/cumin/python/cumin/config.py
branches/play_plumage/mint/python/mint/plumage/main.py
branches/play_plumage/mint/python/mint/plumage/session.py
Log:
Allow classes for a report instance to be specified from cumin.conf
Add update_time to pretend data.
Modified: branches/play_plumage/cumin/etc/cumin.conf
===================================================================
--- branches/play_plumage/cumin/etc/cumin.conf 2012-04-09 19:48:49 UTC (rev 5287)
+++ branches/play_plumage/cumin/etc/cumin.conf 2012-04-09 21:21:50 UTC (rev 5288)
@@ -86,6 +86,8 @@
# section based on 'persona'. See additional comments in [data] section.
#datas: data
+# reports: report
+
# ****************************************************
[web]
@@ -176,6 +178,10 @@
# include-classes: [all]
exclude-classes: com.redhat.grid:*, com.redhat.sesame:*
+[report]
+# include-classes: [all]
+# exclude-classes: [none]
+
# *************** Some parameter explanations by section ***************
## [common]
Modified: branches/play_plumage/cumin/model/plumage/plumage.xml
===================================================================
--- branches/play_plumage/cumin/model/plumage/plumage.xml 2012-04-09 19:48:49 UTC (rev
5287)
+++ branches/play_plumage/cumin/model/plumage/plumage.xml 2012-04-09 21:21:50 UTC (rev
5288)
@@ -9,5 +9,6 @@
<statistic name="avail" type="uint32" unit="uint32"
/>
<statistic name="used" type="uint32" unit="uint32"
/>
+ <statistic name="update_time" type="absTime"
unit="uint32" />
</class>
</schema>
Modified: branches/play_plumage/cumin/python/cumin/config.py
===================================================================
--- branches/play_plumage/cumin/python/cumin/config.py 2012-04-09 19:48:49 UTC (rev 5287)
+++ branches/play_plumage/cumin/python/cumin/config.py 2012-04-09 21:21:50 UTC (rev 5288)
@@ -98,7 +98,7 @@
param.default = "web"
param = ConfigParameter(master, "reports", str)
- param.default = ""
+ param.default = "report"
class CuminConfigSection(ConfigSection):
def __init__(self, config, name, strict_section=False):
Modified: branches/play_plumage/mint/python/mint/plumage/main.py
===================================================================
--- branches/play_plumage/mint/python/mint/plumage/main.py 2012-04-09 19:48:49 UTC (rev
5287)
+++ branches/play_plumage/mint/python/mint/plumage/main.py 2012-04-09 21:21:50 UTC (rev
5288)
@@ -32,8 +32,12 @@
self.print_event_level = 0
- self.packages = []
+ self.packages = set()
+ self.classes = set()
+
+ self.package_filter = ["com.redhat.cumin"]
+
def check(self):
log.info("Checking %s", self)
Modified: branches/play_plumage/mint/python/mint/plumage/session.py
===================================================================
--- branches/play_plumage/mint/python/mint/plumage/session.py 2012-04-09 19:48:49 UTC (rev
5287)
+++ branches/play_plumage/mint/python/mint/plumage/session.py 2012-04-09 21:21:50 UTC (rev
5288)
@@ -1,4 +1,5 @@
import logging
+import time
from mint.util import MintDaemonThread
from time import sleep
@@ -11,7 +12,7 @@
def __init__(self, app, server_url):
self.app = app
self.server_url = server_url
- self.thread = PlumageSessionThread(app, server_url)
+ self.threads = []
def check(self):
log.info("Checking %s", self)
@@ -19,21 +20,52 @@
def init(self):
log.info("Initializing %s", self)
+ # Apply the package filter to the class list
+ if len(self.app.classes):
+ black_list = set()
+ for cls in self.app.classes:
+ if cls._package._name in self.app.package_filter:
+ black_list.add(cls)
+ else:
+ # We're going to have a thread for this...
+ self.threads.append(PlumageSessionThread(
+ self.app,
+ self.server_url,
+ cls))
+
+ # Update our list, minus the black_list
+ self.app.classes.difference_update(black_list)
+
+ else:
+ # Generate the package list from the model, minus
+ # the package filter
+ for pkg in self.app.model._packages:
+ if pkg._name not in self.app.package_filter:
+ self.app.packages.add(pkg)
+ for cls in pkg._classes:
+ self.threads.append(PlumageSessionThread(
+ self.app,
+ self.server_url,
+ cls))
+
def start(self):
log.info("Starting %s", self)
- self.thread.start()
+ for t in self.threads:
+ t.start()
def stop(self):
log.info("Stopping %s", self)
- self.thread.stop()
+ for t in self.threads:
+ t.stop()
def __repr__(self):
return "%s(%s)" % (self.__class__.__name__, self.server_url)
class PlumageSessionThread(MintDaemonThread):
- def __init__(self, app, server_url):
+ def __init__(self, app, server_url, cls):
super(PlumageSessionThread, self).__init__(app)
self.server_url = server_url
+ self.cls = cls
def run(self):
uuid = 1
@@ -44,7 +76,7 @@
# We create objects here. Tag them with the right class,
# probably specified to us from a config option (with a corresponding
# query specification in the xml)
- cls = self.app.model.com_redhat_grid_plumage.OSUtil
+ #cls = self.app.model.com_redhat_grid_plumage.OSUtil
class OSUtil(object):
pass
@@ -55,6 +87,7 @@
os.uuid = str(uuid)
os.osName = "Linux"
+ os.update_time = time.time() * 1000000000
# random, 16 slots
os.avail = randrange(0, 17)
@@ -62,7 +95,7 @@
# some number of available used
os.used = randrange(0, os.avail+1)
- obj = ObjectUpdate(self.app.model, os, cls)
+ obj = ObjectUpdate(self.app.model, os, self.cls)
self.app.update_thread.enqueue(obj)
sleep(1)