Author: justi9
Date: 2007-11-29 15:45:22 -0500 (Thu, 29 Nov 2007)
New Revision: 1399
Modified:
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokergroup.strings
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/parameters.py
mgmt/mint/python/mint/__init__.py
mgmt/mint/python/mint/schema.sql
Log:
Checkpoint commit of conversion to new management-side model objects.
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/cumin/python/cumin/brokercluster.py 2007-11-29 20:45:22 UTC (rev 1399)
@@ -1,3 +1,4 @@
+from mint import *
from wooly import *
from wooly.widgets import *
from random import random
@@ -18,11 +19,10 @@
return branch.marshal()
def get_title(self, session, model):
- return "Broker Clusters %s" \
- % fmt_count(len(model.get_broker_clusters()))
+ return "Broker Clusters %s" % fmt_count(len(BrokerCluster.select()))
def get_items(self, session, model):
- return sorted_by(model.get_broker_clusters())
+ return list(BrokerCluster.select())
def render_item_link(self, session, cluster):
branch = session.branch()
@@ -30,13 +30,13 @@
return fmt_olink(branch, cluster)
def render_item_config(self, session, cluster):
- count = len(cluster.broker_items())
+ count = len(cluster.brokers)
return "%i broker%s" % (count, ess(count))
def render_item_status(self, session, cluster):
writer = Writer()
- for broker in sorted_by(cluster.broker_items()):
+ for broker in sorted_by(cluster.brokers):
writer.write(fmt_ostatus(broker))
return writer.to_string()
@@ -95,11 +95,10 @@
class ClusterBrokerTab(BrokerSetForm):
def get_title(self, session, cluster):
- return "Brokers" #XXX %s" %
fmt_count(len(cluster.broker_items()))
+ return "Brokers %s" % fmt_count(len(cluster.brokers))
def get_items(self, session, cluster):
- return sorted_by(self.app.model.sys.brokers, "id")
- #XXX return sorted_by(cluster.broker_items())
+ return cluster.brokers
class ClusterStatsTab(Widget):
def get_title(self, session, cluster):
@@ -113,11 +112,7 @@
self.add_child(self.cluster_name)
def process_cluster(self, session, cluster):
- cluster.lock()
- try:
- cluster.name = self.cluster_name.get(session)
- finally:
- cluster.unlock()
+ cluster.name = self.cluster_name.get(session)
branch = session.branch()
self.page().show_broker_cluster(branch, cluster).show_view(branch)
@@ -133,7 +128,7 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
- cluster = BrokerCluster(model)
+ cluster = BrokerCluster()
self.process_cluster(session, cluster)
class BrokerClusterEdit(BrokerClusterForm, Frame):
@@ -161,7 +156,7 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, cluster):
- cluster.remove()
+ cluster.destroySelf()
branch = session.branch()
self.page().show_view(branch)
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-29 20:45:22 UTC (rev 1399)
@@ -1,3 +1,4 @@
+from mint import *
from wooly import *
from wooly.widgets import *
@@ -2,3 +3,2 @@
from broker import BrokerSetForm
-from model import *
from widgets import *
@@ -12,7 +12,7 @@
class BrokerGroupSet(ItemSet):
def get_title(self, session, model):
- return "Broker Groups %s" % fmt_count(len(model.get_broker_groups()))
+ return "Broker Groups %s" % fmt_count(BrokerGroup.select().count())
def render_group_add_href(self, session, model):
branch = session.branch()
@@ -20,21 +20,21 @@
return branch.marshal()
def get_items(self, session, model):
- return sorted_by(model.get_broker_groups())
-
+ return list(BrokerGroup.select())
+
def render_item_link(self, session, group):
branch = session.branch()
self.page().show_broker_group(branch, group).show_view(branch)
return fmt_olink(branch, group)
def render_item_config(self, session, group):
- count = len(group.broker_items())
+ count = len(group.brokers)
return "%i broker%s" % (count, ess(count))
def render_item_status(self, session, group):
writer = Writer()
- for broker in sorted_by(group.broker_items()):
+ for broker in sorted_by(group.brokers):
writer.write(fmt_ostatus(broker))
return writer.to_string()
@@ -86,16 +86,12 @@
def render_name(self, session, group):
return group.name
- def render_category(self, session, group):
- return group.get_type().name
-
class GroupBrokerTab(BrokerSetForm):
def get_title(self, session, group):
- return "Brokers %s" % fmt_count(len(group.broker_items()))
+ return "Brokers %s" % fmt_count(len(group.brokers))
def get_items(self, session, group):
- return sorted_by(self.app.model.sys.brokers, "port")
- #XXX return sorted_by(group.broker_items())
+ return group.brokers
class BrokerGroupForm(CuminForm):
def __init__(self, app, name):
@@ -105,12 +101,7 @@
self.add_child(self.group_name)
def process_group(self, session, group):
- group.lock()
- try:
- group.name = self.group_name.get(session)
- group.set_type(self.app.model.get_broker_group_types()[0])
- finally:
- group.unlock()
+ group.name = self.group_name.get(session)
branch = session.branch()
self.page().show_broker_group(branch, group).show_view(branch)
@@ -126,7 +117,7 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
- group = BrokerGroup(model)
+ group = BrokerGroup()
self.process_group(session, group)
class BrokerGroupEdit(BrokerGroupForm, Frame):
@@ -164,7 +155,7 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
- group.remove()
+ group.destroySelf()
branch = session.branch()
self.page().show_view(branch)
Modified: mgmt/cumin/python/cumin/brokergroup.strings
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.strings 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/cumin/python/cumin/brokergroup.strings 2007-11-29 20:45:22 UTC (rev 1399)
@@ -35,7 +35,6 @@
<table class="props">
<tr><th>Name</th><td>{name}</td></tr>
- <tr><th>Category</th><td>{category}</td></tr>
<tr>
<th class="actions" colspan="2">
<h2>Act on This Group:</h2>
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2007-11-29 20:45:22 UTC (rev 1399)
@@ -16,7 +16,7 @@
return branch.marshal()
def get_items(self, session, model):
- return sorted_by(model.get_broker_profiles())
+ return list(BrokerProfile.select())
def render_item_link(self, session, profile):
branch = session.branch()
@@ -64,7 +64,7 @@
class ProfileConfigTab(ConfigPropertySet):
def get_items(self, session, profile):
- return sorted_by(profile.config_property_items())
+ return sorted_by(profile.properties)
def get_title(self, session, profile):
return "Configuration"
@@ -74,11 +74,10 @@
super(BrokerProfileView.ProfileBrokerTab, self).__init__(app, name)
def get_title(self, session, profile):
- return "Brokers %s" % fmt_count(len(profile.broker_items()))
+ return "Brokers %s" % fmt_count(len(profile.brokers))
def get_items(self, session, profile):
- return sorted_by(self.app.model.sys.brokers, "id")
- #XXX return sorted_by(profile.broker_items())
+ return profile.brokers
def render_item_config_href(self, session, broker):
branch = session.branch()
@@ -91,7 +90,8 @@
diffs = 0
- for prop in broker.get_broker_profile().config_property_items():
+ for prop in broker.profile.properties:
+ # XXX need to add assoc for this
for iprop in broker.config_property_items():
if iprop.name == prop.name:
if iprop.value != prop.value:
@@ -107,11 +107,7 @@
self.add_child(self.profile_name)
def process_profile(self, session, profile):
- profile.lock()
- try:
- profile.name = self.profile_name.get(session)
- finally:
- profile.unlock()
+ profile.name = self.profile_name.get(session)
branch = session.branch()
self.page().show_broker_profile(branch, profile).show_view(branch)
@@ -127,7 +123,7 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
- profile = BrokerProfile(model)
+ profile = BrokerProfile()
self.process_profile(session, profile)
class BrokerProfileEdit(BrokerProfileForm, Frame):
@@ -155,7 +151,7 @@
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, profile):
- profile.remove()
+ profile.destroySelf()
branch = session.branch()
self.page().show_view(branch)
Modified: mgmt/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/cumin/python/cumin/parameters.py 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/cumin/python/cumin/parameters.py 2007-11-29 20:45:22 UTC (rev 1399)
@@ -3,14 +3,14 @@
class BrokerClusterParameter(Parameter):
def do_unmarshal(self, string):
- return self.app.model.get_broker_cluster(int(string))
+ return BrokerCluster.get(int(string))
def do_marshal(self, cluster):
return str(cluster.id)
class BrokerGroupParameter(Parameter):
def do_unmarshal(self, string):
- return self.app.model.get_broker_group(int(string))
+ return BrokerGroup.get(int(string))
def do_marshal(self, group):
return str(group.id)
@@ -24,7 +24,7 @@
class BrokerProfileParameter(Parameter):
def do_unmarshal(self, string):
- return self.app.model.get_broker_profile(int(string))
+ return BrokerProfile.get(int(string))
def do_marshal(self, profile):
return str(profile.id)
@@ -57,16 +57,9 @@
def do_marshal(self, queue):
return str(queue.id)
-class RealmParameter(Parameter):
- def do_unmarshal(self, string):
- return self.app.model.get_realm(int(string))
-
- def do_marshal(self, queue):
- return str(realm.id)
-
class VirtualHostParameter(Parameter):
def do_unmarshal(self, string):
- return self.app.model.get_virtual_host(int(string))
+ return Vhost.get(int(string))
def do_marshal(self, vhost):
return str(vhost.id)
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/mint/python/mint/__init__.py 2007-11-29 20:45:22 UTC (rev 1399)
@@ -4,14 +4,14 @@
from mint import schema
-this_mod = __import__(__name__)
+this_module = __import__(__name__)
for item in dir(schema):
cls = getattr(schema, item)
try:
if issubclass(cls, SQLObject) and cls is not SQLObject:
- setattr(this_mod, item, cls)
+ setattr(this_module, item, cls)
except TypeError:
pass
@@ -24,23 +24,36 @@
class BrokerGroup(SQLObject):
name = StringCol(length=1000, default=None)
-BrokerGroup.sqlmeta.addJoin(MultipleJoin("Broker",
joinMethodName="brokers"))
+Broker.sqlmeta.addJoin(RelatedJoin("BrokerGroup",
joinMethodName="groups"))
+BrokerGroup.sqlmeta.addJoin(RelatedJoin("Broker",
joinMethodName="brokers"))
class BrokerCluster(SQLObject):
name = StringCol(length=1000, default=None)
+fk = ForeignKey("BrokerCluster", cascade="null",
+ default=None, name="brokerCluster")
+Broker.sqlmeta.addColumn(fk)
+setattr(Broker, "cluster", fk)
BrokerCluster.sqlmeta.addJoin(MultipleJoin("Broker",
joinMethodName="brokers"))
class BrokerProfile(SQLObject):
name = StringCol(length=1000, default=None)
+fk = ForeignKey("BrokerProfile", cascade="null",
+ default=None, name="brokerProfile")
+Broker.sqlmeta.addColumn(fk)
+setattr(Broker, "profile", fk)
BrokerProfile.sqlmeta.addJoin(MultipleJoin("Broker",
joinMethodName="brokers"))
class ConfigProperty(SQLObject):
name = StringCol(length=1000, default=None)
value = StringCol(length=1000, default=None)
type = StringCol(length=1, default="s")
+ profile = ForeignKey("BrokerProfile", cascade="null",
default=None)
+BrokerProfile.sqlmeta.addJoin(MultipleJoin("ConfigProperty",
+ joinMethodName="properties"))
+
class OriginalIdDict:
def __init__(self):
self.idMap = dict()
Modified: mgmt/mint/python/mint/schema.sql
===================================================================
--- mgmt/mint/python/mint/schema.sql 2007-11-29 19:18:28 UTC (rev 1398)
+++ mgmt/mint/python/mint/schema.sql 2007-11-29 20:45:22 UTC (rev 1399)
@@ -25,7 +25,8 @@
id SERIAL PRIMARY KEY,
name VARCHAR(1000),
value VARCHAR(1000),
- type VARCHAR(1)
+ type VARCHAR(1),
+ profile_id INT
);
CREATE TABLE binding (
@@ -71,8 +72,14 @@
initial_disk_page_size INT,
initial_pages_per_queue INT,
cluster_name VARCHAR(1000),
- version VARCHAR(1000)
+ version VARCHAR(1000),
+ broker_cluster_id INT,
+ broker_profile_id INT
);
+CREATE TABLE broker_broker_group (
+broker_id INT NOT NULL,
+broker_group_id INT NOT NULL
+);
CREATE TABLE broker_stats (
id SERIAL PRIMARY KEY,
@@ -369,6 +376,8 @@
ALTER TABLE broker_registration ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id)
REFERENCES broker (id) ON DELETE SET NULL;
+ALTER TABLE config_property ADD CONSTRAINT profile_id_exists FOREIGN KEY (profile_id)
REFERENCES broker_profile (id) ON DELETE SET NULL;
+
ALTER TABLE binding ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id)
REFERENCES binding_stats (id) ON DELETE SET NULL;
ALTER TABLE binding ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id)
REFERENCES binding_stats (id) ON DELETE SET NULL;
@@ -385,6 +394,10 @@
ALTER TABLE broker ADD CONSTRAINT system_id_exists FOREIGN KEY (system_id) REFERENCES
system (id) ON DELETE SET NULL;
+ALTER TABLE broker ADD CONSTRAINT broker_cluster_id_exists FOREIGN KEY
(broker_cluster_id) REFERENCES broker_cluster (id) ON DELETE SET NULL;
+
+ALTER TABLE broker ADD CONSTRAINT broker_profile_id_exists FOREIGN KEY
(broker_profile_id) REFERENCES broker_profile (id) ON DELETE SET NULL;
+
ALTER TABLE broker_stats ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id)
REFERENCES broker (id) ON DELETE SET NULL;
ALTER TABLE client ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id)
REFERENCES client_stats (id) ON DELETE SET NULL;