Skip to content
Browse files

Fixing some issues with Spot instance datafeed subscriptions.

  • Loading branch information...
1 parent a9e5df1 commit 57a3f6ab9bbf7813cf941d22ad6eb7e4556c2d24 Mitch.Garnaat committed Dec 18, 2009
Showing with 36 additions and 3 deletions.
  1. +4 −2 boto/ec2/connection.py
  2. +10 −1 boto/ec2/spotdatafeedsubscription.py
  3. +22 −0 boto/ec2/spotinstancerequest.py
View
6 boto/ec2/connection.py
@@ -48,6 +48,8 @@
from boto.ec2.launchspecification import LaunchSpecification
from boto.exception import EC2ResponseError
+#boto.set_stream_logger('ec2')
+
class EC2Connection(AWSQueryConnection):
APIVersion = boto.config.get('Boto', 'ec2_version', '2009-11-30')
@@ -814,7 +816,7 @@ def get_spot_datafeed_subscription(self):
return self.get_object('DescribeSpotDatafeedSubscription',
None, SpotDatafeedSubscription)
- def create_spot_datafeed_subscription(self, bucket, prefix=None):
+ def create_spot_datafeed_subscription(self, bucket, prefix):
"""
Create a spot instance datafeed subscription for this account.
@@ -833,7 +835,7 @@ def create_spot_datafeed_subscription(self, bucket, prefix=None):
if prefix:
params['Prefix'] = prefix
return self.get_object('CreateSpotDatafeedSubscription',
- None, SpotDatafeedSubscription)
+ params, SpotDatafeedSubscription)
def delete_spot_datafeed_subscription(self):
"""
View
11 boto/ec2/spotdatafeedsubscription.py
@@ -23,20 +23,29 @@
Represents an EC2 Spot Instance Datafeed Subscription
"""
from boto.ec2.ec2object import EC2Object
+from boto.ec2.spotinstancerequest import SpotInstanceStateFault
class SpotDatafeedSubscription(EC2Object):
def __init__(self, connection=None, owner_id=None,
- bucket=None, prefix=None, state=None):
+ bucket=None, prefix=None, state=None,fault=None):
EC2Object.__init__(self, connection)
self.owner_id = owner_id
self.bucket = bucket
self.prefix = prefix
self.state = state
+ self.fault = fault
def __repr__(self):
return 'SpotDatafeedSubscription:%s' % self.bucket
+ def startElement(self, name, attrs, connection):
+ if name == 'fault':
+ self.fault = SpotInstanceStateFault()
+ return self.fault
+ else:
+ return None
+
def endElement(self, name, value, connection):
if name == 'ownerId':
self.owner_id = value
View
22 boto/ec2/spotinstancerequest.py
@@ -26,6 +26,25 @@
from boto.ec2.ec2object import EC2Object
from boto.ec2.launchspecification import LaunchSpecification
+class SpotInstanceStateFault(object):
+
+ def __init__(self, code=None, message=None):
+ self.code = code
+ self.message = message
+
+ def __repr__(self):
+ return '(%s, %s)' % (self.code, self.message)
+
+ def startElement(self, name, attrs, connection):
+ return None
+
+ def endElement(self, name, value, connection):
+ if name == 'code':
+ self.code = code
+ elif name == 'message':
+ self.message = message
+ setattr(self, name, value)
+
class SpotInstanceRequest(EC2Object):
def __init__(self, connection=None):
@@ -50,6 +69,9 @@ def startElement(self, name, attrs, connection):
if name == 'launchSpecification':
self.launch_specification = LaunchSpecification(connection)
return self.launch_specification
+ elif name == 'fault':
+ self.fault = SpotInstanceStateFault()
+ return self.fault
else:
return None

0 comments on commit 57a3f6a

Please sign in to comment.
Something went wrong with that request. Please try again.