Author: justi9
Date: 2008-03-31 12:35:32 -0400 (Mon, 31 Mar 2008)
New Revision: 1814
Modified:
mgmt/mint/python/mint/schema.py
mgmt/mint/python/mint/schemaparser.py
mgmt/mint/sql/schema.sql
Log:
Update the sql schema. Work around an object attr collision for managementagent.id
Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py 2008-03-31 16:04:54 UTC (rev 1813)
+++ mgmt/mint/python/mint/schema.py 2008-03-31 16:35:32 UTC (rev 1814)
@@ -14,6 +14,11 @@
statsCurr = ForeignKey('SystemStats', cascade='null', default=None)
statsPrev = ForeignKey('SystemStats', cascade='null', default=None)
sysId = StringCol(length=1000, default=None)
+ osName = StringCol(length=1000, default=None)
+ nodeName = StringCol(length=1000, default=None)
+ release = StringCol(length=1000, default=None)
+ version = StringCol(length=1000, default=None)
+ machine = StringCol(length=1000, default=None)
classInfos = dict() # brokerId => classInfo
@@ -24,11 +29,6 @@
idOriginal = BigIntCol(default=None)
recTime = TimestampCol(default=None)
system = ForeignKey('System', cascade='null', default=None)
- osName = StringCol(length=1000, default=None)
- nodeName = StringCol(length=1000, default=None)
- release = StringCol(length=1000, default=None)
- version = StringCol(length=1000, default=None)
- machine = StringCol(length=1000, default=None)
classInfos = dict() # brokerId => classInfo
@@ -111,6 +111,34 @@
Broker.sqlmeta.addJoin(SQLMultipleJoin('BrokerStats',
joinMethodName='stats'))
+class Agent(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ idOriginal = BigIntCol(default=None)
+ recTime = TimestampCol(default=None)
+ creationTime = TimestampCol(default=None)
+ deletionTime = TimestampCol(default=None)
+ managedBroker = StringCol(length=1000, default=None)
+ statsCurr = ForeignKey('AgentStats', cascade='null', default=None)
+ statsPrev = ForeignKey('AgentStats', cascade='null', default=None)
+ id_ = StringCol(default=None)
+
+ classInfos = dict() # brokerId => classInfo
+
+class AgentStats(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ idOriginal = BigIntCol(default=None)
+ recTime = TimestampCol(default=None)
+ agent = ForeignKey('Agent', cascade='null', default=None)
+
+ classInfos = dict() # brokerId => classInfo
+
+Agent.sqlmeta.addJoin(SQLMultipleJoin('AgentStats',
joinMethodName='stats'))
+
+
class Vhost(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -368,6 +396,7 @@
statsPrev = ForeignKey('LinkStats', cascade='null', default=None)
vhost = ForeignKey('Vhost', cascade='null', default=None)
address = StringCol(length=1000, default=None)
+ authIdentity = StringCol(length=1000, default=None)
classInfos = dict() # brokerId => classInfo
@@ -402,7 +431,6 @@
recTime = TimestampCol(default=None)
link = ForeignKey('Link', cascade='null', default=None)
closing = BoolCol(default=None)
- authIdentity = StringCol(length=1000, default=None)
framesFromPeer = BigIntCol(default=None)
framesToPeer = BigIntCol(default=None)
bytesFromPeer = BigIntCol(default=None)
@@ -673,6 +701,8 @@
schemaNameToClassMap['system'] = System
classToSchemaNameMap['Broker'] = 'broker'
schemaNameToClassMap['broker'] = Broker
+classToSchemaNameMap['Agent'] = 'agent'
+schemaNameToClassMap['agent'] = Agent
classToSchemaNameMap['Vhost'] = 'vhost'
schemaNameToClassMap['vhost'] = Vhost
classToSchemaNameMap['Queue'] = 'queue'
Modified: mgmt/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/mint/python/mint/schemaparser.py 2008-03-31 16:04:54 UTC (rev 1813)
+++ mgmt/mint/python/mint/schemaparser.py 2008-03-31 16:35:32 UTC (rev 1814)
@@ -22,6 +22,7 @@
# see xml/MintTypes.xml
self.dataTypesMap = dict()
self.dataTypesMap["objId"] = "ForeignKey"
+ self.dataTypesMap["uuid"] = "StringCol"
self.dataTypesMap["uint8"] = self.dataTypesMap["hilo8"] =
self.dataTypesMap["count8"] = self.dataTypesMap["mma8"] =
"SmallIntCol"
self.dataTypesMap["uint16"] = self.dataTypesMap["hilo16"] =
self.dataTypesMap["count16"] = self.dataTypesMap["mma16"] =
"SmallIntCol"
self.dataTypesMap["uint32"] = self.dataTypesMap["hilo32"] =
self.dataTypesMap["count32"] = self.dataTypesMap["mma32"] =
"IntCol"
@@ -39,6 +40,8 @@
params = "default=None"
else:
params += ", default=None"
+ if attribName == "id":
+ attribName = "id_"
self.pythonOutput += " %s = %s(%s)\n" % (attribName, attribType, params)
def generateTimestampAttrib(self, col):
Modified: mgmt/mint/sql/schema.sql
===================================================================
--- mgmt/mint/sql/schema.sql 2008-03-31 16:04:54 UTC (rev 1813)
+++ mgmt/mint/sql/schema.sql 2008-03-31 16:35:32 UTC (rev 1814)
@@ -50,6 +50,25 @@
version VARCHAR(1000) NOT NULL
);
+CREATE TABLE agent (
+ id SERIAL PRIMARY KEY,
+ id_original BIGINT,
+ rec_time TIMESTAMP,
+ creation_time TIMESTAMP,
+ deletion_time TIMESTAMP,
+ managed_broker VARCHAR(1000),
+ stats_curr_id INT,
+ stats_prev_id INT,
+ id_ TEXT
+);
+
+CREATE TABLE agent_stats (
+ id SERIAL PRIMARY KEY,
+ id_original BIGINT,
+ rec_time TIMESTAMP,
+ agent_id INT
+);
+
CREATE TABLE binding (
id SERIAL PRIMARY KEY,
id_original BIGINT,
@@ -245,7 +264,8 @@
stats_curr_id INT,
stats_prev_id INT,
vhost_id INT,
- address VARCHAR(1000)
+ address VARCHAR(1000),
+ auth_identity VARCHAR(1000)
);
CREATE TABLE link_stats (
@@ -254,7 +274,6 @@
rec_time TIMESTAMP,
link_id INT,
closing BOOL,
- auth_identity VARCHAR(1000),
frames_from_peer BIGINT,
frames_to_peer BIGINT,
bytes_from_peer BIGINT,
@@ -384,19 +403,19 @@
managed_broker VARCHAR(1000),
stats_curr_id INT,
stats_prev_id INT,
- sys_id VARCHAR(1000)
+ sys_id VARCHAR(1000),
+ os_name VARCHAR(1000),
+ node_name VARCHAR(1000),
+ release VARCHAR(1000),
+ version VARCHAR(1000),
+ machine VARCHAR(1000)
);
CREATE TABLE system_stats (
id SERIAL PRIMARY KEY,
id_original BIGINT,
rec_time TIMESTAMP,
- system_id INT,
- os_name VARCHAR(1000),
- node_name VARCHAR(1000),
- release VARCHAR(1000),
- version VARCHAR(1000),
- machine VARCHAR(1000)
+ system_id INT
);
CREATE TABLE vhost (
@@ -429,6 +448,12 @@
ALTER TABLE broker_registration ADD CONSTRAINT profile_id_exists FOREIGN KEY (profile_id)
REFERENCES broker_profile (id) ON DELETE SET NULL;
+ALTER TABLE agent ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id)
REFERENCES agent_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE agent ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id)
REFERENCES agent_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE agent_stats ADD CONSTRAINT agent_id_exists FOREIGN KEY (agent_id) REFERENCES
agent (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;