incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r887368 - in /incubator/tashi: site/docs/ site/xdocs/ trunk/ trunk/etc/ trunk/src/tashi/aws/ trunk/src/tashi/aws/impl/ trunk/src/tashi/rpycservices/
Date Fri, 04 Dec 2009 21:38:27 GMT
Author: stroucki
Date: Fri Dec  4 21:38:24 2009
New Revision: 887368

URL: http://svn.apache.org/viewvc?rev=887368&view=rev
Log:
add support for aws key injection, security groups, images, and addresses
by Michael Wang <mswang@andrew.cmu.edu>


Modified:
    incubator/tashi/site/docs/documentation-single.html
    incubator/tashi/site/xdocs/documentation-single.xml
    incubator/tashi/trunk/Makefile
    incubator/tashi/trunk/etc/TashiDefaults.cfg
    incubator/tashi/trunk/src/tashi/aws/impl/address.py
    incubator/tashi/trunk/src/tashi/aws/impl/images.py
    incubator/tashi/trunk/src/tashi/aws/impl/instances.py
    incubator/tashi/trunk/src/tashi/aws/impl/keys.py
    incubator/tashi/trunk/src/tashi/aws/impl/monitor.py
    incubator/tashi/trunk/src/tashi/aws/impl/other.py
    incubator/tashi/trunk/src/tashi/aws/impl/security.py
    incubator/tashi/trunk/src/tashi/aws/impl/volume.py
    incubator/tashi/trunk/src/tashi/aws/util.py
    incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py

Modified: incubator/tashi/site/docs/documentation-single.html
URL: http://svn.apache.org/viewvc/incubator/tashi/site/docs/documentation-single.html?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/site/docs/documentation-single.html (original)
+++ incubator/tashi/site/docs/documentation-single.html Fri Dec  4 21:38:24 2009
@@ -99,25 +99,19 @@
                                     <h2>Setting up Tashi on a single test machine</h2>
                                                                         <p>There are
several dependencies you need to setup Tashi, they include:</p>
                                                                                         
       <ul>
-<li>Apache Thrift</li>
 <li>RPyC</li>
 <li>Xen or Qemu/KVM</li>
 <li>Python 2.4 or greater</li>
+<li>RPyC</li>
 <li>MySQL or sqlite if you wish to use them as the data backend</li>
 </ul>
-                                                                                        
       <p><i>Please note that due to changes made in Thrift recently, you may
need to get an older version of the software.  The version that Tashi was developed against
was from April 11th, 2008.</i></p>
-                                                                                        
       <p>Once These are setup and configured, check out the Tashi code:</p>
+                                                                                        
       <p>Once these are setup and configured, check out the Tashi code:</p>
                                                                                         
       <div class="lit"><pre>
 svn co http://svn.apache.org/repos/asf/incubator/tashi/trunk ./tashi
 </pre></div>
                                                                                         
       <p>Then, run make:</p>
                                                                                         
       <div class="lit"><pre>
 mryan3@mryan3-d4:~/scratch/tashi$ make
-Building tashi.services...
-Generating Python code for 'services.thrift'...
-Copying generated code to 'tashi.services' package...
-Generatign Python code for 'messagingthrift'...
-Copying generated code to 'tashi.messaging.messagingthrift' package...
 Generating Python code for 'layoutlocality.thrift'...
 Copying generated code to 'tashi.services' package...
 Symlinking in clustermanager...

Modified: incubator/tashi/site/xdocs/documentation-single.xml
URL: http://svn.apache.org/viewvc/incubator/tashi/site/xdocs/documentation-single.xml?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/site/xdocs/documentation-single.xml (original)
+++ incubator/tashi/site/xdocs/documentation-single.xml Fri Dec  4 21:38:24 2009
@@ -30,25 +30,19 @@
 
 <p>There are several dependencies you need to setup Tashi, they include:</p>
 <ul>
-<li>Apache Thrift</li>
 <li>RPyC</li>
 <li>Xen or Qemu/KVM</li>
 <li>Python 2.4 or greater</li>
+<li>RPyC</li>
 <li>MySQL or sqlite if you wish to use them as the data backend</li>
 </ul>
-<p><i>Please note that due to changes made in Thrift recently, you may need to
get an older version of the software.  The version that Tashi was developed against was from
April 11th, 2008.</i></p>
-<p>Once These are setup and configured, check out the Tashi code:</p>
+<p>Once these are setup and configured, check out the Tashi code:</p>
 <div class="lit"><pre>
 svn co http://svn.apache.org/repos/asf/incubator/tashi/trunk ./tashi
 </pre></div>
 <p>Then, run make:</p>
 <div class="lit"><pre>
 mryan3@mryan3-d4:~/scratch/tashi$ make
-Building tashi.services...
-Generating Python code for 'services.thrift'...
-Copying generated code to 'tashi.services' package...
-Generatign Python code for 'messagingthrift'...
-Copying generated code to 'tashi.messaging.messagingthrift' package...
 Generating Python code for 'layoutlocality.thrift'...
 Copying generated code to 'tashi.services' package...
 Symlinking in clustermanager...

Modified: incubator/tashi/trunk/Makefile
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/Makefile?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/Makefile (original)
+++ incubator/tashi/trunk/Makefile Fri Dec  4 21:38:24 2009
@@ -21,16 +21,16 @@
 .SILENT:
 
 # Explicit builds
-default: src/tashi/services bin src/utils/nmd
+default: bin src/utils/nmd
 	@echo Done
 
-all: src/tashi/services bin src/utils/nmd src/tags doc/html aws
+all: bin src/utils/nmd src/tags doc/html aws
 	@echo Done
 
 doc: rmdoc doc/html
 	@echo Done
 
-clean: rmnmd rmbin rmtags rmservices rmdoc rmaws
+clean: rmnmd rmbin rmtags rmdoc rmaws
 	if [ `find . -name "*.pyc" | wc -l` -gt 0 ]; then echo Removing python byte-code...; rm
`find . -name "*.pyc"`; fi
 	@echo Done
 
@@ -55,29 +55,20 @@
 src/utils/nmd: src/utils/Makefile src/utils/nmd.c
 	@echo Building nmd...
 	(cd src/utils; make)
-	ln -s src/utils/nmd/nmd ./bin/nmd
+	ln -s ../src/utils/nmd ./bin/nmd
 
 rmnmd:
 	if test -e src/utils/nmd; then echo Removing nmd...; (cd src/utils; make clean); rm -f bin/nmd;
fi
 
-src/tashi/services: src/tashi/thrift/services.thrift
-	@echo Building tashi.services...
-	(cd src/tashi/thrift; ./build.py)
-
-rmservices:
-	if test -d src/tashi/services; then echo Removing tashi.services...; rm -rf src/tashi/services;
fi
-	if test -d src/tashi/thrift/gen-py; then echo Removing tashi.thrift.gen-py...; rm -rf src/tashi/thrift/gen-py;
fi
-	if test -d src/tashi/messaging/messagingthrift; then echo Removing tashi.messaging.messagingthrift;
rm -rf src/tashi/messaging/messagingthrift; fi
-
 bin: bindir bin/clustermanager.py bin/nodemanager.py bin/tashi-client.py bin/primitive.py
 bindir:
 	if test ! -d bin; then mkdir bin; fi
 rmbin: rmclustermanager rmnodemanager rmtashi-client rmprimitive
 	if test -d bin; then rmdir bin; fi
-bin/getInstances: src/tashi/services
+bin/getInstances: 
 	if test ! -e bin/getInstances; then (echo "Generating client symlinks..."; cd bin; PYTHONPATH=../src
../src/tashi/client/client.py --makesyms); fi
 rmclients:
-	if test -e bin/getInstances; then (echo Removing client symlinks...; make src/tashi/services;
cd bin; PYTHONPATH=../src ../src/tashi/client/client.py --rmsyms; cd ..); fi
+	if test -e bin/getInstances; then (echo Removing client symlinks...; cd bin; PYTHONPATH=../src
../src/tashi/client/client.py --rmsyms; cd ..); fi
 bin/clustermanager.py: src/tashi/clustermanager/clustermanager.py
 	@echo Symlinking in clustermanager...
 	(cd bin; ln -s ../src/tashi/clustermanager/clustermanager.py .)
@@ -106,7 +97,7 @@
 
 doc/html:
 	@echo Generating HTML docs...
-	epydoc --html -o doc/html --include-log --name=tashi --graph=all --exclude=tashi.services
--exclude=tashi.messaging.messagingthrift ./src/tashi
+	epydoc --html -o doc/html --include-log --name=tashi --graph=all --exclude=tashi.messaging.messagingthrift
./src/tashi
 rmdoc:
 	if test -d doc/html; then echo Removing HTML docs...; rm -rf ./doc/html; fi
 

Modified: incubator/tashi/trunk/etc/TashiDefaults.cfg
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/etc/TashiDefaults.cfg?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/etc/TashiDefaults.cfg (original)
+++ incubator/tashi/trunk/etc/TashiDefaults.cfg Fri Dec  4 21:38:24 2009
@@ -216,3 +216,5 @@
 host = localhost
 port = 1717
 
+[AWS]
+awsfile = /var/tmp/aws.dat

Modified: incubator/tashi/trunk/src/tashi/aws/impl/address.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/address.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/address.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/address.py Fri Dec  4 21:38:24 2009
@@ -15,21 +15,70 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
+from tashi.rpycservices.rpyctypes import *
 
 def AllocateAddress():
-	raise NotImplementedError
-
-def ReleaseAddress():
-	raise NotImplementedError
-
-def DescribeAddresses():
-	raise NotImplementedError
-
-def AssociateAddress():
-	raise NotImplementedError
-
-def DisassociateAddress():
-	raise NotImplementedError
+	res = AllocateAddressResponseMsg()
+	res.requestId = genRequestId()
+	# To Do, reserve an available ip address.
+	# client.getAddress()
+	res.publicIp = '0.0.0.0'
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	awsdata.registerAddress(Address({'userId':userId,'publicIp':res.publicIp}))
+	return res
+
+def ReleaseAddress(publicIp):
+	res = ReleaseAddressResponseMsg()
+	res.requestId = genRequestId()
+	# To Do, release a reserved ip address.
+	# client.releaseAddress()
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.__dict__['return'] = True
+	try:
+		awsdata.removeAddress(userId, publicIp)
+	except:
+		res.__dict__['return'] = False
+	return res
+
+def DescribeAddresses(publicIpsSet={}):
+	res = DescribeAddressesResponseMsg()
+	res.requestId = genRequestId()
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.addressesSet = res.new_addressesSet()
+	res.addressesSet.item = []
+	for address in awsdata.getAddresses(userId):
+		addressItem = res.addressesSet.new_item()
+		addressItem.publicIp = address.publicIp
+		addressItem.instanceId = address.instanceId
+		res.addressesSet.item.append(addressItem)
+	return res
+
+def AssociateAddress(instanceId, publicIp):
+	res = AssociateAddressResponseMsg()
+	res.requestId = genRequestId()
+	res.__dict__['return'] = True
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	try:
+		awsdata.associateAddress(userId, instanceId, publicIp)
+		# To Do, associate an Address
+		#client.associateAddress()
+	except:
+		res.__dict__['return'] = False
+	return res
+
+def DisassociateAddress(publicIp):
+	res = DisassociateAddressResponseMsg()
+	res.requestId = genRequestId()
+	res.__dict__['return'] = True
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	try:
+		awsdata.dissociateAddress(userId, publicIp)
+		# To Do, associate an Address
+		#client.dissociateAddress()
+	except:
+		res.__dict__['return'] = False
+	return res
 
 functions = ['AllocateAddress', 'ReleaseAddress', 'DescribeAddresses', 'AssociateAddress',
'DisassociateAddress']

Modified: incubator/tashi/trunk/src/tashi/aws/impl/images.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/images.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/images.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/images.py Fri Dec  4 21:38:24 2009
@@ -17,16 +17,59 @@
 
 import md5
 import os.path
+import shutil
+import os
 from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
+from tashi.rpycservices.rpyctypes import *
+import tashi.aws.util
 
-def RegisterImage():
-	raise NotImplementedError
+def RegisterImage(imageLocation):
+	res = RegisterImageResponseMsg()
+	res.requestId = genRequestId()
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.imageId = "ami-%8.8s" % (md5.md5(imageLocation).hexdigest())
+	awsdata.registerImage(Image({'userId':userId,'imageId':res.imageId,'s3path':imageLocation}))
+	return res
+
+def DeregisterImage(imageId):
+	res = DeregisterImageResponseMsg()
+	res.requestId = genRequestId()
+	res.__dict__['return'] = True
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	try:
+		awsdata.removeImage(userId, imageId)
+	except:
+		res.__dict__['return'] = False
+	return res
 
-def DeregisterImage():
-	raise NotImplementedError
+def _DescribeImages(ownersSet = {}, executableBySet = {}, imagesSet = {}):
+	# _DescribeImages is meant to be used when S3 is implemented.
+	res = DescribeImagesResponseMsg()
+	res.requestId = genRequestId()
+	res.imagesSet = res.new_imagesSet()
+	res.imagesSet.item = []
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	for img in awsdata.getImages(userId):
+		image = res.imagesSet.new_item()
+		image.imageId = img.imageId
+		image.imageLocation = img.s3path
+		image.imageState = 'available'
+		image.imageOwnerId = img.userId
+		image.isPublic = img.isPublic
+		image.productCodes = image.new_productCodes()
+		productCodeItem = image.productCodes.new_item()
+		productCodeItem.productCode = img.productCode
+		image.productCodes.item = [productCodeItem]
+		#image.architecture = None <string>
+		#image.imageType = None <string>
+		#image.kernelId = None <string>
+		#image.ramdiskId = None <string>
+		#image.platform = None <string>
+		res.imagesSet.item.append(image)
+	return res
 
-def DescribeImages(ownersSet={}, executableBySet={}, imagesSet={}):
+def DescribeImages(ownersSet = {}, executableBySet = {}, imagesSet = {}):
 	IMGDIR="/mnt/merkabah/tashi/images/"
 	res = DescribeImagesResponseMsg()
 	res.requestId = genRequestId()
@@ -57,13 +100,78 @@
 			res.imagesSet.item.append(image)
 	return res
 
-def ModifyImageAttribute():
-	raise NotImplementedError
+def ModifyImageAttribute(imageId, launchPermission=None, productCodes=None):
+	# Account ids should probably be entered with leading 0's so that 12 character spaces are
used.
+	# For some reason, only the 'all' group is allowed.
+	res = ModifyImageAttributeResponseMsg()
+	res.requestId = genRequestId()
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.__dict__['return'] = True
+	if launchPermission:
+		try:
+			if 'add' in launchPermission:
+				if 'group' in launchPermission['add']['item']:
+					targetUserId = launchPermission['add']['item']['group']
+				elif 'userId' in launchPermission['add']['item']:
+					targetUserId = launchPermission['add']['item']['userId']
+				awsdata.addPermission(userId, targetUserId, imageId)
+			if 'remove' in launchPermission:
+				if 'group' in launchPermission['remove']['item']:
+					targetUserId = launchPermission['remove']['item']['group']
+				elif 'userId' in launchPermission['remove']['item']:
+					targetUserId = launchPermission['remove']['item']['userId']
+				awsdata.removePermission(userId, targetUserId, imageId)
+		except:
+			res.__dict__['return'] = False
+	if productCodes:
+		try:
+			awsdata.setProductCode(userId, productCodes['item']['productCode'], imageId)
+		except:
+			res.__dict__['return'] = False
+	return res
 
-def ResetImageAttribute():
-	raise NotImplementedError
+def ResetImageAttribute(launchPermission, imageId):
+	# res.__dict__['return'] is used to specify if there is an error.
+	res = ResetImageAttributeResponseMsg()
+	res.requestId = genRequestId()
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.__dict__['return'] = True
+	try:
+		awsdata.resetImage(userId, imageId)
+	except:
+		res.__dict__['return'] = False
+	return res
 
-def DescribeImageAttribute():
-	raise NotImplementedError
+def DescribeImageAttribute(imageId, launchPermission=True, productCodes=True, kernel=True,
ramdisk=True, blockDeviceMapping=True, platform=True):
+	res = DescribeImageAttributeResponseMsg()
+	res.requestId = genRequestId()
+	res.imageId = imageId
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	images = awsdata.getImages(userId)
+	res.launchPermission = res.new_launchPermission()
+	res.launchPermission.item = []
+	index = images.index(Image({'userId':userId,'imageId':imageId}))
+	image = images[index]
+	if not launchPermission:
+		if image.isPublic:
+			launchPermissionItem = res.launchPermission.new_item()
+			launchPermissionItem.group = 'all'
+			res.launchPermission.item.append(launchPermissionItem)
+		else:
+			for explicitUserId in image.explicitUserIds:
+				launchPermissionItem = res.launchPermission.new_item()
+				launchPermissionItem.userId = explicitUserId
+				res.launchPermission.item.append(launchPermissionItem)
+	elif not productCodes:
+		pass
+	elif not kernel:
+		pass
+	elif not ramdisk:
+		pass
+	elif not blockDeviceMapping:
+		pass
+	elif not platform:
+		pass
+	return res
 
 functions = ['RegisterImage', 'DeregisterImage', 'DescribeImages', 'ModifyImageAttribute',
'ResetImageAttribute', 'DescribeImageAttribute']

Modified: incubator/tashi/trunk/src/tashi/aws/impl/instances.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/instances.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/instances.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/instances.py Fri Dec  4 21:38:24 2009
@@ -23,6 +23,7 @@
 from tashi.rpycservices.rpyctypes import *
 from tashi.aws.util import *
 import tashi.aws.util
+import tashi
 
 def getImages():
 	IMGDIR="/mnt/merkabah/tashi/images/"
@@ -97,8 +98,6 @@
 	inst.hints = {}
 	oldInst = inst
 	inst = client.createVm(oldInst)
-	res = RunInstancesResponseMsg()
-	res.requestId = genRequestId()
 	res.reservationId = 'r-12345678'
 	res.ownerId = 'UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM'
 	res.groupSet = res.new_groupSet()
@@ -157,6 +156,8 @@
 		if (userName == tashi.aws.util.authorizedUser):
 			instanceItem = makeTashiInstanceEC2Instance(inst)
 			item.instancesSet.item.append(instanceItem)
+	# For some reason, if item.instancesSet is empty,
+	# "Server: Processing Failure is printed out on the command line.
 	item.requesterId = '1234'
 	res.reservationSet.item = [item]
 	return res

Modified: incubator/tashi/trunk/src/tashi/aws/impl/keys.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/keys.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/keys.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/keys.py Fri Dec  4 21:38:24 2009
@@ -17,21 +17,63 @@
 
 from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
+from tashi.rpycservices.rpyctypes import *
+import os
+import re
 
-def CreateKeyPair():
-	raise NotImplementedError
+def CreateKeyPair(keyName):
+	res = CreateKeyPairResponseMsg()
+	res.requestId = genRequestId()
+	res.keyName = keyName
+	privkeyfile = awsdir + 'id_rsa.tmp'
+	pubkeyfile = awsdir + 'id_rsa.tmp.pub'
+	fingerprintfile = awsdir + 'fingerprint.tmp'
+	try:
+		os.remove(privkeyfile)
+	except:
+		pass
+	os.system('ssh-keygen -t rsa -b 2048 -f ' + privkeyfile + ' -P "" > ' + fingerprintfile)
+	infile = open(privkeyfile, 'r')
+	privkey = infile.read()
+	infile.close()
+	infile = open(pubkeyfile, 'r')
+	pubkey = infile.read()
+	infile.close()
+	infile = open(fingerprintfile, 'r')
+	fingerprint = infile.read()
+	infile.close()
+	fingerprint = re.findall('The key fingerprint is:\s+(\S+)\s+', fingerprint)[0]
+	res.keyFingerprint = fingerprint
+	res.keyMaterial = privkey
+	os.remove(privkeyfile)
+	os.remove(pubkeyfile)
+	os.remove(fingerprintfile)
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	awsdata.registerKey(Key({'userId':userId,'keyName':keyName,'fingerprint':fingerprint,'pubkey':pubkey,'privkey':privkey}))
+	return res
 
-def DescribeKeyPairs():
+def DescribeKeyPairs(keySet={}):
 	res = DescribeKeyPairsResponseMsg()
 	res.requestId = genRequestId()
 	res.keySet = res.new_keySet()
-	item = res.keySet.new_item()
-	item.keyName = "fake"
-	item.keyFingerprint = "missing"
-	res.keySet.item = [item]
+	res.keySet.item = []
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	for key in awsdata.getKeys(userId):
+		item = res.keySet.new_item()
+		item.keyName = key.keyName
+		item.keyFingerprint = key.fingerprint
+		res.keySet.item.append(item)
 	return res
 
-def DeleteKeyPair():
-	raise NotImplementedError
+def DeleteKeyPair(keyName):
+	res = DeleteKeyPairResponseMsg()
+	res.requestId = genRequestId()
+	res.__dict__['return'] = True
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	try:
+		awsdata.removeKey(userId, keyName)
+	except:
+		res.__dict__['return'] = False
+	return res
 
 functions = ['CreateKeyPair', 'DescribeKeyPairs', 'DeleteKeyPair']

Modified: incubator/tashi/trunk/src/tashi/aws/impl/monitor.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/monitor.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/monitor.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/monitor.py Fri Dec  4 21:38:24 2009
@@ -15,10 +15,20 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
 
-def MonitorInstances():
-	raise NotImplementedError
+def MonitorInstances(instancesSet):
+	# Not sure whether the returned information is correct.
+	res = MonitorInstancesResponseMsg()
+	res.requestId = genRequestId()
+	res.instancesSet = res.new_instancesSet()
+	item = res.instancesSet.new_item()
+	item.instanceId = instancesSet['item']['instanceId']
+	item.monitoring = item.new_monitoring()
+	item.monitoring.state = 'Normal'
+	res.instancesSet.item = [item]
+	return res
 
 def UnmonitorInstances():
 	raise NotImplementedError

Modified: incubator/tashi/trunk/src/tashi/aws/impl/other.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/other.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/other.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/other.py Fri Dec  4 21:38:24 2009
@@ -15,9 +15,19 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
 
-def ConfirmProductInstance():
-	raise NotImplementedError
+def ConfirmProductInstance(productCode, instanceId):
+	res = ConfirmProductInstanceResponseMsg()
+	res.requestId = genRequestId()
+	res.__dict__['return'] = True
+	for i in client.getInstances():
+		if i.id == int(instanceId):
+			res.ownerId = i.userId
+			break
+	else:
+		res.__dict__['return'] = False
+	return res
 
 functions = ['ConfirmProductInstance']

Modified: incubator/tashi/trunk/src/tashi/aws/impl/security.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/security.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/security.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/security.py Fri Dec  4 21:38:24 2009
@@ -17,24 +17,113 @@
 
 from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
+from tashi.rpycservices.rpyctypes import *
 
-def CreateSecurityGroup():
-	raise NotImplementedError
+def CreateSecurityGroup(groupName, groupDescription):
+	res = CreateSecurityGroupResponseMsg()
+	res.requestId = genRequestId()
+	res.__dict__['return'] = True
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	try:
+		awsdata.registerGroup(Group({'userId':userId,'groupName':groupName,'groupDescription':groupDescription}))
+	except Exception, e:
+		res.__dict__['return'] = False
+	return res
 
-def DeleteSecurityGroup():
-	raise NotImplementedError
+def DeleteSecurityGroup(groupName):
+	res = DeleteSecurityGroupResponseMsg()
+	res.requestId = genRequestId()
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.__dict__['return'] = True
+	try:
+		awsdata.removeGroup(userId, groupName)
+	except:
+		res.__dict__['return'] = False
+	return res
 
-def DescribeSecurityGroups():
+def DescribeSecurityGroups(securityGroupSet = None):
 	res = DescribeSecurityGroupsResponseMsg()
 	res.requestId = genRequestId()
 	res.securityGroupInfo = res.new_securityGroupInfo()
 	res.securityGroupInfo.item = []
+	userId = userNameToId(tashi.aws.util.authorizedUser)
+	for group in awsdata.getGroups(userId):
+		item = res.securityGroupInfo.new_item()
+		item.ownerId = group.userId
+		item.groupName = group.groupName
+		item.groupDescription = group.groupDescription
+		item.ipPermissions = item.new_ipPermissions()
+		item.ipPermissions.item = []
+		for ipPermission in group.ipPermissions:
+			ipPermissionsItem = item.ipPermissions.new_item()
+			ipPermissionsItem.ipProtocol = ipPermission.ipProtocol
+			ipPermissionsItem.fromPort = int(ipPermission.fromPort)
+			ipPermissionsItem.toPort = int(ipPermission.toPort)
+			ipPermissionsItem.groups = ipPermissionsItem.new_groups()
+			ipPermissionsItem.groups.item = []
+			for groupPermission in ipPermission.groupPermissions:
+				groupPermissionsItem = ipPermissionsItem.groups.new_item()
+				groupPermissionsItem.groupName = groupPermission.groupName
+				groupPermissionsItem.userId = groupPermission.targetUserId
+				ipPermissionsItem.groups.item.append(groupPermissionsItem)
+			ipPermissionsItem.ipRanges = ipPermissionsItem.new_ipRanges()
+			ipPermissionsItem.ipRanges.item = []
+			ipRangesItem = ipPermissionsItem.ipRanges.new_item()
+			ipRangesItem.cidrIp = ipPermission.cidrIp
+			if ipRangesItem.cidrIp != None:
+				ipPermissionsItem.ipRanges.item.append(ipRangesItem)
+			item.ipPermissions.item.append(ipPermissionsItem)
+		res.securityGroupInfo.item.append(item)
 	return res
 
-def AuthorizeSecurityGroupIngress():
-	raise NotImplementedError
+def AuthorizeSecurityGroupIngress(userId, groupName, ipPermissions):
+	res = AuthorizeSecurityGroupIngressResponseMsg()
+	res.requestId = genRequestId()
+	_userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.__dict__['return'] = True
+	if userId != None and userId != _userId:
+		raise TashiException({'msg':'You do not own that security group'})
+	ipProtocol = ipPermissions['item']['ipProtocol']
+	toPort = ipPermissions['item']['toPort']
+	fromPort = ipPermissions['item']['fromPort']
+	cidrIp = None
+	if ipPermissions['item']['ipRanges']:
+		cidrIp = ipPermissions['item']['ipRanges']['item']['cidrIp']
+	groupPermissions = []
+	if ipPermissions['item']['groups']:
+		# Only one userId/groupName seems to get through even if you put multiple userId/groupNames
on the command line.
+		groupPermissions.append(GroupPermission({'targetUserId':ipPermissions['item']['groups']['item']['userId'],'groupName':ipPermissions['item']['groups']['item']['groupName']}))
+	try:
+		awsdata.addIpPermission(IpPermission({'userId':_userId,'groupName':groupName,'ipProtocol':ipProtocol,'toPort':toPort,'fromPort':fromPort,'cidrIp':cidrIp,'groupPermissions':groupPermissions}))
+		#To Do: change permission.
+		#client.changePermission()
+	except:
+		res.__dict__['return'] = False
+	return res
 
-def RevokeSecurityGroupIngress():
-	raise NotImplementedError
+def RevokeSecurityGroupIngress(userId, groupName, ipPermissions):
+	res = RevokeSecurityGroupIngressResponseMsg()
+	res.requestId = genRequestId()
+	_userId = userNameToId(tashi.aws.util.authorizedUser)
+	res.__dict__['return'] = True
+	if userId != None and userId != _userId:
+		raise TashiException({'msg':'You do not own that security group'})
+	ipProtocol = ipPermissions['item']['ipProtocol']
+	toPort = ipPermissions['item']['toPort']
+	fromPort = ipPermissions['item']['fromPort']
+	cidrIp = None
+	if ipPermissions['item']['ipRanges']:
+		cidrIp = ipPermissions['item']['ipRanges']['item']['cidrIp']
+	groupPermissions = []
+	if ipPermissions['item']['groups']:
+		# Only one userId/groupName seems to get through even if you put multiple userId/groupNames
on the command line.
+		groupPermissions.append(GroupPermission({'targetUserId':ipPermissions['item']['groups']['item']['userId'],'groupName':ipPermissions['item']['groups']['item']['groupName']}))
+	try:
+		awsdata.removeIpPermission(IpPermission({'userId':_userId,'groupName':groupName,'ipProtocol':ipProtocol,'toPort':toPort,'fromPort':fromPort,'cidrIp':cidrIp,'groupPermissions':groupPermissions}))
+		#To Do: change permission.
+		#client.changePermission()
+	except:
+		res.__dict__['return'] = False
+	return res
 
 functions = ['CreateSecurityGroup', 'DeleteSecurityGroup', 'DescribeSecurityGroups', 'AuthorizeSecurityGroupIngress',
'RevokeSecurityGroupIngress']

Modified: incubator/tashi/trunk/src/tashi/aws/impl/volume.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/impl/volume.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/impl/volume.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/impl/volume.py Fri Dec  4 21:38:24 2009
@@ -15,7 +15,9 @@
 # specific language governing permissions and limitations
 # under the License.    
 
+from tashi.aws.wsdl.AmazonEC2_services_server import *
 from tashi.aws.util import *
+from tashi.rpycservices.rpyctypes import *
 
 def CreateVolume():
 	raise NotImplementedError

Modified: incubator/tashi/trunk/src/tashi/aws/util.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/aws/util.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/aws/util.py (original)
+++ incubator/tashi/trunk/src/tashi/aws/util.py Fri Dec  4 21:38:24 2009
@@ -16,13 +16,14 @@
 # under the License.    
 
 import sys
+import tashi
+import tashi.aws.data
 import traceback
 import types
 import uuid
+import trans
 from xml.dom import minidom
 from ZSI import SoapWriter
-import tashi
-import trans
 
 sizes = {'m1.small': (int(1.7*1024), 1),
          'm1.large': (int(7.5*1024), 4),
@@ -39,7 +40,7 @@
 		return obj
 	try:
 		if (getattr(obj, "__dict__", None)):
-			for k in obj.__dict__.keys():
+			for k in obj.__dict__:
 				if (not k.startswith("_")):
 					setattr(obj, "_%s" % (k), fixObject(getattr(obj, k)))
 		else:
@@ -91,6 +92,9 @@
 		return getattr(obj, name)
 
 client = Lazy("tashi.createClient(tashi.getConfig()[0])")
+global awsdata
+awsdata = tashi.aws.data.Pickled(tashi.getConfig()[0])
+awsdir = '/tmp/'
 
 users = {}
 def userIdToName(id):
@@ -114,10 +118,9 @@
 		return users[name]
 	else:
 		return -1
-	
-vars = {}
 
 def genRequestId():
 	return str(uuid.uuid1())
-
+	
+vars = {}
 authorizedUser = "UNKNOWN"

Modified: incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py?rev=887368&r1=887367&r2=887368&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py (original)
+++ incubator/tashi/trunk/src/tashi/rpycservices/rpyctypes.py Fri Dec  4 21:38:24 2009
@@ -210,6 +210,7 @@
 		#Quick fix so self.nics is not None
 		self.nics = []
 		self.hints = None
+		self.groupName = None
 		if isinstance(d, dict):
 			if 'id' in d:
 				self.id = d['id']
@@ -235,6 +236,8 @@
 				self.nics = d['nics']
 			if 'hints' in d:
 				self.hints = d['hints']
+			if 'groupName' in d:
+				self.groupName = d['groupName']
 
 	def __str__(self): 
 		return str(self.__dict__)
@@ -248,3 +251,178 @@
 	def __ne__(self, other):
 		return not (self == other)
 
+class Key(object):
+	def __init__(self, d=None):
+		self.userId = None
+		self.keyName = None
+		self.fingerprint = None
+		self.pubkey = None
+		self.privkey = None
+		if isinstance(d, dict):
+			if 'userId' in d:
+				self.userId = d['userId']
+			if 'keyName' in d:
+				self.keyName = d['keyName']
+			if 'fingerprint' in d:
+				self.fingerprint = d['fingerprint']
+			if 'pubkey' in d:
+				self.pubkey = d['pubkey']
+			if 'privkey' in d:
+				self.privkey = d['privkey']
+
+	def __str__(self): 
+		return str(self.__dict__)
+
+	def __repr__(self): 
+		return repr(self.__dict__)
+
+	def __eq__(self, other):
+		return isinstance(other, self.__class__) and self.userId == other.userId and self.keyName
== other.keyName
+
+	def __ne__(self, other):
+		return not (self == other)
+
+class Group(object):
+	def __init__(self, d=None):
+		self.userId = None
+		self.groupName = None
+		self.groupDescription = None
+		self.ipPermissions = []
+		if isinstance(d, dict):
+			if 'userId' in d:
+				self.userId = d['userId']
+			if 'groupName' in d:
+				self.groupName = d['groupName']
+			if 'groupDescription' in d:
+				self.groupDescription = d['groupDescription']
+			if 'ipPermissions' in d:
+				self.ipPermissions = d['ipPermissions']
+
+	def __str__(self): 
+		return str(self.__dict__)
+
+	def __repr__(self): 
+		return repr(self.__dict__)
+
+	def __eq__(self, other):
+		return isinstance(other, self.__class__) and self.userId == other.userId and self.groupName
== other.groupName
+
+	def __ne__(self, other):
+		return not (self == other)
+
+class GroupPermission(object):
+	def __init__(self, d=None):
+		self.targetUserId = None
+		self.groupName = None
+		if isinstance(d, dict):
+			if 'targetUserId' in d:
+				self.targetUserId = d['targetUserId']
+			if 'groupName' in d:
+				self.groupName = d['groupName']
+
+	def __str__(self): 
+		return str(self.__dict__)
+
+	def __repr__(self): 
+		return repr(self.__dict__)
+
+	def __eq__(self, other):
+		return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+	def __ne__(self, other):
+		return not (self == other)
+
+class IpPermission(object):
+	def __init__(self, d=None):
+		self.userId = None
+		self.groupName = None
+		self.ipProtocol = None
+		self.fromPort = None
+		self.toPort = None
+		self.cidrIp = None
+		self.groupPermissions = []
+		if isinstance(d, dict):
+			if 'userId' in d:
+				self.userId = d['userId']
+			if 'groupName' in d:
+				self.groupName = d['groupName']
+			if 'ipProtocol' in d:
+				self.ipProtocol = d['ipProtocol']
+			if 'fromPort' in d:
+				self.fromPort = d['fromPort']
+			if 'toPort' in d:
+				self.toPort = d['toPort']
+			if 'cidrIp' in d:
+				self.cidrIp = d['cidrIp']
+			if 'groupPermissions' in d:
+				self.groupPermissions = d['groupPermissions']
+
+	def __str__(self): 
+		return str(self.__dict__)
+
+	def __repr__(self): 
+		return repr(self.__dict__)
+
+	def __eq__(self, other):
+		return isinstance(other, self.__class__) and self.groupName == other.groupName and self.userId
== other.userId and self.ipProtocol == other.ipProtocol and self.fromPort == other.fromPort
and self.toPort == other.toPort and self.cidrIp == other.cidrIp
+
+	def __ne__(self, other):
+		return not (self == other)
+
+class Image(object):
+	def __init__(self, d=None):
+		self.userId = None
+		self.imageId = None
+		self.isPublic = False
+		self.explicitUserIds = []
+		self.s3path = None
+		self.productCode = ''
+		if isinstance(d, dict):
+			if 'userId' in d:
+				self.userId = d['userId']
+			if 'imageId' in d:
+				self.imageId = d['imageId']
+			if 'isPublic' in d:
+				self.isPublic = d['isPublic']
+			if 'explicitUserIds' in d:
+				self.explicitUserIds = d['explicitUserIds']
+			if 's3path' in d:
+				self.s3path = d['s3path']
+			if 'productCode' in d:
+				self.productCode = d['productCode']
+
+	def __str__(self): 
+		return str(self.__dict__)
+
+	def __repr__(self): 
+		return repr(self.__dict__)
+
+	def __eq__(self, other):
+		return isinstance(other, self.__class__) and self.imageId == other.imageId and self.userId
== other.userId
+
+	def __ne__(self, other):
+		return not (self == other)
+
+class Address(object):
+	def __init__(self, d=None):
+		self.userId = None
+		self.publicIp = None
+		self.instanceId = None
+		if 'userId' in d:
+			self.userId = d['userId']
+		if 'publicIp' in d:
+			self.publicIp = d['publicIp']
+		if 'instanceId' in d:
+			self.instanceId = d['instanceId']
+
+	def __str__(self): 
+		return str(self.__dict__)
+
+	def __repr__(self): 
+		return repr(self.__dict__)
+
+	def __eq__(self, other):
+		return isinstance(other, self.__class__) and self.userId == other.userId and self.publicIp
== other.publicIp
+
+	def __ne__(self, other):
+		return not (self == other)



Mime
View raw message