You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.6 KiB
122 lines
4.6 KiB
Patch by Robert Scheck <robert@fedoraproject.org> for boto >= 1.9b, which replaces
|
|
ternary operator and with-statement context usages by python 2.4 compatible stuff.
|
|
It also works around PEP 341 (Unifying try-except and try-finally).
|
|
|
|
--- boto-1.9b/boto/manage/server.py 2009-12-13 16:32:54.000000000 +0100
|
|
+++ boto-1.9b/boto/manage/server.py.python24 2011-01-02 23:36:53.000000000 +0100
|
|
@@ -22,7 +22,6 @@
|
|
"""
|
|
High-level abstraction of an EC2 server
|
|
"""
|
|
-from __future__ import with_statement
|
|
import boto.ec2
|
|
from boto.mashups.iobject import IObject
|
|
from boto.pyami.config import BotoConfigPath, Config
|
|
@@ -328,7 +327,10 @@
|
|
for instance in instances:
|
|
s = cls()
|
|
s.ec2 = ec2
|
|
- s.name = params.get('name') + '' if i==0 else str(i)
|
|
+ if i == 0:
|
|
+ s.name = params.get('name') + ''
|
|
+ else:
|
|
+ s.name = str(i)
|
|
s.description = params.get('description')
|
|
s.region_name = region.name
|
|
s.instance_id = instance.id
|
|
@@ -522,8 +524,11 @@
|
|
self._cmdshell = None
|
|
|
|
def run(self, command):
|
|
- with closing(self.get_cmdshell()) as cmd:
|
|
+ try:
|
|
+ cmd = self.get_cmdshell()
|
|
status = cmd.run(command)
|
|
+ finally:
|
|
+ cmd.close()
|
|
return status
|
|
|
|
def get_bundler(self, uname='root'):
|
|
--- boto-1.9b/boto/manage/volume.py 2009-11-24 04:47:51.000000000 +0100
|
|
+++ boto-1.9b/boto/manage/volume.py.python24 2011-01-02 23:55:51.000000000 +0100
|
|
@@ -19,7 +19,6 @@
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
# IN THE SOFTWARE.
|
|
|
|
-from __future__ import with_statement
|
|
from boto.sdb.db.model import Model
|
|
from boto.sdb.db.property import *
|
|
from boto.manage.server import Server
|
|
@@ -232,28 +231,33 @@
|
|
def wait(self):
|
|
if self.server == None:
|
|
raise ValueError, 'server attribute must be set to run this command'
|
|
- with closing(self.server.get_cmdshell()) as cmd:
|
|
+ try:
|
|
# wait for the volume device to appear
|
|
cmd = self.server.get_cmdshell()
|
|
while not cmd.exists(self.device):
|
|
boto.log.info('%s still does not exist, waiting 10 seconds' % self.device)
|
|
time.sleep(10)
|
|
+ finally:
|
|
+ cmd.close()
|
|
|
|
def format(self):
|
|
if self.server == None:
|
|
raise ValueError, 'server attribute must be set to run this command'
|
|
status = None
|
|
- with closing(self.server.get_cmdshell()) as cmd:
|
|
+ try:
|
|
+ cmd = self.server.get_cmdshell()
|
|
if not self.checkfs(cmd):
|
|
boto.log.info('make_fs...')
|
|
status = cmd.run('mkfs -t xfs %s' % self.device)
|
|
+ finally:
|
|
+ cmd.close()
|
|
return status
|
|
|
|
def mount(self):
|
|
if self.server == None:
|
|
raise ValueError, 'server attribute must be set to run this command'
|
|
boto.log.info('handle_mount_point')
|
|
- with closing(self.server.get_cmdshell()) as cmd:
|
|
+ try:
|
|
cmd = self.server.get_cmdshell()
|
|
if not cmd.isdir(self.mount_point):
|
|
boto.log.info('making directory')
|
|
@@ -276,6 +280,8 @@
|
|
# Mount up our new EBS volume onto mount_point
|
|
cmd.run("mount %s %s" % (self.device, self.mount_point))
|
|
cmd.run('xfs_growfs %s' % self.mount_point)
|
|
+ finally:
|
|
+ cmd.close()
|
|
|
|
def make_ready(self, server):
|
|
self.server = server
|
|
@@ -298,15 +304,16 @@
|
|
# if this volume is attached to a server
|
|
# we need to freeze the XFS file system
|
|
try:
|
|
- self.freeze()
|
|
- if self.server == None:
|
|
- snapshot = self.get_ec2_connection().create_snapshot(self.volume_id)
|
|
- else:
|
|
- snapshot = self.server.ec2.create_snapshot(self.volume_id)
|
|
- boto.log.info('Snapshot of Volume %s created: %s' % (self.name, snapshot))
|
|
- except Exception, e:
|
|
- boto.log.info('Snapshot error')
|
|
- boto.log.info(traceback.format_exc())
|
|
+ try:
|
|
+ self.freeze()
|
|
+ if self.server == None:
|
|
+ snapshot = self.get_ec2_connection().create_snapshot(self.volume_id)
|
|
+ else:
|
|
+ snapshot = self.server.ec2.create_snapshot(self.volume_id)
|
|
+ boto.log.info('Snapshot of Volume %s created: %s' % (self.name, snapshot))
|
|
+ except Exception, e:
|
|
+ boto.log.info('Snapshot error')
|
|
+ boto.log.info(traceback.format_exc())
|
|
finally:
|
|
status = self.unfreeze()
|
|
return status
|