Fix for LP Bug #737240
This commit is contained in:
parent
d6e6ba0780
commit
59d2a315b8
|
@ -39,3 +39,101 @@ class EC2ConnectionV6(boto.ec2.EC2Connection):
|
|||
self.build_filter_params(params, filters)
|
||||
return self.get_list('DescribeInstancesV6', params,
|
||||
[('item', ReservationV6)])
|
||||
|
||||
def run_instances(self, image_id, min_count=1, max_count=1,
|
||||
key_name=None, security_groups=None,
|
||||
user_data=None, addressing_type=None,
|
||||
instance_type='m1.small', placement=None,
|
||||
kernel_id=None, ramdisk_id=None,
|
||||
monitoring_enabled=False, subnet_id=None,
|
||||
block_device_map=None):
|
||||
"""
|
||||
Runs an image on EC2.
|
||||
|
||||
:type image_id: string
|
||||
:param image_id: The ID of the image to run
|
||||
|
||||
:type min_count: int
|
||||
:param min_count: The minimum number of instances to launch
|
||||
|
||||
:type max_count: int
|
||||
:param max_count: The maximum number of instances to launch
|
||||
|
||||
:type key_name: string
|
||||
:param key_name: The name of the key pair with which to
|
||||
launch instances
|
||||
|
||||
:type security_groups: list of strings
|
||||
:param security_groups: The names of the security groups with
|
||||
which to associate instances
|
||||
|
||||
:type user_data: string
|
||||
:param user_data: The user data passed to the launched instances
|
||||
|
||||
:type instance_type: string
|
||||
:param instance_type: The type of instance to run
|
||||
(m1.small, m1.large, m1.xlarge)
|
||||
|
||||
:type placement: string
|
||||
:param placement: The availability zone in which to launch
|
||||
the instances
|
||||
|
||||
:type kernel_id: string
|
||||
:param kernel_id: The ID of the kernel with which to
|
||||
launch the instances
|
||||
|
||||
:type ramdisk_id: string
|
||||
:param ramdisk_id: The ID of the RAM disk with which to
|
||||
launch the instances
|
||||
|
||||
:type monitoring_enabled: bool
|
||||
:param monitoring_enabled: Enable CloudWatch monitoring
|
||||
on the instance.
|
||||
|
||||
:type subnet_id: string
|
||||
:param subnet_id: The subnet ID within which to launch
|
||||
the instances for VPC.
|
||||
|
||||
:type block_device_map:
|
||||
:class:`boto.ec2.blockdevicemapping.BlockDeviceMapping`
|
||||
:param block_device_map: A BlockDeviceMapping data structure
|
||||
describing the EBS volumes associated
|
||||
with the Image.
|
||||
|
||||
:rtype: Reservation
|
||||
:return: The :class:`boto.ec2.instance.Reservation`
|
||||
associated with the request for machines
|
||||
"""
|
||||
params = {'ImageId': image_id,
|
||||
'MinCount': min_count,
|
||||
'MaxCount': max_count}
|
||||
if key_name:
|
||||
params['KeyName'] = key_name
|
||||
if security_groups:
|
||||
l = []
|
||||
for group in security_groups:
|
||||
if isinstance(group, SecurityGroup):
|
||||
l.append(group.name)
|
||||
else:
|
||||
l.append(group)
|
||||
self.build_list_params(params, l, 'SecurityGroup')
|
||||
if user_data:
|
||||
params['UserData'] = base64.b64encode(user_data)
|
||||
if addressing_type:
|
||||
params['AddressingType'] = addressing_type
|
||||
if instance_type:
|
||||
params['InstanceType'] = instance_type
|
||||
if placement:
|
||||
params['Placement.AvailabilityZone'] = placement
|
||||
if kernel_id:
|
||||
params['KernelId'] = kernel_id
|
||||
if ramdisk_id:
|
||||
params['RamdiskId'] = ramdisk_id
|
||||
if monitoring_enabled:
|
||||
params['Monitoring.Enabled'] = 'true'
|
||||
if subnet_id:
|
||||
params['SubnetId'] = subnet_id
|
||||
if block_device_map:
|
||||
block_device_map.build_list_params(params)
|
||||
return self.get_object('RunInstances', params,
|
||||
ReservationV6, verb='POST')
|
||||
|
|
|
@ -34,8 +34,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
|
|||
from smoketests import flags
|
||||
from smoketests import base
|
||||
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
flags.DEFINE_string('bundle_kernel', 'openwrt-x86-vmlinuz',
|
||||
'Local kernel file to use for bundling tests')
|
||||
|
@ -46,6 +44,8 @@ TEST_PREFIX = 'test%s' % int(random.random() * 1000000)
|
|||
TEST_BUCKET = '%s_bucket' % TEST_PREFIX
|
||||
TEST_KEY = '%s_key' % TEST_PREFIX
|
||||
TEST_GROUP = '%s_group' % TEST_PREFIX
|
||||
|
||||
|
||||
class ImageTests(base.UserSmokeTestCase):
|
||||
def test_001_can_bundle_image(self):
|
||||
self.assertTrue(self.bundle_image(FLAGS.bundle_image))
|
||||
|
@ -148,7 +148,8 @@ class InstanceTests(base.UserSmokeTestCase):
|
|||
self.fail('could not ping instance')
|
||||
|
||||
if FLAGS.use_ipv6:
|
||||
if not self.wait_for_ping(self.data['instance'].ip_v6, "ping6"):
|
||||
if not self.wait_for_ping(self.data['instance'].dns_name_v6,
|
||||
"ping6"):
|
||||
self.fail('could not ping instance v6')
|
||||
|
||||
def test_005_can_ssh_to_private_ip(self):
|
||||
|
@ -157,7 +158,7 @@ class InstanceTests(base.UserSmokeTestCase):
|
|||
self.fail('could not ssh to instance')
|
||||
|
||||
if FLAGS.use_ipv6:
|
||||
if not self.wait_for_ssh(self.data['instance'].ip_v6,
|
||||
if not self.wait_for_ssh(self.data['instance'].dns_name_v6,
|
||||
TEST_KEY):
|
||||
self.fail('could not ssh to instance v6')
|
||||
|
||||
|
@ -286,8 +287,7 @@ class VolumeTests(base.UserSmokeTestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
suites = {'image': unittest.makeSuite(ImageTests),
|
||||
suites = {
|
||||
'instance': unittest.makeSuite(InstanceTests),
|
||||
'volume': unittest.makeSuite(VolumeTests)
|
||||
}
|
||||
sys.exit(base.run_tests(suites))
|
||||
|
|
Loading…
Reference in New Issue