Author: nunofsantos
Date: 2008-11-18 16:17:03 -0500 (Tue, 18 Nov 2008)
New Revision: 2836
Modified:
mgmt/trunk/mint/python/mint/__init__.py
mgmt/trunk/mint/python/mint/schema.py
mgmt/trunk/mint/sql/schema.sql
Log:
expand one remaining 'finally' clause
Modified: mgmt/trunk/mint/python/mint/__init__.py
===================================================================
--- mgmt/trunk/mint/python/mint/__init__.py 2008-11-18 21:00:44 UTC (rev 2835)
+++ mgmt/trunk/mint/python/mint/__init__.py 2008-11-18 21:17:03 UTC (rev 2836)
@@ -345,22 +345,24 @@
if isinstance(id, qpid.qmfconsole.ObjectId):
first = id.first
second = id.second
+ dbId = None
if (first, second) in self.qmfIdToDbIdMap:
- return self.qmfIdToDbIdMap[(first, second)]
-
- try:
- conn = self.dbConn.getConnection()
- cursor = conn.cursor()
- cursor.execute("select id from %s where source_scope_id = %s and
source_object_id = %s" \
- % (self.dbStyle.pythonClassToDBTable(cls.__name__), first,
second));
- rec = cursor.fetchone()
- dbId = rec[0]
- self.qmfIdToDbIdMap[(first, second)] = dbId
- return dbId
- except Exception:
- raise ObjectNotFound()
- finally:
- conn.close()
+ dbId = self.qmfIdToDbIdMap[(first, second)]
+ else:
+ try:
+ try:
+ conn = self.dbConn.getConnection()
+ cursor = conn.cursor()
+ cursor.execute("select id from %s where source_scope_id = %s and
source_object_id = %s" \
+ % (self.dbStyle.pythonClassToDBTable(cls.__name__), first,
second));
+ rec = cursor.fetchone()
+ dbId = rec[0]
+ self.qmfIdToDbIdMap[(first, second)] = dbId
+ except Exception:
+ raise ObjectNotFound()
+ finally:
+ conn.close()
+ return dbId
else:
raise ObjectNotFound()
Modified: mgmt/trunk/mint/python/mint/schema.py
===================================================================
--- mgmt/trunk/mint/python/mint/schema.py 2008-11-18 21:00:44 UTC (rev 2835)
+++ mgmt/trunk/mint/python/mint/schema.py 2008-11-18 21:17:03 UTC (rev 2836)
@@ -1257,6 +1257,49 @@
+class SysImage(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ recTime = TimestampCol(default=None)
+ sourceScopeId = BigIntCol(default=None)
+ sourceObjectId = BigIntCol(default=None)
+ source_ids_unique = DatabaseIndex(sourceScopeId, sourceObjectId, unique=True)
+ qmfClassKey = BLOBCol(default=None)
+ creationTime = TimestampCol(default=None)
+ deletionTime = TimestampCol(default=None)
+ managedBroker = StringCol(length=1000, default=None)
+ statsCurr = ForeignKey('SysImageStats', cascade='null', default=None)
+ statsPrev = ForeignKey('SysImageStats', cascade='null', default=None)
+ classInfos = dict() # brokerId => classInfo
+ uuid = BLOBCol(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)
+ memTotal = IntCol(default=None)
+ swapTotal = IntCol(default=None)
+
+
+class SysImageStats(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ recTime = TimestampCol(default=None)
+ sysImage = ForeignKey('SysImage', cascade='null', default=None)
+ classInfos = dict() # brokerId => classInfo
+ memFree = IntCol(default=None)
+ swapFree = IntCol(default=None)
+ loadAverage1Min = FloatCol(default=None)
+ loadAverage5Min = FloatCol(default=None)
+ loadAverage10Min = FloatCol(default=None)
+ procTotal = IntCol(default=None)
+ procRunning = IntCol(default=None)
+
+
+
+
classToSchemaNameMap = dict()
schemaNameToClassMap = dict()
schemaReservedWordsMap = {"in": "inRsv", "In":
"InRsv",
@@ -1431,3 +1474,8 @@
Session.sqlmeta.addJoin(SQLMultipleJoin('SessionStats',
joinMethodName='stats'))
+classToSchemaNameMap['SysImage'] = 'SysImage'
+schemaNameToClassMap['SysImage'] = SysImage
+
+SysImage.sqlmeta.addJoin(SQLMultipleJoin('SysImageStats',
joinMethodName='stats'))
+
Modified: mgmt/trunk/mint/sql/schema.sql
===================================================================
--- mgmt/trunk/mint/sql/schema.sql 2008-11-18 21:00:44 UTC (rev 2835)
+++ mgmt/trunk/mint/sql/schema.sql 2008-11-18 21:17:03 UTC (rev 2836)
@@ -838,6 +838,41 @@
running_jobs INT
);
+CREATE TABLE sys_image (
+ id SERIAL PRIMARY KEY,
+ rec_time TIMESTAMP,
+ source_scope_id BIGINT,
+ source_object_id BIGINT,
+ qmf_class_key BYTEA,
+ creation_time TIMESTAMP,
+ deletion_time TIMESTAMP,
+ managed_broker VARCHAR(1000),
+ stats_curr_id INT,
+ stats_prev_id INT,
+ uuid BYTEA,
+ os_name VARCHAR(1000),
+ node_name VARCHAR(1000),
+ release VARCHAR(1000),
+ version VARCHAR(1000),
+ machine VARCHAR(1000),
+ mem_total INT,
+ swap_total INT
+);
+CREATE UNIQUE INDEX sys_image_source_ids_unique ON sys_image (source_scope_id,
source_object_id);
+
+CREATE TABLE sys_image_stats (
+ id SERIAL PRIMARY KEY,
+ rec_time TIMESTAMP,
+ sys_image_id INT,
+ mem_free INT,
+ swap_free INT,
+ load_average1_min FLOAT,
+ load_average5_min FLOAT,
+ load_average10_min FLOAT,
+ proc_total INT,
+ proc_running INT
+);
+
CREATE TABLE system (
id SERIAL PRIMARY KEY,
rec_time TIMESTAMP,
@@ -1061,6 +1096,12 @@
ALTER TABLE submitter_stats ADD CONSTRAINT submitter_id_exists FOREIGN KEY (submitter_id)
REFERENCES submitter (id) ON DELETE SET NULL;
+ALTER TABLE sys_image ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id)
REFERENCES sys_image_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE sys_image ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id)
REFERENCES sys_image_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE sys_image_stats ADD CONSTRAINT sys_image_id_exists FOREIGN KEY (sys_image_id)
REFERENCES sys_image (id) ON DELETE SET NULL;
+
ALTER TABLE system ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id)
REFERENCES system_stats (id) ON DELETE SET NULL;
ALTER TABLE system ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id)
REFERENCES system_stats (id) ON DELETE SET NULL;