Example #1
0
 def attach(self):
     ec2 = boto.connect_ec2()
     if self.logical_volume_name:
         # if a logical volume was specified, override the specified volume_id
         # (if there was one) with the current AWS volume for the logical volume:
         logical_volume = Volume.find(name=self.logical_volume_name).next()
         self.volume_id = logical_volume._volume_id
     volume = ec2.get_all_volumes([self.volume_id])[0]
     # wait for the volume to be available. The volume may still be being created
     # from a snapshot.
     while volume.update() != 'available':
         boto.log.info('Volume %s not yet available. Current status = %s.' %
                       (volume.id, volume.status))
         time.sleep(5)
     instance = ec2.get_only_instances([self.instance_id])[0]
     attempt_attach = True
     while attempt_attach:
         try:
             ec2.attach_volume(self.volume_id, self.instance_id,
                               self.device)
             attempt_attach = False
         except EC2ResponseError, e:
             if e.error_code != 'IncorrectState':
                 # if there's an EC2ResonseError with the code set to IncorrectState, delay a bit for ec2
                 # to realize the instance is running, then try again. Otherwise, raise the error:
                 boto.log.info(
                     'Attempt to attach the EBS volume %s to this instance (%s) returned %s. Trying again in a bit.'
                     % (self.volume_id, self.instance_id, e.errors))
                 time.sleep(2)
             else:
                 raise e
Example #2
0
 def attach(self):
     ec2 = boto.connect_ec2()
     if self.logical_volume_name:
         # if a logical volume was specified, override the specified volume_id
         # (if there was one) with the current AWS volume for the logical volume:
         logical_volume = next(Volume.find(name = self.logical_volume_name))
         self.volume_id = logical_volume._volume_id
     volume = ec2.get_all_volumes([self.volume_id])[0]
     # wait for the volume to be available. The volume may still be being created
     # from a snapshot.
     while volume.update() != 'available':
         boto.log.info('Volume %s not yet available. Current status = %s.' % (volume.id, volume.status))
         time.sleep(5)
     instance = ec2.get_only_instances([self.instance_id])[0]
     attempt_attach = True
     while attempt_attach:
         try:
             ec2.attach_volume(self.volume_id, self.instance_id, self.device)
             attempt_attach = False
         except EC2ResponseError as e:
             if e.error_code != 'IncorrectState':
                 # if there's an EC2ResonseError with the code set to IncorrectState, delay a bit for ec2
                 # to realize the instance is running, then try again. Otherwise, raise the error:
                 boto.log.info('Attempt to attach the EBS volume %s to this instance (%s) returned %s. Trying again in a bit.' % (self.volume_id, self.instance_id, e.errors))
                 time.sleep(2)
             else:
                 raise e
     boto.log.info('Attached volume %s to instance %s as device %s' % (self.volume_id, self.instance_id, self.device))
     # now wait for the volume device to appear
     while not os.path.exists(self.device):
         boto.log.info('%s still does not exist, waiting 2 seconds' % self.device)
         time.sleep(2)
Example #3
0
File: ebs.py Project: rlotun/boto
 def attach(self):
     ec2 = boto.connect_ec2()
     if self.logical_volume_name:
         # if a logical volume was specified, override the specified volume_id
         # (if there was one) with the current AWS volume for the logical volume:
         logical_volume = Volume.find(name=self.logical_volume_name).next()
         self.volume_id = logical_volume._volume_id
     volume = ec2.get_all_volumes([self.volume_id])[0]
     # wait for the volume to be available. The volume may still be being created
     # from a snapshot.
     while volume.update() != "available":
         boto.log.info("Volume %s not yet available. Current status = %s." % (volume.id, volume.status))
         time.sleep(5)
     instance = ec2.get_all_instances([self.instance_id])[0].instances[0]
     attempt_attach = True
     while attempt_attach:
         try:
             ec2.attach_volume(self.volume_id, self.instance_id, self.device)
             attempt_attach = False
         except EC2ResponseError, e:
             if e.error_code != "IncorrectState":
                 # if there's an EC2ResonseError with the code set to IncorrectState, delay a bit for ec2
                 # to realize the instance is running, then try again. Otherwise, raise the error:
                 boto.log.info(
                     "Attempt to attach the EBS volume %s to this instance (%s) returned %s. Trying again in a bit."
                     % (self.volume_id, self.instance_id, e.errors)
                 )
                 time.sleep(2)
             else:
                 raise e
Example #4
0
 def attach(self):
     ec2 = boto.connect_ec2()
     if self.logical_volume_name:
         # if a logical volume was specified, override the specified volume_id
         # (if there was one) with the current AWS volume for the logical volume:
         logical_volume = Volume.find(name = self.logical_volume_name).next()
         self.volume_id = logical_volume._volume_id
     volume = ec2.get_all_volumes([self.volume_id])[0]
     # wait for the volume to be available. The volume may still be being created
     # from a snapshot.
     while volume.update() != 'available':
         boto.log.info('Volume %s not yet available. Current status = %s.' % (volume.id, volume.status))
         time.sleep(5)
     ec2.attach_volume(self.volume_id, self.instance_id, self.device)
     # now wait for the volume device to appear
     while not os.path.exists(self.device):
         boto.log.info('%s still does not exist, waiting 10 seconds' % self.device)
         time.sleep(10)
Example #5
0
 def attach(self):
     ec2 = boto.connect_ec2()
     if self.logical_volume_name:
         # if a logical volume was specified, override the specified volume_id
         # (if there was one) with the current AWS volume for the logical volume:
         logical_volume = Volume.find(name=self.logical_volume_name).next()
         self.volume_id = logical_volume._volume_id
     volume = ec2.get_all_volumes([self.volume_id])[0]
     # wait for the volume to be available. The volume may still be being created
     # from a snapshot.
     while volume.update() != 'available':
         boto.log.info('Volume %s not yet available. Current status = %s.' %
                       (volume.id, volume.status))
         time.sleep(5)
     ec2.attach_volume(self.volume_id, self.instance_id, self.device)
     # now wait for the volume device to appear
     while not os.path.exists(self.device):
         boto.log.info('%s still does not exist, waiting 10 seconds' %
                       self.device)
         time.sleep(10)
Example #6
0
from boto.manage.server import Server
from boto.manage.volume import Volume
import time

print('--> Creating New Volume')
volume = Volume.create()
print(volume)

print('--> Creating New Server')
server_list = Server.create()
server = server_list[0]
print(server)

print('----> Waiting for Server to start up')
while server.status != 'running':
    print('*')
    time.sleep(10)
print('----> Server is running')

print('--> Run "df -k" on Server')
status = server.run('df -k')
print(status[1])

print(
    '--> Now run volume.make_ready to make the volume ready to use on server')
volume.make_ready(server)

print('--> Run "df -k" on Server')
status = server.run('df -k')
print(status[1])
Example #7
0
from boto.manage.server import Server
from boto.manage.volume import Volume
import time

print("--> Creating New Volume")
volume = Volume.create()
print(volume)

print("--> Creating New Server")
server_list = Server.create()
server = server_list[0]
print(server)

print("----> Waiting for Server to start up")
while server.status != "running":
    print("*")
    time.sleep(10)
print("----> Server is running")

print('--> Run "df -k" on Server')
status = server.run("df -k")
print(status[1])

print("--> Now run volume.make_ready to make the volume ready to use on server")
volume.make_ready(server)

print('--> Run "df -k" on Server')
status = server.run("df -k")
print(status[1])

print('--> Do an "ls -al" on the new filesystem')