Ejemplo n.º 1
0
def test_request_spot_instances():
    conn = boto.connect_ec2()

    conn.create_security_group('group1', 'description')
    conn.create_security_group('group2', 'description')

    start = iso_8601_datetime(datetime.datetime(2013, 1, 1))
    end = iso_8601_datetime(datetime.datetime(2013, 1, 2))

    request = conn.request_spot_instances(
        price=0.5,
        image_id='ami-abcd1234',
        count=1,
        type='one-time',
        valid_from=start,
        valid_until=end,
        launch_group="the-group",
        availability_zone_group='my-group',
        key_name="test",
        security_groups=['group1', 'group2'],
        user_data="some test data",
        instance_type='m1.small',
        placement='us-east-1c',
        kernel_id="test-kernel",
        ramdisk_id="test-ramdisk",
        monitoring_enabled=True,
        subnet_id="subnet123",
    )

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")
    request.price.should.equal(0.5)
    request.launch_specification.image_id.should.equal('ami-abcd1234')
    request.type.should.equal('one-time')
    request.valid_from.should.equal(start)
    request.valid_until.should.equal(end)
    request.launch_group.should.equal("the-group")
    request.availability_zone_group.should.equal('my-group')
    request.launch_specification.key_name.should.equal("test")
    security_group_names = [
        group.name for group in request.launch_specification.groups
    ]
    set(security_group_names).should.equal(set(['group1', 'group2']))
    request.launch_specification.instance_type.should.equal('m1.small')
    request.launch_specification.placement.should.equal('us-east-1c')
    request.launch_specification.kernel.should.equal("test-kernel")
    request.launch_specification.ramdisk.should.equal("test-ramdisk")
    request.launch_specification.subnet_id.should.equal("subnet123")
Ejemplo n.º 2
0
 def get_post_data(self, message, message_id):
     return {
         "Type": "Notification",
         "MessageId": message_id,
         "TopicArn": self.topic.arn,
         "Subject": "my subject",
         "Message": message,
         "Timestamp": iso_8601_datetime(datetime.datetime.now()),
         "SignatureVersion": "1",
         "Signature": "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
         "SigningCertURL": "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
         "UnsubscribeURL": "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
     }
Ejemplo n.º 3
0
def test_request_spot_instances():
    conn = boto.connect_ec2()

    conn.create_security_group('group1', 'description')
    conn.create_security_group('group2', 'description')

    start = iso_8601_datetime(datetime.datetime(2013, 1, 1))
    end = iso_8601_datetime(datetime.datetime(2013, 1, 2))

    request = conn.request_spot_instances(
        price=0.5, image_id='ami-abcd1234', count=1, type='one-time',
        valid_from=start, valid_until=end, launch_group="the-group",
        availability_zone_group='my-group', key_name="test",
        security_groups=['group1', 'group2'], user_data="some test data",
        instance_type='m1.small', placement='us-east-1c',
        kernel_id="test-kernel", ramdisk_id="test-ramdisk",
        monitoring_enabled=True, subnet_id="subnet123",
    )

    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    request = requests[0]

    request.state.should.equal("open")
    request.price.should.equal(0.5)
    request.launch_specification.image_id.should.equal('ami-abcd1234')
    request.type.should.equal('one-time')
    request.valid_from.should.equal(start)
    request.valid_until.should.equal(end)
    request.launch_group.should.equal("the-group")
    request.availability_zone_group.should.equal('my-group')
    request.launch_specification.key_name.should.equal("test")
    security_group_names = [group.name for group in request.launch_specification.groups]
    set(security_group_names).should.equal(set(['group1', 'group2']))
    request.launch_specification.instance_type.should.equal('m1.small')
    request.launch_specification.placement.should.equal('us-east-1c')
    request.launch_specification.kernel.should.equal("test-kernel")
    request.launch_specification.ramdisk.should.equal("test-ramdisk")
    request.launch_specification.subnet_id.should.equal("subnet123")
Ejemplo n.º 4
0
 def last_modified_ISO8601(self):
     return iso_8601_datetime(self.last_modified)
Ejemplo n.º 5
0
 def last_modified_ISO8601(self):
     return iso_8601_datetime(self.last_modified)
Ejemplo n.º 6
0
 def expiration_ISO8601(self):
     return iso_8601_datetime(self.expiration)
Ejemplo n.º 7
0
 def expiration_ISO8601(self):
     return iso_8601_datetime(self.expiration)