Author: croberts
Date: 2012-03-21 20:09:23 +0000 (Wed, 21 Mar 2012)
New Revision: 5260
Modified:
trunk/cumin/python/cumin/grid/main.py
trunk/cumin/python/cumin/grid/slot.py
trunk/cumin/python/cumin/grid/slot.strings
trunk/cumin/python/cumin/grid/slotvis.py
trunk/cumin/python/cumin/grid/slotvis.strings
trunk/cumin/python/cumin/inventory/main.py
trunk/cumin/python/cumin/inventory/system.py
trunk/cumin/python/cumin/inventory/system.strings
Log:
Per BZ 805029, code cleanup following the slotvis removal.
Modified: trunk/cumin/python/cumin/grid/main.py
===================================================================
--- trunk/cumin/python/cumin/grid/main.py 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/grid/main.py 2012-03-21 20:09:23 UTC (rev 5260)
@@ -5,8 +5,6 @@
from cumin import *
from cumin.objecttask import *
from cumin.util import *
-from cumin.grid.slot import SlotMapPage
-from cumin.grid.slotvis import PoolSlotFullPage
from submission import *
from pool import *
@@ -29,12 +27,6 @@
self.app.main_page.main.grid = self.frame
self.app.main_page.main.add_tab(self.frame)
- self.pool_slots_page = SlotMapPage(self.app, "poolslots.vis")
- self.app.add_page(self.pool_slots_page)
- self.pool_slots_fullpage = PoolSlotFullPage \
- (self.app, "poolslotsfull.vis")
- self.app.add_page(self.pool_slots_fullpage)
-
def init_test(self, test):
GridTest("grid", test)
Modified: trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- trunk/cumin/python/cumin/grid/slot.py 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/grid/slot.py 2012-03-21 20:09:23 UTC (rev 5260)
@@ -21,22 +21,6 @@
super(SlotFrame, self).__init__(app, name, cls)
-class SlotDataSet(CuminSqlDataSet):
- def __init__(self, app):
- super(SlotDataSet, self).__init__(app)
-
- self.where_exprs.default = list()
-
- def sort_records(self, records):
- try:
- for rec in records:
- rec["category"], rec["category_group"] =
SlotMapPage.get_cat_and_group(rec["State"], rec["Activity"])
- recs = sorted(records, key=lambda x:"%s%s%s" %
- (x["category_group"], x["category"],
x["Name"]))
- except Exception:
- return records
- return recs
-
class SlotLoadStatSet(StatSet):
def __init__(self, app, name, object):
super(SlotLoadStatSet, self).__init__(app, name, object)
@@ -81,497 +65,3 @@
return [(x.get_title(session), x.value(session, obj), x.escape)
for x in cls.properties if x.category == self.category]
-class SlotMapPage(Page):
- """ handles the slots.vis request """
-
- categories = {("Owner", None): ("Unavailable",
"Owner"),
- ("Unclaimed", None): ("Available",
"Unclaimed"),
- ("Matched", None): ("Starting",
"Transitioning"),
- ("Claimed", "Idle"): ("Starting",
"Transitioning"),
- ("Claimed", "Busy"): ("Running",
"Busy"),
- ("Claimed", "Retiring"): ("Running",
"Busy"),
- ("Claimed", "Suspended"): ("Paused",
"Busy"),
- ("Preempting", None): ("Stopping",
"Transitioning"),
- ("Unknown", None): ("Unknown",
"Unknown")}
-
- shapes = {"Unavailable": {"shape": "filled_triangle",
"color": (.6,.6,.6)},
- "Available": {"shape": "box",
"color": (.6,.6,.6)},
- "Stopping": {"shape": "diagonal",
"color": (1,.2,.2)},
- "Starting": {"shape": "diagonal",
"color": (.2,1,8)},
- "Paused": {"shape": "solid",
"color": (1,.2,.2)},
- "Running": {"shape": "solid",
"color": (0,.8,0)},
- "Busy": {"shape": "solid", "color":
(0,.8,0)},
- "Transitioning": {"shape": "diagonal",
"color": (.8,0,.8)},
- "Unclaimed": {"shape": "box",
"color": (.6,.6,.6)},
- "Owner": {"shape": "filled_triangle",
"color": (.6,.6,.6)},
- "Unknown": {"shape": "solid",
"color": (1,0,0)}}
-
- interiors = {"Idle": (.7,.7,.7),
- "Busy": (0.0, 0.4, 0.0),
- "Suspended": (1,0,0),
- "Vacating": (1,.73,.367),
- "Killing": (0,0,1),
- "Benchmarking": (1,.8,.8),
- "Retiring": (.8,.2,.8),
- "Unknown": (.8,.8,.8)}
-
- max_width = 400
- max_png_age = 30
-
- # start creating artificial groupings after the number of real groups
- max_top_level_items = 500
-
- def __init__(self, app, name, param=None, desc=""):
- super(SlotMapPage, self).__init__(app, name)
-
- self.object_param = param
- self.object_description = desc
-
- self.zoom_level = IntegerParameter(app, "zl")
- self.zoom_level.default = 1
- self.add_parameter(self.zoom_level)
-
- self.category = Parameter(app, "category")
- self.add_parameter(self.category)
-
- self.json = Parameter(app, "json")
- self.add_parameter(self.json)
-
- self.sequence = IntegerParameter(app, "seq")
- self.sequence.default = 0
- self.add_parameter(self.sequence)
-
- self.expanded = Parameter(app, "expanded")
- self.expanded.default = ""
- self.expanded.all = "all"
- self.add_parameter(self.expanded)
-
- self.group = Parameter(app, "group")
- self.add_parameter(self.group)
-
- self.slots = SlotDataSet(app)
-
- @classmethod
- def get_categories(cls):
- return cls.categories
-
- @classmethod
- def get_unique_category_groups(cls):
- categories = cls.categories
- d = dict()
- for x in categories:
- _, group = categories[x]
- if not group == "Unknown":
- d[group] = None
- return d.keys()
-
- def get_content_type(self, session):
- return self.json.get(session) and "text/plain" or
"image/png"
-
- def get_cache_control(self, session):
- return "no-cache"
-
- def render_category(self, session, category):
- map = HeatMapChart()
- surface = map.plot_colored_shape(self.shapes[category]["color"],
- self.shapes[category]["shape"], 20,
20)
- writer = Writer()
- surface.write_to_png(writer)
- return writer.to_string()
-
- def do_render(self, session):
- # render the legend icon
- category = self.category.get(session)
- if category:
- return self.render_category(session, category)
-
- # generate the json data for the flash chart
- if self.json.get(session):
- return self.render_json(session)
-
- zl = self.zoom_level.get(session)
-
- map = HeatMapChart(self.max_width, self.max_width)
-
- cursor = self.slots.execute(session)
- records = cursor_to_rows(cursor)
-
- if len(records) == 0:
- return
-
- records = self.slots.sort_records(records)
- shape_info = list()
- for rec in records:
- cat = rec["category"]
- shape_info.append(self.shapes[cat])
- size = map.plot_shapes(shape_info, zl)
-
- args = (size, map.width, map.height, len(shape_info), map.rows, map.cols)
- cookie = "|".join((str(x) for x in args))
- session.set_cookie("slot_info", cookie)
-
- writer = Writer()
- map.write(writer)
- return writer.to_string()
-
- def split_compound_attribute(self, record, attr):
- if "|" in attr:
- attr_list = attr.split("|")
- atr_list = [record[x] for x in attr_list]
- return ":".join(atr_list)
- return ""
-
- def get_info_array(self, records, array, attr):
- '''
- Creates a list of record indexes for each unique value of attr
- @param records: all the records
- @param array: list of indexes to check
- @param attr: the rosemary attribute to create the array for
- '''
- d = dict()
- for i in array:
- try:
- atr = records[i][attr]
- except KeyError:
- atr = self.split_compound_attribute(records[i], attr)
- if not atr:
- atr = "Unknown %s" % attr
- if not atr in d:
- d[atr] = {"plist": list()}
- d[atr]["klist"] = [atr]
- d[atr]["plist"].append(i)
- return d
-
- def collapse_level(self, level_dict, count):
- collapsed = dict()
-
- def save_bucket(low_key, key, plist, keylist):
- if low_key is not key:
- coll_key = "%s - %s" % (low_key, key)
- else:
- coll_key = low_key
- collapsed[coll_key] = {"plist": plist,
- "klist": keylist}
-
- plist = list()
- keylist = list()
- max_edge = len(level_dict) - 1
- bucket_size = int(max_edge / count)
- edge = bucket_size
- low_key = None
- for i, key in enumerate(sorted(level_dict.keys())):
- if not low_key:
- low_key = key
- plist.extend(level_dict[key]["plist"])
- keylist.append(key)
- if i >= edge:
- save_bucket(low_key, key, plist, keylist)
- low_key = None
- plist = list()
- keylist = list()
- edge += bucket_size
- if edge > max_edge:
- edge = max_edge
-
- if low_key:
- save_bucket(low_key, key, plist, keylist)
- return collapsed
-
- @classmethod
- def get_cat_and_group(cls, state, activity):
- act = activity
- if state in ("Owner", "Unclaimed", "Matched",
"Preempting", "Unknown"):
- # activity doesn't matter for these states
- act = None
- try:
- cat, cat_group = cls.categories[(state, act)]
- except:
- log.debug("Problem finding state and activity", exc_info=True)
- cat, cat_group = ("%s:%s" % (state, activity),
"Unknown")
-
- return cat, cat_group
-
- def get_cats(self, records, plist):
- d = dict()
- for i in plist:
- state = records[i]["State"]
- activity = records[i]["Activity"]
-
- cat, cat_group = SlotMapPage.get_cat_and_group(state, activity)
- if not cat_group in d:
- d[cat_group] = dict()
- if not cat in d[cat_group]:
- d[cat_group][cat] = 0
- d[cat_group]["_count"] = 0
- d[cat_group]["_count"] += 1
- d[cat_group][cat] += 1
-
- return d
-
- def render_json(self, session):
- cursor = self.slots.execute(session)
- records = cursor_to_rows(cursor)
-
- if len(records) == 0:
- return "[]"
-
- records = self.slots.sort_records(records)
- group = self.group.get(session)
- slot_count = len(records)
-
- root = Element()
-
- # Not sure these are used. Code was modified
- # when collector filtering was removed. If values
- # are needed here they can be synthesized in the case
- # of a collector
- root.name = self.object_description
- if self.object_param != None:
- root.value = self.object_param.get(session)._id
- else:
- root.value = ""
-
- root.slots = slot_count
- json = self.json.get(session)
- sequence = self.sequence.get(session)
- root.vis = json
- root.seq = sequence
- root.shape_info = self.shapes
- root.activity_colors = self.interiors
- expanded = self.expanded.get(session)
- root.tree = self.treeify(records, range(slot_count), group, expanded)
- root.back = False
- return "[%s]" % root.create()
-
- def treeify(self, records, plist, group, expanded):
- def add_branch(level_list, tree, back, group, key, slots):
- if len(tree):
- el = Element()
- el.tree = tree
- el.back = back
- el.name = group
- el.value = key
- el.slots = slots
- el.level = 0
- level_list.append(el)
-
- def gen_leaves(plist):
- level_list = list()
- for i in sorted(plist, key=lambda x:"%s%s%s" %
- (records[x]["category_group"],
records[x]["category"], records[x]["Name"])):
- el = Element()
- el.job_id = records[i]["JobId"] and
records[i]["JobId"] or ""
- el.activity = records[i]["Activity"] and
records[i]["Activity"] or "Unknown"
- el.state = records[i]["State"] and
records[i]["State"] or "Unknown"
- el.category = records[i]["category"]
- el.category_group = records[i]["category_group"]
- el.value = records[i]["Name"] and records[i]["Name"]
or ""
- el.load_avg = records[i]["LoadAvg"] and
round(records[i]["LoadAvg"], 2) or 0
- el.name = "slot"
- el.slot_id = records[i]["_id"]
- level_list.append(el)
- return level_list
-
- def gen_summary(plist):
- # display summary info for all the slots under this grouping
- level_list = list()
- category_groups = self.get_cats(records, plist)
- for category_group in sorted(category_groups):
- el = Element()
- el.name = "slot_info"
- el.category = category_group
- el.category_group = category_group
- el.count = category_groups[category_group]["_count"]
- try:
- el.value = "%s.%s" % (records[plist[0]][group],
category_group) # uid
- except KeyError:
- atr = self.split_compound_attribute(records[plist[0]], group)
- el.value = "%s.%s" % (atr, category_group)
- level_list.append(el)
- return level_list
-
- level_list = list()
- if not group:
- tree = gen_leaves(plist)
- add_branch(level_list, tree, False, "", "", len(plist))
- return level_list
-
- original_level_dict = level_dict = self.get_info_array(records, plist, group)
-
- if len(original_level_dict) > self.max_top_level_items:
- # collapse groups into artificial sub-groups
- level_dict = self.collapse_level(original_level_dict,
self.max_top_level_items)
-
- for key in sorted(level_dict):
- tree = list()
- if not expanded:
- #if len(level_dict) == 1:
- # # there is only one grouping. no need to make them click on it
- # tree = gen_leaves(level_dict[key]["plist"])
- # add_branch(level_list, tree, False, group, key,
len(level_dict[key]["plist"]))
- #else:
- # display the top level of groups (artificial or natural)
- tree = gen_summary(level_dict[key]["plist"])
- add_branch(level_list, tree, False, group, key,
len(level_dict[key]["plist"]))
- elif expanded == key:
- # lowest level of a natural group
- if key in original_level_dict:
- tree = gen_leaves(level_dict[key]["plist"])
- add_branch(level_list, tree, True, group, key,
len(level_dict[key]["plist"]))
- else:
- # we want to display the groups that went into an atrificial
sub-group
- for original_key in level_dict[key]["klist"]:
- tree =
gen_summary(original_level_dict[original_key]["plist"])
- add_branch(level_list, tree, True, group, original_key,
len(original_level_dict[original_key]["plist"]))
- elif expanded in level_dict[key]["klist"]:
- # lowest level of an artificial group
- tree = gen_leaves(original_level_dict[expanded]["plist"])
- add_branch(level_list, tree, True, group, expanded,
len(original_level_dict[expanded]["plist"]))
-
- return level_list
-
-class SlotMap(Widget):
- def __init__(self, app, name):
- super(SlotMap, self).__init__(app, name)
-
- self.slots = SlotDataSet(app)
-
- self.slot_info = self.SlotInfo(app, "slot_info", self.slots)
- self.add_child(self.slot_info)
-
- self.slot_legend = self.SlotLegend(app, "slot_legend")
- self.add_child(self.slot_legend)
-
- self.slot_clip_size = 400
-
- def render_image_href(self, session):
- raise Exception("Not implemented")
-
- def render_job_index_param(self, session):
- return "xargs"
-
- def render_fullpageable(self, session):
- return "fullpageable"
-
- def render_slot_url(self, session):
- slot = Identifiable("XXX")
- try:
- return self.page.main.grid.slot.get_href(session, slot)
- except:
- pass
-
- def render_slot_clip_size(self, session):
- return self.slot_clip_size
-
- class SlotLegend(ItemSet):
- def __init__(self, app, name):
- super(SlotMap.SlotLegend, self).__init__(app, name)
-
- categories = SlotMapPage.get_unique_category_groups()
- for cat in sorted(categories):
- acat = SlotCategories(app, cat)
- self.add_child(acat)
-
- def do_get_items(self, session):
- return self.children
-
- def render_category(self, session, cat):
- return cat.name
-
- def render_category_items(self, session, cat):
- return cat.render(session)
-
- class SlotInfo(ItemSet):
- display_names = {"category": ("", "",
""),
- "JobId": ("Job ID", "",
""),
- "System": ("System", "",
""),
- "Machine": ("Machine", "",
""),
- "State": ("State", "",
""),
- "Activity": ("Activity", "",
""),
- "Name": ("Name", "",
""),
- "_id": ("Slot_ID", "slotInfo_id",
"hidden_row")}
-
- def __init__(self, app, name, slot_data):
- super(SlotMap.SlotInfo, self).__init__(app, name)
-
- self.index = IntegerParameter(app, "i")
- self.add_parameter(self.index)
-
- self.slot = Attribute(app, "slot")
- self.add_attribute(self.slot)
-
- self.slot_data = slot_data
-
- self.info_div_tmpl = WidgetTemplate(self, "bg_html")
-
- def do_render(self, session):
- index = self.index.get(session)
-
- if index is not None:
- #self.parent.slots.limit.set(session, 1)
- #self.parent.slots.offset.set(session, index)
-
- cursor = self.slot_data.execute(session)
- records = cursor_to_rows(cursor)
-
- if len(records):
- records = self.slot_data.sort_records(records)
-
- self.slot.set(session, records[index])
-
- writer = Writer()
- self.info_div_tmpl.render(writer, session)
- return writer.to_string()
- else:
- return super(SlotMap.SlotInfo, self).do_render(session)
-
- def do_get_items(self, session):
- slot = self.slot.get(session)
-
- return ((
- x == "category" and
(slot["category_group"],"","title_row") or
self.display_names[x],
- slot[x])
- for x in slot if x in self.display_names)
-
- def render_slot_info_url(self, session):
- return self.page.get_update_url(session, (self,))
-
- def render_slot_info_index(self, session):
- return self.index.path
-
- def render_item_value(self, session, item):
- return item[1]
-
- def render_item_title(self, session, item):
- return item[0][0]
-
- def render_item_id(self, session, item):
- return item[0][1] and "id='%s'" % item[0][1] or
""
-
- def render_item_row_class(self, session, item):
- return item[0][2] and "class='%s'" % item[0][2] or
""
-
-class SlotCategories(ItemSet):
- def do_get_items(self, session):
- cat_group = self.name
- categories = SlotMapPage.get_categories()
-
- d = dict()
- for x in categories:
- cat, group = categories[x]
- if group is cat_group:
- d[cat] = None
-
- return sorted(d.keys())
-
- def render_item_size(self, session, cat):
- return 20
-
- def render_item_title(self, session, cat):
- return cat
-
- def render_item_href(self, session, cat):
- params = list()
- params.append("category=%s" % cat)
-
- return "resource?name=slotvis-" + cat + ".png"
Modified: trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- trunk/cumin/python/cumin/grid/slot.strings 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/grid/slot.strings 2012-03-21 20:09:23 UTC (rev 5260)
@@ -39,389 +39,3 @@
</tbody>
</table>
-[SlotMap.javascript]
-addJavascript('resource?name=slotvis.js', 'head');
-
-[SlotMap.css]
-div#slot_hover {
- visibility: hidden;
- position: absolute;
- border: 1px solid pink;
- left: 0;
- top: 0;
- z-index: 10;
- width: 28px;
- height: 28px;
-/* -moz-border-radius: 50%; */
-}
-
-div#slot_zooming {
- margin: 3em auto;
- padding: 1em;
- z-index:200;
- text-align: center;
- background-color: white;
- overflow: hidden;
- opacity: 0.5;
- display: none;
- border: 1px solid #000;
-}
-
-div#slot_zooming p {
- margin: 0;
-/* padding: 140px 0 0 0; */
-}
-
-div#slot_controls {
- font-size: 0.8em;
- float: left;
- position: relative;
- left: 0px;
- top: 11px;
- z-index: 1;
-}
-
-div#slot_panleft {
- float: left;
- background: url(resource?name=pan-left.png) scroll no-repeat center;
- width: 18px;
- height: 0px;
-}
-
-div#slot_panright {
- float: left;
- background: url(resource?name=pan-right.png) scroll no-repeat center;
- width: 18px;
- height: 0px;
-}
-
-div#slot_panup {
- clear: both;
- background: url(resource?name=pan-up.png) scroll no-repeat center;
- height: 18px;
- width: 0px;
- position: relative;
- left: 18px;
- z-index:0;
-}
-
-div#slot_pandown {
- clear: left;
- background: url(resource?name=pan-down.png) scroll no-repeat center;
- height: 18px;
- width: 0px;
- position: relative;
- left: 18px;
-}
-
-div.slot_map {
- background-color: white;
- border: 1px solid #CCCCCC;
- float: left;
- height: 0px;
- overflow: hidden;
- position:relative;
- width: 0px;
-}
-
-div#slot_png {
- clip: rect(0 400px 400px 0);
- position:absolute;
- z-index: 0;
-}
-
-div#slot_glass {
- height: 0px;
- left: 0px;
- position:absolute;
- top: 0px;
- width: 0px;
- z-index: 100;
-}
-
-div#slot_visualization {
- position: relative;
- display: none;
- float: left;
-}
-
-div.zoom_node {
- background-color: white;
- position: absolute;
- left: -4px;
- top: -8px;
- color: #0066CC;
-}
-
-div.zoom_node_last {
- background-color: white;
- position: absolute;
- left: 2px;
- top: -8px;
- color: #0066CC;
-}
-
-div.zoom_first {
- width: 6px;
- height: 15px;
- border-bottom: 1px solid black;
- border-left: 1px solid black;
- float: left;
- position: relative;
- margin-left: 0.5em;
- cursor: pointer;
-}
-
-div.zoom_last {
- width: 6px;
- height: 15px;
- border-bottom: 1px solid black;
- border-right: 1px solid black;
- float: left;
- position: relative;
- margin-right: 0.5em;
- cursor: pointer;
-}
-
-div.zoom_middle_right {
- width: 6px;
- height: 15px;
- border-bottom: 1px solid black;
- border-left: 1px solid black;
- float: left;
- position: relative;
- cursor: pointer;
-}
-
-div.zoom_middle_left {
- width: 6px;
- height: 15px;
- border-bottom: 1px solid black;
- float: left;
- cursor: pointer;
-}
-
-div#zoom_text {
- margin-right: 1em;
- float:left;
-}
-
-div#zoom_levels {
- position:relative;
- float: left;
-}
-
-div#zoom_pos {
- background: url(slots.png?dot=Busy) scroll no-repeat center;
- width: 12px;
- height: 12px;
- position: absolute;
- top: 10px;
- z-index: 4;
-}
-
-[SlotMap.html]
-<div id="slot_visualization" class="fullpageable">
- <h2>Slots</h2>
- <div id="slot_controls">
- <div id="zoom_text">Zoom</div><div
id="zoom_levels"><div
id="zoom_pos"></div></div><div
style="clear:left;"><!-- --></div>
- </div>
-
- <div id="slot_panup" onclick="vis.pan_up()"></div>
- <div id="slot_panleft" onclick="vis.pan_left()"></div>
- <div class="slot_map" id="{id}">
- <div id="slot_glass"><!-- mouse target to prevent
selecting/dragging image --></div>
- <div id="slot_png">
- <img name="{id}" border="0"
onload="vis.img_loaded(this)" onerror="vis.img_error(this)"
alt="slots"/>
- </div>
- <div id="slot_hover"><!-- red border around current slot
--></div>
- <div id="slot_zooming"><p>Zooming...</p></div>
- </div>
- <div id="slot_panright" onclick="vis.pan_right()"><!--
--></div>
- <div id="slot_pandown" onclick="vis.pan_down()"></div>
- {slot_legend}
-</div>
-<div style="clear: left"><!-- --></div>
-{slot_info}
-<script type="text/javascript">
-//<![CDATA[
- var show_slot_url = "{slot_url}";
- var flashversion = swfobject.getFlashPlayerVersion();
- if (flashversion.major < 9) {
- var psm = document.getElementById('pngSlotMap');
- if (psm)
- psm.style.display = "block";
- var theImage = document.images['{id}'];
- if (theImage) {
- theImage.src = "{image_href}";
- }
- var slot_current_id = "{id}";
- var slot_job_index = "{job_index_param}";
- var slot_map_info = {size: 0, width: 0, height: 0, count: 0, rows: 0, cols: 0};
- var slot_clip_size = {slot_clip_size};
- var original_clip_size = slot_clip_size;
- $('slot_visualization').onfullpage = function (width) { vis.notify(true,
width); };
- $('slot_visualization').onrestore = function () { vis.notify(false,
original_clip_size); };
- var oGlass = document.getElementById("slot_glass");
- if (oGlass) {
- oGlass.onmousedown = vis.downGlass;
- oGlass.onmouseup = vis.upGlass;
- oGlass.onmousemove = vis.moveGlass;
- oGlass.onmouseout = vis.outGlass;
- oGlass.ondblclick = clicks.doMouseDown;
- oGlass.onclick = clicks.doMouseDown;
- oGlass.dragging = false;
- oGlass.down_pos = null;
- }
- }
-//]]>
-</script>
-
-[SlotInfo.css]
-div.slot_info {
- position: absolute;
- top: 0;
- left: 0.5em;
- visibility: hidden;
- z-index: 301;
-}
-
-div.slot_container {
- position: absolute;
- background-color: #ffffaa;
- background-image: url(resource?name=shade.png);
- background-position: bottom left;
- background-repeat: repeat-x;
- border: 1px solid #cccc99;
- padding: 1em;
- z-index: 101;
-}
-
-td.slot_info_title {
- font-weight: bold;
- height: 1.1em;
- text-align: right;
- padding-right: 1em;
-}
-td.slot_info_value {
- font-weight: normal;
- height: 1.1em;
-}
-
-tr.title_row td.slot_info_title, tr.title_row td.slot_info_value {
- padding-bottom: 0.5em;
- border-bottom: 1px solid black;
- font-style: italic;
- font-weight: bold;
-}
-
-html > body .outerpair1 {
- background: url(resource?name=upperrightfade.png) right top no-repeat;
-}
-
-html > body .outerpair2 {
- background: url(resource?name=lowerleftfade.png) left bottom no-repeat;
- padding-top: 8px;
- padding-left: 8px;
-}
-
-html > body .shadowbox {
- background: url(resource?name=shadow.png) bottom right;
-}
-
-html > body .innerbox {
- position: relative;
- left: -8px;
- top: -8px;
-}
-
-tr.hidden_row {
- display: none;
-}
-
-[SlotInfo.html]
-<div id="{id}"><!-- place holder to receive backgound update of slot
info on mouseover of a slot --></div>
-<script type="text/javascript">
- var slot_info_url = "{slot_info_url}";
- var slot_info_index = "{slot_info_index}";
- var slot_info_id = "{id}";
-</script>
-
-[SlotInfo.bg_html]
-<div class="outerpair1 slot_info" id="{id}">
- <div class="outerpair2">
- <div class="shadowbox">
- <div class="innerbox slot_container">
- <table cellspacing="0" cellpadding="0"
border="0">{items}</table>
- </div>
- </div>
- </div>
-</div>
-
-[SlotInfo.item_html]
-<tr {item_row_class}>
- <td class="slot_info_title">{item_title}</td>
- <td {item_id} class="slot_info_value">{item_value}</td>
-</tr>
-
-[SlotLegend.css]
-div.SlotLegend div.slot_container {
- background-image: url(resource?name=shade1.png);
-}
-div.SlotLegend {
- margin: 0 0 0 2em;
- width: 12em;
-}
-div.SlotLegend dl {
- margin: auto;
- padding: 0;
- position: relative;
- top: -0.5em;
-}
-div.SlotLegend dt {
- margin: 0;
- padding: 1em 0 0 0;
- font-weight: bold;
-}
-div.SlotLegend dd {
- margin: 0 0 0 1em;
- padding: 0;
- cursor: default;
-}
-div.SlotLegend dd:hover {
- color: #FF0000;
-}
-div.SlotLegend dd img {
- margin: 0;
- position: relative;
- top: 6px;
-}
-
-[SlotLegend.html]
-<div id="{id}" class="{class}">
- <div class="outerpair1" id="{id}">
- <div class="outerpair2">
- <div class="shadowbox">
- <div class="innerbox slot_container">
- <dl>
- {items}
- </dl>
- </div>
- </div>
- </div>
- </div>
-</div>
-
-[SlotLegend.item_html]
- <dt>{category}</dt>
- {category_items}
-
-[SlotCategories.html]
-{items}
-
-[SlotCategories.item_html]
-<dd onmouseover="vis_treemap_over('category',
'{item_title}')" onmouseout="vis_treemap_out('category',
'{item_title}')">
- <img src="{item_href}" width="{item_size}"
height="{item_size}" title="{item_title}"
alt="{item_title}"/>
-
- {item_title}
-</dd>
Modified: trunk/cumin/python/cumin/grid/slotvis.py
===================================================================
--- trunk/cumin/python/cumin/grid/slotvis.py 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/grid/slotvis.py 2012-03-21 20:09:23 UTC (rev 5260)
@@ -5,7 +5,6 @@
from wooly.util import StringCatalog
from wooly.widgets import RadioModeSet
-from slot import SlotMap, SlotMapPage
from cumin.parameters import RosemaryObjectParameter
from cumin.widgets import StateSwitch
from cumin.stat import FlashFullPage
@@ -51,89 +50,3 @@
def render_title(self, session):
return "Slot table"
-class Visualization(Widget):
- def __init__(self, app, name):
- super(Visualization, self).__init__(app, name)
-
- slot_map = PoolSlotMap(app, "slot_png")
- self.add_child(slot_map)
-
- slot_vis = PoolSlotFlashVis(app, "slot_map")
- self.add_child(slot_vis)
-
- def render_title(self, session):
- return "Slot visualization"
-
-class PoolSlotMap(SlotMap):
- def render_image_href(self, session):
- page = self.app.grid.pool_slots_page
- return Session(page).marshal()
-
-class PoolSlotFlashVis(PoolSlotMap):
- def __init__(self, app, name):
- super(PoolSlotFlashVis, self).__init__(app, name)
-
- self.group_by = self.GroupBySwitch(app, "group_by")
- self.add_child(self.group_by)
-
- self.fullpageable = True
-
- def render_slots_href(self, session):
- page = self.app.grid.pool_slots_page
- sess = Session(page)
- page.json.set(sess, "slots")
- page.group.set(sess, self.group_by.get(session))
-
- return sess.marshal()
-
- def render_image_href(self, session):
- page = self.app.grid.pool_slots_page
- return Session(page).marshal()
-
- def render_slot_chart_width(self, session):
- return 740
-
- def render_slot_chart_height(self, session):
- cursor = self.slots.execute(session)
- data = cursor.fetchall()
-
- slot_size = 51
- count = len(data)
- # individual slots are 51 px wide and tall
- width = self.render_slot_chart_width(session)
- cols = int(width / slot_size) * 4
- rows = int(math.ceil(count / cols))
-
- return min(max(rows * slot_size, width), 4095)
-
- def render_fullpageable(self, session):
- return self.fullpageable and "fullpageable" or ""
-
- def render_fullpage_href(self, session):
- page = self.app.grid.pool_slots_fullpage
- sess = Session(page)
- return sess.marshal()
-
- class GroupBySwitch(StateSwitch):
- def __init__(self, app, name):
- super(PoolSlotFlashVis.GroupBySwitch, self).__init__(app, name)
-
- self.add_state("Activity|State", "By activity/state")
- self.add_state("AccountingGroup", "By accounting group")
-
- def get_click(self, session, state):
- href = self.parent.render_slots_href(session)
- return "return slot_vis('%s', this, '%s',
'%s')" % \
- (state, self.parent.path, href)
-
-class PoolSlotFullPage(FlashFullPage):
- def __init__(self, app, name):
- super(PoolSlotFullPage, self).__init__(app, name)
-
- self.flash_chart = PoolSlotFlashVis(app, "chart")
- self.flash_chart.fullpageable = False
- self.replace_child(self.flash_chart)
-
- def render_content(self, session):
- return self.flash_chart.render(session)
-
Modified: trunk/cumin/python/cumin/grid/slotvis.strings
===================================================================
--- trunk/cumin/python/cumin/grid/slotvis.strings 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/grid/slotvis.strings 2012-03-21 20:09:23 UTC (rev 5260)
@@ -1,210 +1,3 @@
-[PoolSlotFlashVis.css]
-div#PoolSlotFlashVis {
- visibility: hidden;
-}
-
-div#PoolSlotFlashVis div.StatValueChart {
- width: auto;
-}
-
-div#PoolSlotFlashVis div.slot_legend {
- float: left;
-}
-div#PoolSlotFlashVis div.SlotLegend {
- margin: 4em 0 0 2em;
-}
-div#PoolSlotFlashVis div.slot_visualization {
- float: left;
-}
-
-div.SlotVisChart div.duration {
- margin: 1em 0 0.5em 1em;
- width:300px;
-}
-
-[PoolSlotFlashVis.html]
-<div id="PoolSlotFlashVis">
- <h2>Slots</h2>
- <div class="StatValueChart SlotVisChart {fullpageable}"
id="{id}">
- <h2>{title}</h2>
- <div class="slot_visualization">
- <div class="duration">{group_by}</div>
- <div id="{id}_chart"></div>
- </div>
- <div class="slot_legend">{slot_legend}</div><div
style="clear:both;"></div>
- </div>
-</div>
-<script type="text/javascript">
-//<![CDATA[
- // called every time the page is updated (currently 10 secs) and
- // when the user expands/collapses the flash chart
- function updatePoolSlotVis(id, loadType) {
- var chart = cumin.getFlashChart(id);
- if (typeof loadType == "undefined")
- loadType = "load";
- if ((chart != null) && (typeof chart.src != "undefined")) {
-
- var seq = incrementChartSequence(chart);
- if ((loadType == "reload") && (typeof chart.reload !=
"undefined")) {
- chart.reload(chart.src, seq);
- wooly.log("reloaded chart " + chart.src);
- }
- else if ((loadType == "load") && (typeof chart.load !=
"undefined")) {
- chart.load(chart.src, seq);
- wooly.log("loaded chart " + chart.src);
- }
- else {
- wooly.log("load not defined for " + id);
- }
- }
- }
-
- function vis_loaded(data) {
- if (data == "1") {
- $('PoolSlotFlashVis').style.visibility = "visible";
- }
- }
- function vis_ready(vis) {
- if (vis == "slots") {
- var chart = cumin.getFlashChart("{id}");
- chart.src = "{slots_href}";
- updatePoolSlotVis('{id}', "load");
- }
- }
-
- // we want to drill down a level in the slot vis
- function vis_expand(parent) {
- if (parent == null) {
- parent = "None";
- }
- var chart = cumin.getFlashChart("{id}");
- var src = chart.src;
- var branch = wooly.session.branch(src);
-
- // save the value of the current expanded
- var curExpand = "";
- if (typeof branch.expanded != "undefined") {
- curExpand = branch.expanded;
- }
-
- // expand to the level that was passed in
- branch['expanded'] = parent;
-
- // add the original expand to the end of the back list
- var backList = [];
- if (typeof branch.back != "undefined") {
- backList = branch.back.split("|");
- }
- if (curExpand != "")
- backList.push(curExpand);
- if (backList.length > 0)
- branch["back"] = backList.join("|");
- else if (typeof branch.back != "undefined")
- delete branch.back;
-
- chart.src = branch.marshal();
- updatePoolSlotVis("{id}", "load");
- var myFx = new Fx.Scroll(window).toTop();
- }
-
- // we want to go back 1 level in the slot vis
- function vis_back() {
- var chart = cumin.getFlashChart("{id}");
- var src = chart.src;
- var branch = wooly.session.branch(src);
-
- // get the current back list
- var backList = [];
- if (typeof branch.back != "undefined") {
- backList = branch.back.split("|");
- }
-
- // remove the last entry from the back list
- // and use it as the expand
- var expand = backList.pop();
- if (typeof expand != "undefined") {
- branch["expanded"] = expand;
- } else {
- // we are back to the top level
- if (typeof branch.expanded != "undefined")
- delete branch.expanded;
- }
-
- // save the new back list
- if (backList.length > 0) {
- branch["back"] = backList.join("|");
- } else {
- if (typeof branch.back != "undefined")
- delete branch.back;
- }
-
- chart.src = branch.marshal();
- updatePoolSlotVis("{id}", "load");
- }
-
- function vis_treemap_over(type, value) {
- var chart = cumin.getFlashChart("{id}");
- if (chart) {
- if (typeof chart.highlight != "undefined")
- chart.highlight(type, value);
- }
- }
- function vis_treemap_out(type, value) {
- var chart = cumin.getFlashChart("{id}");
- if (chart) {
- if (typeof chart.lowlight != "undefined")
- chart.lowlight(type, value);
- }
- }
- function slot_vis(state, a, id, href) {
- var li = a.parentNode;
- var ul = li.parentNode;
- var as = ul.getElementsByTagName('a');
- for (var i=0; i < as.length; i++) {
- as[i].className = (as[i] == a) ? "selected" : "";
- }
-
- var branch = wooly.session.branch(href);
- if (state == "None") {
- if ("group" in branch)
- delete branch.group;
- } else {
- branch.group = state;
- }
- var src = branch.marshal();
- var chart = cumin.getFlashChart(id);
- chart.src = src
- updatePoolSlotVis(id, "load");
- return false;
- }
-
- function init_flash() {
- var flashversion = swfobject.getFlashPlayerVersion();
- if (flashversion.major >= 9) {
- var fsm = document.getElementById('flashSlotMap');
- if (fsm)
- fsm.style.display = "block";
-
- var params = {menu: "false", scale: "noScale",
allowFullscreen: "true", allowScriptAccess: "always", bgcolor:
"#FFFFFF"};
- var branch = wooly.session.branch();
- if (branch.formBackground) {
- var i = 1;
- params.wmode = "opaque";
- }
-
- swfobject.embedSWF("resource?name=slots.swf",
"{id}_chart", "{slot_chart_width}", "{slot_chart_height}",
"9.0.0", "", {vis:"slots"}, params);
-
- wooly.addPageUpdateListener(function () { updatePoolSlotVis('{id}',
"reload"); });
- window.addEvent('domready',function () {
- cumin.setFullpageHandler('{id}', '{fullpage_href}');
- });
- }
- }
- window.addEvent('domready', init_flash);
-
-//]]>
-</script>
-
[SlotSelector.css]
div.SlotSelector div.ObjectSelectorFilters {
padding-bottom: 0.5em;
Modified: trunk/cumin/python/cumin/inventory/main.py
===================================================================
--- trunk/cumin/python/cumin/inventory/main.py 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/inventory/main.py 2012-03-21 20:09:23 UTC (rev 5260)
@@ -21,9 +21,6 @@
self.app.main_page.main.inventory = self.frame
self.app.main_page.main.add_tab(self.frame)
- self.app.system_slots_page = SystemSlotMapPage(self.app,
"systemslots.png")
- self.app.add_page(self.app.system_slots_page)
-
class InventoryFrame(CuminFrame):
def __init__(self, app, name):
super(InventoryFrame, self).__init__(app, name)
Modified: trunk/cumin/python/cumin/inventory/system.py
===================================================================
--- trunk/cumin/python/cumin/inventory/system.py 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/inventory/system.py 2012-03-21 20:09:23 UTC (rev 5260)
@@ -1,5 +1,4 @@
from operator import itemgetter
-from cumin.grid.slot import SlotMap, SlotMapPage
from cumin.objectselector import ObjectSelector, ObjectLinkColumn, ObjectTable,
ObjectTableColumn
from cumin.objectframe import ObjectFrame
@@ -123,10 +122,7 @@
chart = StatFlashChart(app, "loadavg", system)
chart.stats = ("loadAverage1Min",)
self.add_child(chart)
-
- slots = SystemSlotMap(app, "system_slot_map", system)
- self.add_child(slots)
-
+
self.main_tmpl = WidgetTemplate(self, "html")
def render_title(self, session):
@@ -223,67 +219,6 @@
def render_title(self, session):
return "Configuration"
-class SystemSlotMap(SlotMap):
- def __init__(self, app, name, system):
- super(SystemSlotMap, self).__init__(app, name)
-
- self.system = system
- self.slot_clip_size = 280
-
- def do_process(self, session):
- super(SystemSlotMap, self).do_process(session)
-
- system = self.system.get(session)
- self.slots.add_where_expr(session, "\"System\" =
'%s'", system.nodeName)
-
- def render_image_href(self, session):
- system = self.system.get(session)
-
- page = self.app.system_slots_page
- sess = Session(page)
-
- #page.sysimage.set(sess, system._id)
- page.sysimage.set(sess, system)
-
- return sess.marshal()
-
- def render_slot_url(self, session):
- return ""
-
-class SystemSlotFlashVis(SystemSlotMap):
- def render_slots_href(self, session):
- system = self.system.get(session)
-
- page = self.app.system_slots_page
- sess = Session(page)
-
- page.sysimage.set(sess, system)
- page.json.set(sess, "slots")
- page.group.set(sess, None)
-
- return sess.marshal()
-
- def render_slot_chart_width(self, session):
- return 250
-
- def render_slot_chart_height(self, session):
- return 250
-
-class SystemSlotMapPage(SlotMapPage):
- def __init__(self, app, name):
- self.cls = app.model.com_redhat_sesame.Sysimage
- self.sysimage = RosemaryObjectParameter(app, "id", self.cls)
-
- super(SystemSlotMapPage, self).__init__(app, name, self.sysimage,
"System")
-
- self.add_parameter(self.sysimage)
-
- def do_process(self, session):
- super(SystemSlotMapPage, self).do_process(session)
-
- sysimage = self.sysimage.get(session)
- self.slots.add_where_expr(session, "\"System\" =
'%s'", sysimage.nodeName)
-
class WallabyAndSqlAdapter(ObjectSqlAdapter):
def get_count(self, values):
Modified: trunk/cumin/python/cumin/inventory/system.strings
===================================================================
--- trunk/cumin/python/cumin/inventory/system.strings 2012-03-21 15:25:05 UTC (rev 5259)
+++ trunk/cumin/python/cumin/inventory/system.strings 2012-03-21 20:09:23 UTC (rev 5260)
@@ -42,76 +42,6 @@
[SystemServices.item_html]
<tr><th>{item_type}</th><td>{item_content}</td></tr>
-[SystemSlotFlashVis.css]
-div#SystemSlotFlashVis {
- visibility: hidden;
-}
-
-.system_slot_legend {
- float: right;
- width: 150px;
-}
-
-.system_slot_vis {
- float: left;
- width: 250px;
-}
-
-[SystemSlotFlashVis.html]
-<div id="SystemSlotFlashVis">
- <h2>Slots</h2>
- <div class="StatValueChart SlotVisChart {fullpageable}"
id="{id}">
- <h2>{title}</h2>
- <div class="slot_visualization">
- <div class="system_slot_vis"
id="{id}_chart"></div>
- <div class="slot_legend system_slot_legend">{slot_legend}</div>
- </div>
- <div style="clear:both;"></div>
- </div>
-</div>
-<script type="text/javascript">
-//<![CDATA[
- function updateSystemSlotVis(id, loadType) {
- var chart = cumin.getFlashChart(id);
- if ((chart != null) && (typeof chart.src != "undefined")) {
- var seq = incrementChartSequence(chart);
- if (typeof loadType != "undefined") {
- if (typeof chart.reload != "undefined")
- chart.reload(chart.src, seq);
- } else {
- if (typeof chart.load != "undefined")
- chart.load(chart.src, seq);
- else
- wooly.log("load not defined for " + id);
- }
- }
- }
- function vis_loaded(data) {
- if (data == "1") {
- $('SystemSlotFlashVis').style.visibility = "visible";
- }
- }
- function vis_ready(vis) {
- if (vis == "slots") {
- var chart = cumin.getFlashChart("{id}");
- chart.src = "{slots_href}";
- updateSystemSlotVis('{id}');
- }
- }
- var flashversion = swfobject.getFlashPlayerVersion();
- if (flashversion.major >= 9) {
- var fsm = document.getElementById('flashSlotMap');
- if (fsm)
- fsm.style.display = "block";
-
- var params = {menu: "false", scale: "noScale",
allowFullscreen: "true", allowScriptAccess: "always", bgcolor:
"#FFFFFF"};
- swfobject.embedSWF("resource?name=slots.swf", "{id}_chart",
"{slot_chart_width}", "{slot_chart_height}", "9.0.0",
"", {vis:"slots"}, params);
-
- wooly.addPageUpdateListener(function () { updateSystemSlotVis('{id}',
"reload"); });
- }
-//]]>
-</script>
-
[SystemTagSet.html]
<table id="{id}" class="{class} PropertySet TagPropertySet">
<thead>