kill all pep8 errors in parser and resources
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
@ -148,7 +148,8 @@ def stack_create(context, values):
|
||||
def stack_delete(context, stack_name):
|
||||
s = stack_get(context, stack_name)
|
||||
if not s:
|
||||
raise Exception('Attempt to delete a stack with id: %s that does not exist' % stack_name)
|
||||
raise Exception('Attempt to delete a stack with id: %s %s' % \
|
||||
(stack_name, 'that does not exist'))
|
||||
|
||||
session = Session.object_session(s)
|
||||
|
||||
|
@ -41,7 +41,7 @@ class Stack(object):
|
||||
"AllowedValues": ["us-east-1", "us-west-1", "us-west-2",
|
||||
"sa-east-1", "eu-west-1", "ap-southeast-1",
|
||||
"ap-northeast-1"],
|
||||
"ConstraintDescription": "must be a valid EC2 instance type." }
|
||||
"ConstraintDescription": "must be a valid EC2 instance type."}
|
||||
|
||||
if parms != None:
|
||||
self._apply_user_parameters(parms)
|
||||
@ -79,19 +79,19 @@ class Stack(object):
|
||||
self.resources[r] = resources.GenericResource(r,
|
||||
self.t['Resources'][r], self)
|
||||
|
||||
self.calulate_dependencies(self.t['Resources'][r], self.resources[r])
|
||||
self.calulate_dependencies(self.t['Resources'][r],
|
||||
self.resources[r])
|
||||
|
||||
def validate(self):
|
||||
'''
|
||||
If you are wondering where the actual validation is, me too.
|
||||
it is just not obvious how to respond to validation failures.
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_ValidateTemplate.html
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/ \
|
||||
APIReference/API_ValidateTemplate.html
|
||||
'''
|
||||
response = { 'ValidateTemplateResult': {
|
||||
response = {'ValidateTemplateResult': {
|
||||
'Description': 'bla',
|
||||
'Parameters': []
|
||||
}
|
||||
}
|
||||
'Parameters': []}}
|
||||
|
||||
for p in self.parms:
|
||||
jp = {'member': {}}
|
||||
@ -137,17 +137,17 @@ class Stack(object):
|
||||
order = self.get_create_order()
|
||||
failed = False
|
||||
for r in order:
|
||||
failed_str = self.resources[r].CREATE_FAILED
|
||||
if not failed:
|
||||
try:
|
||||
self.resources[r].create()
|
||||
except Exception as ex:
|
||||
logger.exception('create')
|
||||
failed = True
|
||||
self.resources[r].state_set(self.resources[r].CREATE_FAILED, str(ex))
|
||||
self.resources[r].state_set(failed_str, str(ex))
|
||||
else:
|
||||
self.resources[r].state_set(self.resources[r].CREATE_FAILED)
|
||||
|
||||
|
||||
def create(self):
|
||||
|
||||
pool = eventlet.GreenPool()
|
||||
@ -155,7 +155,8 @@ class Stack(object):
|
||||
|
||||
def delete_blocking(self):
|
||||
'''
|
||||
delete all the resources in the reverse order specified by get_create_order
|
||||
delete all the resources in the reverse order specified by
|
||||
get_create_order().
|
||||
'''
|
||||
order = self.get_create_order()
|
||||
order.reverse()
|
||||
@ -300,7 +301,8 @@ class Stack(object):
|
||||
if res:
|
||||
return res.FnGetAtt(key_name)
|
||||
else:
|
||||
raise exception.InvalidTemplateAttribute(resource=resource_name, key=key_name)
|
||||
raise exception.InvalidTemplateAttribute(
|
||||
resource=resource_name, key=key_name)
|
||||
return rc
|
||||
else:
|
||||
s[i] = self.resolve_attributes(s[i])
|
||||
@ -311,7 +313,7 @@ class Stack(object):
|
||||
|
||||
def resolve_joins(self, s):
|
||||
'''
|
||||
looking for { "Fn::join": [] }
|
||||
looking for { "Fn::join": []}
|
||||
'''
|
||||
if isinstance(s, dict):
|
||||
for i in s:
|
||||
|
@ -159,7 +159,8 @@ class Resource(object):
|
||||
|
||||
def FnGetRefId(self):
|
||||
'''
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ \
|
||||
intrinsic-function-reference-ref.html
|
||||
'''
|
||||
if self.instance_id != None:
|
||||
return unicode(self.instance_id)
|
||||
@ -168,13 +169,15 @@ http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/intrinsic-f
|
||||
|
||||
def FnGetAtt(self, key):
|
||||
'''
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ \
|
||||
intrinsic-function-reference-getatt.html
|
||||
'''
|
||||
raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
|
||||
|
||||
def FnBase64(self, data):
|
||||
'''
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-base64.html
|
||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ \
|
||||
intrinsic-function-reference-base64.html
|
||||
'''
|
||||
return base64.b64encode(data)
|
||||
|
||||
@ -216,7 +219,8 @@ class SecurityGroup(Resource):
|
||||
break
|
||||
|
||||
if not sec:
|
||||
sec = self.nova().security_groups.create(self.name, self.description)
|
||||
sec = self.nova().security_groups.create(self.name,
|
||||
self.description)
|
||||
|
||||
self.instance_id_set(sec.id)
|
||||
|
||||
@ -231,9 +235,12 @@ class SecurityGroup(Resource):
|
||||
i['CidrIp'])
|
||||
except BadRequest as ex:
|
||||
if ex.message.find('already exists') >= 0:
|
||||
pass # no worries, the rule is already there
|
||||
# no worries, the rule is already there
|
||||
pass
|
||||
else:
|
||||
raise # unexpected error
|
||||
# unexpected error
|
||||
raise
|
||||
|
||||
self.state_set(self.CREATE_COMPLETE)
|
||||
|
||||
def delete(self):
|
||||
@ -266,7 +273,8 @@ class ElasticIp(Resource):
|
||||
self.ipaddress = ''
|
||||
|
||||
if 'Domain' in self.t['Properties']:
|
||||
logger.warn('*** can\'t support Domain %s yet' % (self.t['Properties']['Domain']))
|
||||
logger.warn('*** can\'t support Domain %s yet' % \
|
||||
(self.t['Properties']['Domain']))
|
||||
|
||||
def create(self):
|
||||
"""Allocate a floating IP for the current tenant."""
|
||||
@ -302,7 +310,8 @@ class ElasticIp(Resource):
|
||||
if key == 'AllocationId':
|
||||
return unicode(self.instance_id)
|
||||
else:
|
||||
raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
|
||||
raise exception.InvalidTemplateAttribute(resource=self.name,
|
||||
key=key)
|
||||
|
||||
|
||||
class ElasticIpAssociation(Resource):
|
||||
@ -322,8 +331,9 @@ class ElasticIpAssociation(Resource):
|
||||
return
|
||||
self.state_set(self.CREATE_IN_PROGRESS)
|
||||
super(ElasticIpAssociation, self).create()
|
||||
print 'ElasticIpAssociation %s.add_floating_ip(%s)' % (self.t['Properties']['InstanceId'],
|
||||
self.t['Properties']['EIP'])
|
||||
print 'ElasticIpAssociation %s.add_floating_ip(%s)' % \
|
||||
(self.t['Properties']['InstanceId'],
|
||||
self.t['Properties']['EIP'])
|
||||
|
||||
server = self.nova().servers.get(self.t['Properties']['InstanceId'])
|
||||
server.add_floating_ip(self.t['Properties']['EIP'])
|
||||
@ -398,15 +408,16 @@ class VolumeAttachment(Resource):
|
||||
self.state_set(self.CREATE_IN_PROGRESS)
|
||||
super(VolumeAttachment, self).create()
|
||||
|
||||
print 'Attaching InstanceId %s VolumeId %s Device %s' % \
|
||||
(self.t['Properties']['InstanceId'],
|
||||
self.t['Properties']['VolumeId'],
|
||||
self.t['Properties']['Device'])
|
||||
va = self.nova().volumes.create_server_volume(server_id=self.t['Properties']['InstanceId'],
|
||||
volume_id=self.t['Properties']['VolumeId'],
|
||||
device=self.t['Properties']['Device'])
|
||||
server_id = self.t['Properties']['InstanceId']
|
||||
volume_id = self.t['Properties']['VolumeId']
|
||||
print 'Attaching InstanceId %s VolumeId %s Device %s' % (server_id,
|
||||
volume_id, self.t['Properties']['Device'])
|
||||
volapi = self.nova().volumes
|
||||
va = volapi.create_server_volume(server_id=server_id,
|
||||
volume_id=volume_id,
|
||||
device=self.t['Properties']['Device'])
|
||||
|
||||
vol = self.nova('volume').volumes.get(va.id)
|
||||
vol = volapi.get(va.id)
|
||||
while vol.status == 'available' or vol.status == 'attaching':
|
||||
eventlet.sleep(1)
|
||||
vol.get()
|
||||
@ -423,19 +434,23 @@ class VolumeAttachment(Resource):
|
||||
self.state_set(self.DELETE_IN_PROGRESS)
|
||||
Resource.delete(self)
|
||||
|
||||
print 'VolumeAttachment un-attaching %s %s' % (self.t['Properties']['InstanceId'],
|
||||
self.instance_id)
|
||||
print 'VolumeAttachment un-attaching %s %s' % \
|
||||
(self.t['Properties']['InstanceId'],
|
||||
self.instance_id)
|
||||
|
||||
self.nova().volumes.delete_server_volume(self.t['Properties']['InstanceId'],
|
||||
self.instance_id)
|
||||
volapi = self.nova().volumes
|
||||
volapi.delete_server_volume(self.t['Properties']['InstanceId'],
|
||||
self.instance_id)
|
||||
|
||||
vol = self.nova('volume').volumes.get(self.t['Properties']['VolumeId'])
|
||||
print 'un-attaching %s, status %s' % (self.instance_id, vol.status)
|
||||
while vol.status == 'in-use':
|
||||
print 'trying to un-attach %s, but still %s' % (self.instance_id, vol.status)
|
||||
print 'trying to un-attach %s, but still %s' % (self.instance_id,
|
||||
vol.status)
|
||||
eventlet.sleep(1)
|
||||
try:
|
||||
self.nova().volumes.delete_server_volume(self.t['Properties']['InstanceId'],
|
||||
self.instance_id)
|
||||
volapi.delete_server_volume(self.t['Properties']['InstanceId'],
|
||||
self.instance_id)
|
||||
except Exception:
|
||||
pass
|
||||
vol.get()
|
||||
@ -472,7 +487,8 @@ class Instance(Resource):
|
||||
elif key == 'PublicIp':
|
||||
res = self.ipaddress
|
||||
else:
|
||||
raise exception.InvalidTemplateAttribute(resource=self.name, key=key)
|
||||
raise exception.InvalidTemplateAttribute(resource=self.name,
|
||||
key=key)
|
||||
|
||||
# TODO(asalkeld) PrivateDnsName, PublicDnsName & PrivateIp
|
||||
|
||||
@ -560,7 +576,8 @@ class Instance(Resource):
|
||||
mime_blob.attach(msg)
|
||||
|
||||
server = self.nova().servers.create(name=self.name, image=image_id,
|
||||
flavor=flavor_id, key_name=key_name,
|
||||
flavor=flavor_id,
|
||||
key_name=key_name,
|
||||
security_groups=security_groups,
|
||||
userdata=mime_blob.as_string())
|
||||
while server.status == 'BUILD':
|
||||
|
@ -200,7 +200,7 @@ class TopicPublisher(Publisher):
|
||||
"""init a 'topic' publisher.
|
||||
"""
|
||||
super(TopicPublisher, self).__init__(session,
|
||||
"%s/%s" % (config.FLAGS.control_exchange, topic))
|
||||
"%s/%s" % (config.FLAGS.control_exchange, topic))
|
||||
|
||||
|
||||
class FanoutPublisher(Publisher):
|
||||
@ -218,7 +218,7 @@ class NotifyPublisher(Publisher):
|
||||
"""init a 'topic' publisher.
|
||||
"""
|
||||
super(NotifyPublisher, self).__init__(session,
|
||||
"%s/%s" % (config.FLAGS.control_exchange, topic),
|
||||
"%s/%s" % (config.FLAGS.control_exchange, topic),
|
||||
{"durable": True})
|
||||
|
||||
|
||||
@ -253,7 +253,8 @@ class Connection(object):
|
||||
self.connection.sasl_mechanisms = config.FLAGS.qpid_sasl_mechanisms
|
||||
self.connection.reconnect = config.FLAGS.qpid_reconnect
|
||||
if config.FLAGS.qpid_reconnect_timeout:
|
||||
self.connection.reconnect_timeout = config.FLAGS.qpid_reconnect_timeout
|
||||
self.connection.reconnect_timeout = \
|
||||
config.FLAGS.qpid_reconnect_timeout
|
||||
if config.FLAGS.qpid_reconnect_limit:
|
||||
self.connection.reconnect_limit = config.FLAGS.qpid_reconnect_limit
|
||||
if config.FLAGS.qpid_reconnect_interval_max:
|
||||
@ -263,7 +264,8 @@ class Connection(object):
|
||||
self.connection.reconnect_interval_min = (
|
||||
config.FLAGS.qpid_reconnect_interval_min)
|
||||
if config.FLAGS.qpid_reconnect_interval:
|
||||
self.connection.reconnect_interval = config.FLAGS.qpid_reconnect_interval
|
||||
self.connection.reconnect_interval = \
|
||||
config.FLAGS.qpid_reconnect_interval
|
||||
self.connection.hearbeat = config.FLAGS.qpid_heartbeat
|
||||
self.connection.protocol = config.FLAGS.qpid_protocol
|
||||
self.connection.tcp_nodelay = config.FLAGS.qpid_tcp_nodelay
|
||||
|
@ -1,5 +1,6 @@
|
||||
def setup():
|
||||
print "package setup complete"
|
||||
|
||||
|
||||
def teardown():
|
||||
print "package teardown complete"
|
||||
|
@ -1,7 +1,7 @@
|
||||
###
|
||||
### an unparented test -- no encapsulating class, just any fn starting with
|
||||
### 'test'.
|
||||
### http://darcs.idyll.org/~t/projects/nose-demo/simple/tests/test_stuff.py.html
|
||||
## http://darcs.idyll.org/~t/projects/nose-demo/simple/tests/test_stuff.py.html
|
||||
###
|
||||
|
||||
import sys
|
||||
@ -20,7 +20,7 @@ def tearDown():
|
||||
print "test1 teardown complete"
|
||||
|
||||
|
||||
@with_setup(setUp, tearDown) # test level
|
||||
@with_setup(setUp, tearDown) # test level
|
||||
@attr(tag=['example', 'func'])
|
||||
@attr(speed='fast')
|
||||
def test_a():
|
||||
|
@ -1,7 +1,7 @@
|
||||
###
|
||||
### non-unittest derived test -- class is instantiated, then functions
|
||||
### starting with 'test' are executed.
|
||||
### http://darcs.idyll.org/~t/projects/nose-demo/simple/tests/test_stuff.py.html
|
||||
## http://darcs.idyll.org/~t/projects/nose-demo/simple/tests/test_stuff.py.html
|
||||
###
|
||||
|
||||
import sys
|
||||
|
@ -1,6 +1,6 @@
|
||||
###
|
||||
### the standard unittest-derived test
|
||||
### http://darcs.idyll.org/~t/projects/nose-demo/simple/tests/test_stuff.py.html
|
||||
## http://darcs.idyll.org/~t/projects/nose-demo/simple/tests/test_stuff.py.html
|
||||
###
|
||||
|
||||
import sys
|
||||
|
Reference in New Issue
Block a user