incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1352704 - in /incubator/tashi/trunk: doc/UPDATING src/tashi/clustermanager/data/sql.py
Date Thu, 21 Jun 2012 21:39:38 GMT
Author: stroucki
Date: Thu Jun 21 21:39:38 2012
New Revision: 1352704

URL: http://svn.apache.org/viewvc?rev=1352704&view=rev
Log:
UPDATING: make note on changed database schema
sql.py: support notes and reserved fields for Host, and groupName for Instance

Added:
    incubator/tashi/trunk/doc/UPDATING
Modified:
    incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py

Added: incubator/tashi/trunk/doc/UPDATING
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/doc/UPDATING?rev=1352704&view=auto
==============================================================================
--- incubator/tashi/trunk/doc/UPDATING (added)
+++ incubator/tashi/trunk/doc/UPDATING Thu Jun 21 21:39:38 2012
@@ -0,0 +1,14 @@
+This file will list important information for updaters. Protocol and database
+changes will also be found here.
+
+---++ Changes from release 201203-incubating:
+---+++ sql.py has more complete support for Tashi data fields
+Conversion procedure:
+   * If you do not use the SQL data store for the cluster manager, this change does not affect
you.
+   * Shut down the cluster manager
+   * ALTER your host table to match this:
+(id INTEGER PRIMARY KEY, name varchar(256) NOT NULL, up tinyint(1) DEFAULT 0, decayed tinyint(1)
DEFAULT 0, state int(11) DEFAULT 1, memory int(11), cores int(11), version varchar(256), notes
varchar(256), reserved varchar(1024))
+   * Please ALTER your instance table to match this:
+(id int(11) NOT NULL, vmId int(11), hostId int(11), decayed tinyint(1) NOT NULL, state int(11)
NOT NULL, userId int(11), name varchar(256), cores int(11) NOT NULL, memory int(11) NOT NULL,
disks varchar(1024) NOT NULL, nics varchar(1024) NOT NULL, hints varchar(1024) NOT NULL, groupName
varchar(256))
+   * Start the cluster manager
+

Modified: incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py?rev=1352704&r1=1352703&r2=1352704&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py (original)
+++ incubator/tashi/trunk/src/tashi/clustermanager/data/sql.py Thu Jun 21 21:39:38 2012
@@ -45,8 +45,8 @@ class SQL(DataInterface):
 		else:
 			raise TashiException, 'Unknown SQL database engine by URI: %s' % (self.uri)
 
-		self.instanceOrder = ['id', 'vmId', 'hostId', 'decayed', 'state', 'userId', 'name', 'cores',
'memory', 'disks', 'nics', 'hints']
-		self.hostOrder = ['id', 'name', 'up', 'decayed', 'state', 'memory', 'cores', 'version']
+		self.instanceOrder = ['id', 'vmId', 'hostId', 'decayed', 'state', 'userId', 'name', 'cores',
'memory', 'disks', 'nics', 'hints', 'groupName']
+		self.hostOrder = ['id', 'name', 'up', 'decayed', 'state', 'memory', 'cores', 'version',
'notes', 'reserved']
 		self.instanceLock = threading.Lock()
 		self.instanceIdLock = threading.Lock()
 		self.instanceLocks = {}
@@ -83,8 +83,8 @@ class SQL(DataInterface):
 		return instanceId
 	
 	def verifyStructure(self):
-		self.executeStatement("CREATE TABLE IF NOT EXISTS instances (id int(11) NOT NULL, vmId
int(11), hostId int(11), decayed tinyint(1) NOT NULL, state int(11) NOT NULL, userId int(11),
name varchar(256), cores int(11) NOT NULL, memory int(11) NOT NULL, disks varchar(1024) NOT
NULL, nics varchar(1024) NOT NULL, hints varchar(1024) NOT NULL)")
-		self.executeStatement("CREATE TABLE IF NOT EXISTS hosts (id INTEGER PRIMARY KEY, name varchar(256)
NOT NULL, up tinyint(1) DEFAULT 0, decayed tinyint(1) DEFAULT 0, state int(11) DEFAULT 1,
memory int(11), cores int(11), version varchar(256))")
+		self.executeStatement("CREATE TABLE IF NOT EXISTS instances (id int(11) NOT NULL, vmId
int(11), hostId int(11), decayed tinyint(1) NOT NULL, state int(11) NOT NULL, userId int(11),
name varchar(256), cores int(11) NOT NULL, memory int(11) NOT NULL, disks varchar(1024) NOT
NULL, nics varchar(1024) NOT NULL, hints varchar(1024) NOT NULL, groupName varchar(256))")
+		self.executeStatement("CREATE TABLE IF NOT EXISTS hosts (id INTEGER PRIMARY KEY, name varchar(256)
NOT NULL, up tinyint(1) DEFAULT 0, decayed tinyint(1) DEFAULT 0, state int(11) DEFAULT 1,
memory int(11), cores int(11), version varchar(256), notes varchar(256), reserved varchar(1024))")
 		self.executeStatement("CREATE TABLE IF NOT EXISTS networks (id int(11) NOT NULL, name varchar(256)
NOT NULL)")
 		self.executeStatement("CREATE TABLE IF NOT EXISTS users (id int(11) NOT NULL, name varchar(256)
NOT NULL, passwd varchar(256))")
 	
@@ -101,7 +101,7 @@ class SQL(DataInterface):
 		l = []
 		for e in range(0, len(self.instanceOrder)):
 			l.append(i.__dict__[self.instanceOrder[e]])
-		return map(lambda x: self.sanitizeForSql('"' + str(x) + '"'), l)
+		return map(lambda x: self.sanitizeForSql('"%s"' % str(x)), l)
 	
 	def makeListInstance(self, l):
 		i = Instance()
@@ -118,7 +118,7 @@ class SQL(DataInterface):
 		l = []
 		for e in range(0, len(self.hostOrder)):
 			l.append(h.__dict__[self.hostOrder[e]])
-		return map(lambda x: self.sanitizeForSql('"' + str(x) + '"'), l)
+		return map(lambda x: self.sanitizeForSql('"%s"' % str(x)), l)
 	
 	def makeListHost(self, l):
 		h = Host()
@@ -127,6 +127,10 @@ class SQL(DataInterface):
 		h.up = boolean(h.up)
 		h.decayed = boolean(h.decayed)
 		h.state = int(h.state)
+		if h.reserved is not None:
+			h.reserved = eval(h.reserved)
+		else:
+			h.reserved = []
 		return h
 	
 	def registerInstance(self, instance):
@@ -148,7 +152,8 @@ class SQL(DataInterface):
 			instance._lock.acquire()
 			self.instanceBusy[instance.id] = True
 			l = self.makeInstanceList(instance)
-			self.executeStatement("INSERT INTO instances VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s)" % tuple(l))
+			# XXXstroucki nicer?
+			self.executeStatement("INSERT INTO instances VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s)" % tuple(l))
 		finally:
 			self.instanceLock.release()
 		return instance
@@ -350,9 +355,10 @@ class SQL(DataInterface):
 				self.hostLock.release()
 				return r[0], True
 		_id = self.getNewId("hosts")
-		host = Host(d={'id': _id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory,
'cores': cores, 'version':version})
+		host = Host(d={'id': _id, 'up': 0, 'decayed': 0, 'state': 1, 'name': hostname, 'memory':memory,
'cores': cores, 'version':version, 'notes':'', 'reserved':[]})
 		l = self.makeHostList(host)
-		self.executeStatement("INSERT INTO hosts VALUES (%s, %s, %s, %s, %s, %s, %s, %s)" % tuple(l))
+		# XXXstroucki nicer?
+		self.executeStatement("INSERT INTO hosts VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
% tuple(l))
 		self.hostLock.release()
 		return id, False
 	



Mime
View raw message