You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by mr...@apache.org on 2009/02/04 17:15:13 UTC

svn commit: r740799 - in /incubator/tashi/trunk: etc/TashiDefaults.cfg src/tashi/agents/dhcpdnsscheduler.py src/tashi/agents/examplepolicy.py src/tashi/client/client.py

Author: mryan3
Date: Wed Feb  4 17:15:12 2009
New Revision: 740799

URL: http://svn.apache.org/viewvc?rev=740799&view=rev
Log:
Modified version of Jim Cipar's patch.

Removes the need for the TASHI_CM_* environment variables in the clients.


Modified:
    incubator/tashi/trunk/etc/TashiDefaults.cfg
    incubator/tashi/trunk/src/tashi/agents/dhcpdnsscheduler.py
    incubator/tashi/trunk/src/tashi/agents/examplepolicy.py
    incubator/tashi/trunk/src/tashi/client/client.py

Modified: incubator/tashi/trunk/etc/TashiDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/etc/TashiDefaults.cfg?rev=740799&r1=740798&r2=740799&view=diff
==============================================================================
--- incubator/tashi/trunk/etc/TashiDefaults.cfg (original)
+++ incubator/tashi/trunk/etc/TashiDefaults.cfg Wed Feb  4 17:15:12 2009
@@ -57,6 +57,12 @@
 clusterManagerPort = 9882
 ;bind = 0.0.0.0 ; not supported (Thrift is missing support to specify what to bind to!)
 
+# Client configuration
+[Client]
+clusterManagerHost = localhost
+clusterManagerPort = 9882
+clusterManagerTimeout = 5.0
+
 [Qemu]
 qemuBin = /usr/local/bin/qemu-system-x86_64
 infoDir = /var/tmp/VmControlQemu/

Modified: incubator/tashi/trunk/src/tashi/agents/dhcpdnsscheduler.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/dhcpdnsscheduler.py?rev=740799&r1=740798&r2=740799&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/dhcpdnsscheduler.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/dhcpdnsscheduler.py Wed Feb  4 17:15:12 2009
@@ -207,10 +207,10 @@
 					os.write(1, "%s\n" % (str(e)))
 				time.sleep(2)
 
-def createClient():
-	host = os.getenv('TASHI_CM_HOST', 'localhost')
-	port = os.getenv('TASHI_CM_PORT', '9882')
-	timeout = float(os.getenv('TASHI_CM_TIMEOUT', '5000.0'))
+def createClient(config):
+	host = config.get('Client', 'clusterManagerHost')
+	port = config.get('Client', 'clusterManagerPort')
+	timeout = float(config.get('Client', 'clusterManagerTimeout')) * 1000.0
 	socket = TSocket(host, int(port))
 	socket.setTimeout(timeout)
 	transport = TBufferedTransport(socket)
@@ -221,7 +221,7 @@
 
 def main():
 	(config, configFiles) = getConfig(["Agent"])
-	(client, transport) = createClient()
+	(client, transport) = createClient(config)
 	agent = DhcpDnsScheduler(config, client, transport)
 	agent.start()
 

Modified: incubator/tashi/trunk/src/tashi/agents/examplepolicy.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/agents/examplepolicy.py?rev=740799&r1=740798&r2=740799&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/agents/examplepolicy.py (original)
+++ incubator/tashi/trunk/src/tashi/agents/examplepolicy.py Wed Feb  4 17:15:12 2009
@@ -26,6 +26,7 @@
 from thrift.protocol.TBinaryProtocol import TBinaryProtocol
 from thrift.transport.TTransport import TBufferedTransport
 from tashi.services import clustermanagerservice
+from tashi.util import getConfig
 
 class ExamplePolicy():
 	def __init__(self, client, transport):
@@ -76,10 +77,11 @@
 					print e
 				time.sleep(2)
 
-def createClient():
-	host = os.getenv('TASHI_CM_HOST', 'localhost')
-	port = os.getenv('TASHI_CM_PORT', '9882')
-	timeout = float(os.getenv('TASHI_CM_TIMEOUT', '5000.0'))
+def createClient(config):
+	host = config.get('Client', 'clusterManagerHost')
+	port = config.get('Client', 'clusterManagerPort')
+	timeout = float(config.get('Client', 'clusterManagerTimeout')) * 1000.0
+
 	socket = TSocket(host, int(port))
 	socket.setTimeout(timeout)
 	transport = TBufferedTransport(socket)
@@ -89,7 +91,8 @@
 	return (client, transport)
 
 def main():
-	(client, transport) = createClient()
+	(config, configFiles) = getConfig(["Agent"])
+	(client, transport) = createClient(config)
 	agent = ExamplePolicy(client, transport)
 	agent.start()
 

Modified: incubator/tashi/trunk/src/tashi/client/client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/client/client.py?rev=740799&r1=740798&r2=740799&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/client/client.py (original)
+++ incubator/tashi/trunk/src/tashi/client/client.py Wed Feb  4 17:15:12 2009
@@ -29,6 +29,8 @@
 from tashi.services import clustermanagerservice
 from tashi import vmStates
 
+from tashi.util import getConfig
+
 def makeHTMLTable(list):
 	(stdin_r, stdin_w) = os.pipe()
 	pipe = os.popen("tput cols")
@@ -152,9 +154,15 @@
 		for m in methods:
 			os.unlink(m)
 		sys.exit(0)
-	host = os.getenv('TASHI_CM_HOST', 'localhost')
-	port = os.getenv('TASHI_CM_PORT', '9882')
-	timeout = float(os.getenv('TASHI_CM_TIMEOUT', '5000.0'))
+
+	(config,configFiles) = getConfig(["Client"])
+	cfgHost = config.get('Client', 'clusterManagerHost')
+	cfgPort = config.get('Client', 'clusterManagerPort')
+	cfgTimeout = float(config.get('Client', 'clusterManagerTimeout'))
+	host = os.getenv('TASHI_CM_HOST', cfgHost)
+	port = os.getenv('TASHI_CM_PORT', cfgPort)
+	timeout = float(os.getenv('TASHI_CM_TIMEOUT', cfgTimeout)) * 1000.0
+
 	socket = TSocket(host, int(port))
 	socket.setTimeout(timeout)
 	transport = TBufferedTransport(socket)