]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
kill all pep8 errors in parser and resources
authorAngus Salkeld <asalkeld@redhat.com>
Tue, 17 Apr 2012 01:58:57 +0000 (11:58 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Tue, 17 Apr 2012 02:10:44 +0000 (12:10 +1000)
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/db/sqlalchemy/api.py
heat/engine/parser.py
heat/engine/resources.py
heat/rpc/impl_qpid.py
heat/tests/examples/__init__.py
heat/tests/examples/test1.py
heat/tests/examples/test2.py
heat/tests/examples/test3.py

index a1334f1d163589a3e63495a86d9a9b38fe1bbebc..657f704b7936725b87793248214f3a56ed89c18e 100644 (file)
@@ -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)
 
index eac2a90b2b6c2893e6a733fd89b0fe32f064de7f..6da62079a97b07b43bf396dc6bc0ef722c827325 100644 (file)
@@ -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:
index 6be99715ebde776e6104acc2c0a220dfb7826902..2b1475b8db2979b273e7859f2955c3400eb59f47 100644 (file)
@@ -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':
index 7c492c681f2197b1d4b63bb7a6e0a2429b3d0865..7602cf1d48841048530fa079effe3f378faf1d12 100644 (file)
@@ -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
index cc9a23905fe03e1133b5712cef184a7f12e3b8f5..3fe375cc97e82ee25611fd73f202af8d35318c06 100644 (file)
@@ -1,5 +1,6 @@
 def setup():
     print "package setup complete"
 
+
 def teardown():
     print "package teardown complete"
index 0fc8d6c168e804e46f9409344f8c0669b05a08ef..9e75a01504f46c0971387a5036345e0fcc57f60b 100644 (file)
@@ -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():
index 1f1325dec8eb79fb9b875be6441ed8fd28f15d1f..632fc981795b32ddcb70cc3067e3bbec7cdbeb2b 100644 (file)
@@ -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
index 77191406d76ac54d1f790b5b264e99052b770b5b..714e18cd8d183bfbdfbf2e5e585bce44c874a212 100644 (file)
@@ -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