incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rg...@apache.org
Subject svn commit: r1040687 - in /incubator/tashi/branches/zoni-dev/trunk/src/zoni/services: ./ __init__.py pcvciservice.py rpycservices.py zonimanager.py
Date Tue, 30 Nov 2010 18:39:20 GMT
Author: rgass
Date: Tue Nov 30 18:39:20 2010
New Revision: 1040687

URL: http://svn.apache.org/viewvc?rev=1040687&view=rev
Log:
Initial version of Physical cluster manager to virtual cluster manager service

Added:
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/__init__.py   (with props)
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py   (with props)
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/rpycservices.py   (with props)
    incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py   (with props)

Added: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/__init__.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/__init__.py?rev=1040687&view=auto
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/__init__.py (added)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/__init__.py Tue Nov 30 18:39:20
2010
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.    

Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/__init__.py
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py?rev=1040687&view=auto
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py (added)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py Tue Nov 30 18:39:20
2010
@@ -0,0 +1,97 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#  $Id$
+#
+
+import threading
+import logging
+
+from tashi.util import instantiateImplementation
+
+'''  Physical cluster manager/Virtual cluster manager service '''
+class pcmService(object):
+	'''  Phycical cluster manager service '''
+	def __init__(self, config, data):
+		self.config = config
+		self.data = data
+		self.log = logging.getLogger(__name__)
+		self.hardware = instantiateImplementation("zoni.hardware.systemmanagement.SystemManagement",
self.config, self.data)
+
+		print self.data.conn
+		#if self.data._isDb:
+			#threading.Thread(target=self.data.keepAlive).start()
+
+	#  auth domain and verify it can operate on domain
+	def __key2vcm(self, key):
+		return self.data.getDomainFromKey(key)
+
+	def releaseResource(self, key, nodeName):
+		vcm = self.__key2vcm(key)
+		'''  Check for keys later  and remove vcm '''
+		self.log.info("VCM_RELEASE_RESOURCE: VCM %s RESOURCE %s" % (vcm, nodeName))
+		self.data.releaseNode(nodeName)
+			
+	def requestResources(self, key, specs, quantity):
+		vcm = self.__key2vcm(key)
+		node = specs
+		'''  Check for keys later  '''
+		self.log.info("VCM_REQUEST_RESOURCE: VCM %s RESOURCE %s(%s)" % (vcm, specs, quantity))
+		# go to scheduler val = self.agent.requestResource(specs)
+		if val:
+			return 1
+		return 0
+
+	def getResources(self, key):
+		vcm = self.__key2vcm(key)
+		self.log.info("VCM_QUERY_ALL: VCM %s" % (vcm))
+		print self.data.getAvailableResources()
+		return self.data.getAvailableResources()
+
+	def getMyResources(self, key):
+		vcm = self.__key2vcm(key)
+		self.log.info("VCM_QUERY_OWN: VCM %s" % (vcm))
+		print self.data.getMyResources(key)
+		return self.data.getMyResources(key)
+
+	def powerOn(self, key, nodeName):
+		vcm = self.__key2vcm(key)
+		self.log.info("VCM_COMMAND_POWER_ON: VCM %s" % (vcm))
+		self.hardware.powerOn(nodeName)
+
+	def powerReset(self, key, nodeName):
+		vcm = self.__key2vcm(key)
+		self.log.info("VCM_COMMAND_POWER_RESET: VCM %s" % (vcm))
+		self.hardware.powerReset(nodeName)
+		
+
+	def powerOff(self, key, nodeName):
+		vcm = self.__key2vcm(key)
+		self.log.info("VCM_COMMAND_POWER_OFF: VCM %s" % (vcm))
+		self.hardware.powerOff(nodeName)
+
+	#def selectBootImage
+
+class vcmService(object):
+	def __init__(self, config):
+		self.config = config
+
+
+	def requestResource(self, nodeName):
+		pass
+		

Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/pcvciservice.py
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/rpycservices.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/rpycservices.py?rev=1040687&view=auto
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/rpycservices.py (added)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/rpycservices.py Tue Nov 30 18:39:20
2010
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#  $Id$
+#
+
+
+import rpyc
+
+pcmRPCs = ['releaseResource', 'requestResources', 'getResources', 'getMyResources', 'powerOn',
'powerReset', 'powerOff']
+hardwareRPCs = ['getPowerStatus']
+
+class client:
+	def __init__(self, host, port, username=None, password=None):
+		"""Client for ManagerService. If username and password are provided, rpyc.tls_connect will
be used to connect, else rpyc.connect will be used."""
+		self.host = host
+		self.port = int(port)
+		self.username = username
+		self.password = password
+		self.conn = self.createConn()
+
+	def createConn(self):
+		"""Creates a rpyc connection."""
+		if self.username != None and self.password != None:
+			return rpyc.tls_connect(host=self.host, port=self.port, username=self.username, password=self.password)
+		else:
+			return rpyc.connect(host=self.host, port=self.port)
+
+	def __getattr__(self, name):
+		"""Returns a function that makes the RPC call. No keyword arguments allowed when calling
this function."""
+		if self.conn.closed == True:
+			self.conn = self.createConn()
+		def connectWrap(*args):
+			print "INSIDE CLIENT  connectWroap__getattr__", self, name, "args ", args
+			try:
+				res = getattr(self.conn.root, name)(args)
+			except Exception, e:
+				self.conn.close()
+				raise e
+			if isinstance(res, Exception):
+				raise res
+			return res
+		return connectWrap
+
+class ManagerService(rpyc.Service):
+	"""Custom access to attributes of this object"""
+
+	def _rpyc_getattr(self, name):
+		if name in pcmRPCs:
+			res = getattr(self.service, name)	
+		elif name in hardwareRPCs:
+			res = getattr(self.hardware, name)	
+		else:
+			raise AttributeError("RPC '%s' not supported" % name)
+		return res

Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/rpycservices.py
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py?rev=1040687&view=auto
==============================================================================
--- incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py (added)
+++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py Tue Nov 30 18:39:20
2010
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.  
+#
+#  $Id$
+#
+
+import os
+import sys
+import threading
+import signal
+import logging.config
+import signal
+
+from tashi.util import instantiateImplementation, signalHandler
+
+from zoni.extra.util import loadConfigFile, getConfig, debugConsole
+from zoni.version import *
+from zoni.services.hardwareservice import HardwareService
+from zoni.services.pcvciservice import pcmService
+from zoni.services.rpycservices import ManagerService
+
+from rpyc.utils.server import ThreadedServer
+
+
+
+
+
+def startZoniManager(config):
+
+	data = instantiateImplementation("zoni.data.resourcequerysql.ResourceQuerySql", config)
+	service = instantiateImplementation("zoni.services.pcvciservice.pcmService", config, data)
+	#hardware = instantiateImplementation("zoni.services.hardwareservice.HardwareService", config,
data)
+
+	t = ThreadedServer(service=ManagerService, hostname='0.0.0.0', port=12345, auto_register=False
)
+	t.logger.quiet = True
+	t.service.service = service
+	#t.service.hardware = hardware
+	t.service._type = "pcmService"
+	debugConsole(globals())
+	t.start()
+
+def main():
+	(configs, configFiles) = getConfig()
+	logging.config.fileConfig(configFiles)
+	log = logging.getLogger(os.path.basename(__file__))
+
+	mesg = "Starting Zoni Manager"
+	log.info(mesg)
+	startZoniManager(configs)
+	
+
+
+
+
+
+if __name__ == "__main__":
+	main()

Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/services/zonimanager.py
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message