Fix new pep8 warnings.

With the new release of pep8 we have some different requirements.
This patch fixes them all.

Change-Id: Ief16becba47007460f8b125907b055aa51de999e
Signed-off-by: Ian Main <imain@redhat.com>
changes/14/114/1
Ian Main 10 years ago
parent fdfb967cef
commit 6b0e7a4314
  1. 6
      bin/heat
  2. 4
      heat/api/v1/stacks.py
  3. 4
      heat/cfntools/cfn_helper.py
  4. 6
      heat/db/sqlalchemy/api.py
  5. 14
      heat/db/sqlalchemy/models.py
  6. 6
      heat/engine/checkeddict.py
  7. 2
      heat/engine/cloud_watch.py
  8. 10
      heat/engine/eip.py
  9. 2
      heat/engine/escalation_policy.py
  10. 8
      heat/engine/instance.py
  11. 6
      heat/engine/manager.py
  12. 8
      heat/engine/parser.py
  13. 4
      heat/engine/resources.py
  14. 4
      heat/engine/security_group.py
  15. 10
      heat/engine/volume.py
  16. 6
      heat/engine/wait_condition.py
  17. 2
      heat/metadata/api/v1/__init__.py
  18. 2
      heat/openstack/common/setup.py
  19. 2
      heat/tests/functional/test_bin_heat.py
  20. 6
      heat/tests/test_cfn.py
  21. 22
      heat/tests/test_resources.py
  22. 16
      heat/tests/test_stacks.py
  23. 14
      heat/tests/test_validate.py
  24. 30
      heat/utils.py

@ -422,14 +422,14 @@ def parse_options(parser, cli_args):
command = lookup_command(parser, command_name)
if options.debug:
logging.basicConfig(format='%(levelname)s:%(message)s',\
logging.basicConfig(format='%(levelname)s:%(message)s',
level=logging.DEBUG)
logging.debug("Debug level logging enabled")
elif options.verbose:
logging.basicConfig(format='%(levelname)s:%(message)s',\
logging.basicConfig(format='%(levelname)s:%(message)s',
level=logging.INFO)
else:
logging.basicConfig(format='%(levelname)s:%(message)s',\
logging.basicConfig(format='%(levelname)s:%(message)s',
level=logging.WARNING)
return (options, command, args)

@ -63,7 +63,7 @@ class StackController(object):
'ListStacksResult': {'StackSummaries': []}}}
results = res['ListStacksResponse']['ListStacksResult']
summaries = results['StackSummaries']
if stack_list != None:
if stack_list is not None:
for s in stack_list['stacks']:
summaries.append(s)
@ -193,7 +193,7 @@ class StackController(object):
except rpc_common.RemoteError as ex:
return webob.exc.HTTPBadRequest(str(ex))
if res == None:
if res is None:
return {'DeleteStackResult': ''}
else:
return {'DeleteStackResult': res['Error']}

@ -126,7 +126,7 @@ class Hook(object):
ev_name in self.triggers:
CommandRunner(self.action).run(user=self.runas)
else:
logger.debug('event: {%s, %s, %s} did not match %s' % \
logger.debug('event: {%s, %s, %s} did not match %s' %
(ev_name, ev_object, ev_resource, self.__str__()))
def __str__(self):
@ -428,7 +428,7 @@ class PackagesHandler(object):
# FIXME:print non-error, but skipping pkg
pass
elif not RpmHelper.yum_package_available(pkg):
logger.warn("Skipping package '%s'. Not available via yum" % \
logger.warn("Skipping package '%s'. Not available via yum" %
pkg)
elif not ver:
installs.append(pkg)

@ -144,7 +144,7 @@ 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 %s' % \
raise Exception('Attempt to delete a stack with id: %s %s' %
(stack_name, 'that does not exist'))
session = Session.object_session(s)
@ -220,7 +220,7 @@ def watch_rule_delete(context, watch_name):
filter_by(name=watch_name).first()
if not wr:
raise Exception('Attempt to delete a watch_rule with name: %s %s' % \
raise Exception('Attempt to delete a watch_rule with name: %s %s' %
(watch_name, 'that does not exist'))
session = Session.object_session(wr)
@ -251,7 +251,7 @@ def watch_data_delete(context, watch_name):
filter_by(name=watch_name).all()
if not ds:
raise Exception('Attempt to delete watch_data with name: %s %s' % \
raise Exception('Attempt to delete watch_data with name: %s %s' %
(watch_name, 'that does not exist'))
session = Session.object_session(ds)

@ -116,7 +116,7 @@ class RawTemplate(BASE, HeatBase):
__tablename__ = 'raw_template'
id = Column(Integer, primary_key=True)
template = Column(Json)
parsed_template = relationship("ParsedTemplate",\
parsed_template = relationship("ParsedTemplate",
uselist=False, backref="raw_template")
@ -126,7 +126,7 @@ class ParsedTemplate(BASE, HeatBase):
__tablename__ = 'parsed_template'
id = Column(Integer, primary_key=True)
template = Column(Json)
raw_template_id = Column(Integer, ForeignKey('raw_template.id'),\
raw_template_id = Column(Integer, ForeignKey('raw_template.id'),
nullable=False)
@ -137,7 +137,7 @@ class Stack(BASE, HeatBase):
id = Column(Integer, primary_key=True)
name = Column(String, unique=True)
raw_template_id = Column(Integer, ForeignKey('raw_template.id'),\
raw_template_id = Column(Integer, ForeignKey('raw_template.id'),
nullable=False)
raw_template = relationship(RawTemplate,
backref=backref('stack'))
@ -149,7 +149,7 @@ class Event(BASE, HeatBase):
__tablename__ = 'event'
id = Column(Integer, primary_key=True)
stack_id = Column(Integer, ForeignKey('stack.id'),\
stack_id = Column(Integer, ForeignKey('stack.id'),
nullable=False)
stack = relationship(Stack,
backref=backref('events'))
@ -172,12 +172,12 @@ class Resource(BASE, HeatBase):
name = Column('name', String, nullable=False)
nova_instance = Column('nova_instance', String)
state_description = Column('state_description', String)
parsed_template_id = Column(Integer, ForeignKey('parsed_template.id'),\
parsed_template_id = Column(Integer, ForeignKey('parsed_template.id'),
nullable=True)
parsed_template = relationship(ParsedTemplate,
backref=backref('resources'))
stack_id = Column(Integer, ForeignKey('stack.id'),\
stack_id = Column(Integer, ForeignKey('stack.id'),
nullable=False)
stack = relationship(Stack, backref=backref('resources'))
@ -205,6 +205,6 @@ class WatchData(BASE, HeatBase):
id = Column(Integer, primary_key=True)
data = Column('data', Json)
watch_rule_id = Column(Integer, ForeignKey('watch_rule.id'),\
watch_rule_id = Column(Integer, ForeignKey('watch_rule.id'),
nullable=False)
watch_rule = relationship(WatchRule, backref=backref('watch_data'))

@ -69,7 +69,7 @@ class CheckedDict(collections.MutableMapping):
if 'AllowedPattern' in self.data[key]:
rc = re.match('^%s$' % self.data[key]['AllowedPattern'],
value)
if rc == None:
if rc is None:
raise ValueError('%s: Pattern %s does not match %s' %
(self.name,
self.data[key]['AllowedPattern'],
@ -154,11 +154,11 @@ class Properties(CheckedDict):
if 'Required' in self.data[key]:
if self.data[key]['Required'] \
and not 'Value' in self.data[key]:
return {'Error': \
return {'Error':
'%s Property must be provided' % key}
# are there unimplemented Properties
if not self.data[key]['Implemented'] and 'Value' in self.data[key]:
return {'Error': \
return {'Error':
'%s Property not implemented yet' % key}
return None

@ -61,7 +61,7 @@ class CloudWatchAlarm(Resource):
return Resource.validate(self)
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)

@ -32,7 +32,7 @@ class ElasticIp(Resource):
def create(self):
"""Allocate a floating IP for the current tenant."""
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
super(ElasticIp, self).create()
@ -53,7 +53,7 @@ class ElasticIp(Resource):
'''
get the ipaddress here
'''
if self.instance_id != None:
if self.instance_id is not None:
try:
ips = self.nova().floating_ips.get(self.instance_id)
self.ipaddress = ips.ip
@ -71,7 +71,7 @@ class ElasticIp(Resource):
self.state_set(self.DELETE_IN_PROGRESS)
Resource.delete(self)
if self.instance_id != None:
if self.instance_id is not None:
self.nova().floating_ips.delete(self.instance_id)
self.state_set(self.DELETE_COMPLETE)
@ -112,12 +112,12 @@ class ElasticIpAssociation(Resource):
def create(self):
"""Add a floating IP address to a server."""
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
super(ElasticIpAssociation, self).create()
logger.debug('ElasticIpAssociation %s.add_floating_ip(%s)' % \
logger.debug('ElasticIpAssociation %s.add_floating_ip(%s)' %
(self.properties['InstanceId'],
self.properties['EIP']))

@ -41,7 +41,7 @@ class EscalationPolicy(Resource):
return Resource.validate(self)
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)

@ -49,7 +49,7 @@ class Restarter(Resource):
super(Restarter, self).__init__(name, json_snippet, stack)
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)
@ -64,7 +64,7 @@ class Restarter(Resource):
self.state_set(self.DELETE_COMPLETE)
def alarm(self):
logger.notice('%s Alarm, restarting resource: %s' % \
logger.notice('%s Alarm, restarting resource: %s' %
(self.name, self.properties['InstanceId']))
self.stack.restart_resource(self.properties['InstanceId'])
@ -191,7 +191,7 @@ class Instance(Resource):
"""
pass
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)
@ -255,7 +255,7 @@ class Instance(Resource):
if k.name == self.stack.parms['KeyName']:
valid_key = True
if not valid_key:
return {'Error': \
return {'Error':
'Provided KeyName is not registered with nova'}
return None

@ -75,7 +75,7 @@ class EngineManager(manager.Manager):
res = {'stacks': []}
stacks = db_api.stack_get_all(None)
if stacks == None:
if stacks is None:
return res
for s in stacks:
ps = parser.Stack(context, s.name,
@ -181,7 +181,7 @@ class EngineManager(manager.Manager):
stack.parsed_template_id = new_pt.id
stack.create()
return {'stack': {'id': new_s.id, 'name': new_s.name,\
return {'stack': {'id': new_s.id, 'name': new_s.name,
'created_at': str(new_s.created_at)}}
def validate_template(self, context, template, params):
@ -432,7 +432,7 @@ class EngineManager(manager.Manager):
alarming = self.do_data_cmp(wr.rule, data,
int(wr.rule['Threshold']))
logger.debug('%s: %d/%d => %d (current state:%s)' % \
logger.debug('%s: %d/%d => %d (current state:%s)' %
(wr.rule['MetricName'],
int(wr.rule['Threshold']),
data, alarming, wr.state))

@ -64,7 +64,7 @@ class Stack(object):
self.parms.addschema(p, ps[p])
# user Parameters
if parms != None:
if parms is not None:
self._apply_user_parameters(parms)
self.resources = {}
@ -107,7 +107,7 @@ class Stack(object):
'Parameters': []}}
return response
if response == None:
if response is None:
response = {'ValidateTemplateResult': {
'Description': 'Successfully validated',
'Parameters': []}}
@ -164,7 +164,7 @@ class Stack(object):
if pt:
pt.update_and_save({'template': self.t.copy()})
else:
logger.warn('Cant find parsed template to update %d' % \
logger.warn('Cant find parsed template to update %d' %
self.parsed_template_id)
def status_set(self, new_status, reason='change in resource state'):
@ -320,7 +320,7 @@ class Stack(object):
try:
key_name = 'Parameters.member.%s.ParameterKey' % s[2]
value_name = 'Parameters.member.%s.ParameterValue' % s[2]
logger.debug('appling user parameter %s=%s' % \
logger.debug('appling user parameter %s=%s' %
(key_name, value_name))
self.parms[parms[key_name]] = parms[value_name]
except Exception:

@ -191,7 +191,7 @@ class Resource(object):
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ \
intrinsic-function-reference-ref.html
'''
if self.instance_id != None:
if self.instance_id is not None:
return unicode(self.instance_id)
else:
return unicode(self.name)
@ -224,7 +224,7 @@ class GenericResource(Resource):
super(GenericResource, self).__init__(name, json_snippet, stack)
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
super(GenericResource, self).create()

@ -35,7 +35,7 @@ class SecurityGroup(Resource):
super(SecurityGroup, self).__init__(name, json_snippet, stack)
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)
@ -85,7 +85,7 @@ class SecurityGroup(Resource):
self.state_set(self.DELETE_IN_PROGRESS)
Resource.delete(self)
if self.instance_id != None:
if self.instance_id is not None:
try:
sec = self.nova().security_groups.get(self.instance_id)
except NotFound:

@ -34,7 +34,7 @@ class Volume(Resource):
super(Volume, self).__init__(name, json_snippet, stack)
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
super(Volume, self).create()
@ -63,7 +63,7 @@ class Volume(Resource):
self.state == self.DELETE_COMPLETE:
return
if self.instance_id != None:
if self.instance_id is not None:
vol = self.nova('volume').volumes.get(self.instance_id)
if vol.status == 'in-use':
logger.warn('cant delete volume when in-use')
@ -72,7 +72,7 @@ class Volume(Resource):
self.state_set(self.DELETE_IN_PROGRESS)
Resource.delete(self)
if self.instance_id != None:
if self.instance_id is not None:
self.nova('volume').volumes.delete(self.instance_id)
self.state_set(self.DELETE_COMPLETE)
@ -91,7 +91,7 @@ class VolumeAttachment(Resource):
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
super(VolumeAttachment, self).create()
@ -130,7 +130,7 @@ class VolumeAttachment(Resource):
server_id = self.properties['InstanceId']
volume_id = self.properties['VolumeId']
logger.info('VolumeAttachment un-attaching %s %s' % \
logger.info('VolumeAttachment un-attaching %s %s' %
(server_id, volume_id))
volapi = self.nova().volumes

@ -39,7 +39,7 @@ class WaitConditionHandle(Resource):
self.instance_id = ''
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)
@ -85,13 +85,13 @@ class WaitCondition(Resource):
self.count = int(self.t['Properties'].get('Count', '1'))
def _get_handle_resource_id(self):
if self.resource_id == None:
if self.resource_id is None:
self.handle_url = self.t['Properties'].get('Handle', None)
self.resource_id = self.handle_url.split('/')[-1]
return self.resource_id
def create(self):
if self.state != None:
if self.state is not None:
return
self.state_set(self.CREATE_IN_PROGRESS)
Resource.create(self)

@ -46,7 +46,7 @@ class API(wsgi.Router):
controller=metadata_controller, action='create_stack',
conditions=dict(method=['PUT']))
mapper.connect('/stacks/:stack_name/resources/:resource_id',
controller=metadata_controller,\
controller=metadata_controller,
action='update_metadata',
conditions=dict(method=['PUT']))
mapper.connect('/events/',

@ -33,7 +33,7 @@ def parse_mailmap(mailmap='.mailmap'):
for l in fp:
l = l.strip()
if not l.startswith('#') and ' ' in l:
canonical_email, alias = [x for x in l.split(' ') \
canonical_email, alias = [x for x in l.split(' ')
if x.startswith('<')]
mapping[alias] = canonical_email
return mapping

@ -107,7 +107,7 @@ class TestBinHeat():
print "Waiting for OpenStack to initialize and assign network address"
ip = None
tries = 0
while ip == None:
while ip is None:
tries += 1
assert tries < 500
time.sleep(10)

@ -117,7 +117,7 @@ runas=root
def tearDown_metadata_files():
shutil.rmtree('/tmp/_files_test_',\
shutil.rmtree('/tmp/_files_test_',
ignore_errors=True)
@ -183,8 +183,8 @@ class MetadataTest(unittest.TestCase):
self.m.StubOutWithMock(os, 'chmod')
subprocess.Popen(['su', 'root', '-c',
'wget -O /tmp/CloudFormationRailsSample.zip ' + \
'https://s3.amazonaws.com/cloudformation-' + \
'wget -O /tmp/CloudFormationRailsSample.zip ' +
'https://s3.amazonaws.com/cloudformation-' +
'examples/CloudFormationRailsSample.zip'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).AndReturn(PopenMock())

@ -41,7 +41,7 @@ class instancesTest(unittest.TestCase):
stack = parser.Stack(None, 'test_stack', t, 0, params)
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',\
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',
stack).AndReturn(None)
self.m.StubOutWithMock(instances.Instance, 'nova')
@ -55,7 +55,7 @@ class instancesTest(unittest.TestCase):
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['InstanceType'] = \
'256 MB Server'
instance = instances.Instance('test_resource_name',\
instance = instances.Instance('test_resource_name',
t['Resources']['WebServer'], stack)
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
@ -64,11 +64,11 @@ class instancesTest(unittest.TestCase):
instance.stack.resolve_base64(instance.t)
# need to resolve the template functions
server_userdata = instance._build_userdata(\
server_userdata = instance._build_userdata(
instance.t['Properties']['UserData'])
self.m.StubOutWithMock(self.fc.servers, 'create')
self.fc.servers.create(image=1, flavor=1, key_name='test',\
name='test_resource_name', security_groups=None,\
self.fc.servers.create(image=1, flavor=1, key_name='test',
name='test_resource_name', security_groups=None,
userdata=server_userdata).\
AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
@ -91,7 +91,7 @@ class instancesTest(unittest.TestCase):
stack = parser.Stack(None, 'test_stack', t, 0, params)
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',\
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',
stack).AndReturn(None)
self.m.StubOutWithMock(instances.Instance, 'nova')
@ -105,7 +105,7 @@ class instancesTest(unittest.TestCase):
t['Resources']['WebServer']['Properties']['ImageId'] = 'CentOS 5.2'
t['Resources']['WebServer']['Properties']['InstanceType'] = \
'256 MB Server'
instance = instances.Instance('test_resource_name',\
instance = instances.Instance('test_resource_name',
t['Resources']['WebServer'], stack)
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
@ -114,11 +114,11 @@ class instancesTest(unittest.TestCase):
instance.stack.resolve_base64(instance.t)
# need to resolve the template functions
server_userdata = instance._build_userdata(\
server_userdata = instance._build_userdata(
instance.t['Properties']['UserData'])
self.m.StubOutWithMock(self.fc.servers, 'create')
self.fc.servers.create(image=1, flavor=1, key_name='test',\
name='test_resource_name', security_groups=None,\
self.fc.servers.create(image=1, flavor=1, key_name='test',
name='test_resource_name', security_groups=None,
userdata=server_userdata).\
AndReturn(self.fc.servers.list()[1])
self.m.ReplayAll()
@ -131,7 +131,7 @@ class instancesTest(unittest.TestCase):
assert(instance.id > 0)
instance.delete()
assert(instance.instance_id == None)
assert(instance.instance_id is None)
assert(instance.state == instance.DELETE_COMPLETE)
# allows testing of the test directly, shown below

@ -48,11 +48,11 @@ class stacksTest(unittest.TestCase):
instance.stack.resolve_attributes(instance.t)
instance.stack.resolve_joins(instance.t)
instance.stack.resolve_base64(instance.t)
server_userdata = instance._build_userdata(\
server_userdata = instance._build_userdata(
instance.t['Properties']['UserData'])
self.m.StubOutWithMock(self.fc.servers, 'create')
self.fc.servers.create(image=744, flavor=3, key_name='test',\
name='WebServer', security_groups=None,\
self.fc.servers.create(image=744, flavor=3, key_name='test',
name='WebServer', security_groups=None,
userdata=server_userdata).\
AndReturn(self.fc.servers.list()[-1])
return stack
@ -61,7 +61,7 @@ class stacksTest(unittest.TestCase):
stack = self.start_wordpress_stack('test_stack')
self.m.ReplayAll()
stack.create_blocking()
assert(stack.resources['WebServer'] != None)
assert(stack.resources['WebServer'] is not None)
assert(stack.resources['WebServer'].instance_id > 0)
assert(stack.resources['WebServer'].ipaddress != '0.0.0.0')
@ -82,7 +82,7 @@ class stacksTest(unittest.TestCase):
pt['raw_template_id'] = new_rt.id
new_pt = db_api.parsed_template_create(None, pt)
stack.create_blocking()
assert(stack.resources['WebServer'] != None)
assert(stack.resources['WebServer'] is not None)
assert(stack.resources['WebServer'].instance_id > 0)
stack.delete_blocking()
assert(stack.resources['WebServer'].state == 'DELETE_COMPLETE')
@ -105,7 +105,7 @@ class stacksTest(unittest.TestCase):
pt['raw_template_id'] = new_rt.id
new_pt = db_api.parsed_template_create(None, pt)
stack.create_blocking()
assert(stack.resources['WebServer'] != None)
assert(stack.resources['WebServer'] is not None)
assert(stack.resources['WebServer'].instance_id > 0)
m = manager.EngineManager()
@ -122,9 +122,9 @@ class stacksTest(unittest.TestCase):
assert(result['LogicalResourceId'] == 'WebServer')
# Big long user data field.. it mentions 'wordpress'
# a few times so this should work.
assert(result['ResourceProperties']['UserData'].find('wordpress')\
assert(result['ResourceProperties']['UserData'].find('wordpress')
!= -1)
assert(result['ResourceProperties']['ImageId']\
assert(result['ResourceProperties']['ImageId']
== 'F16-x86_64-gold')
assert(result['ResourceProperties']['InstanceType'] == 'm1.large')

@ -218,7 +218,7 @@ class validateTest(unittest.TestCase):
stack = parser.Stack(None, 'test_stack', t, 0, params)
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',\
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',
stack).AndReturn(None)
self.m.ReplayAll()
@ -226,7 +226,7 @@ class validateTest(unittest.TestCase):
stack.resolve_attributes(volumeattach.t)
stack.resolve_joins(volumeattach.t)
stack.resolve_base64(volumeattach.t)
assert(volumeattach.validate() == None)
assert(volumeattach.validate() is None)
def test_validate_volumeattach_invalid(self):
t = json.loads(test_template_volumeattach % 'sda')
@ -236,7 +236,7 @@ class validateTest(unittest.TestCase):
stack = parser.Stack(None, 'test_stack', t, 0, params)
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',\
db_api.resource_get_by_name_and_stack(None, 'test_resource_name',
stack).AndReturn(None)
self.m.ReplayAll()
@ -258,7 +258,7 @@ class validateTest(unittest.TestCase):
self.m.ReplayAll()
manager = managers.EngineManager()
res = dict(manager.\
res = dict(manager.
validate_template(None, t, params)['ValidateTemplateResult'])
print 'res %s' % res
assert (res['Description'] == 'Successfully validated')
@ -275,7 +275,7 @@ class validateTest(unittest.TestCase):
self.m.ReplayAll()
manager = managers.EngineManager()
res = dict(manager.\
res = dict(manager.
validate_template(None, t, params)['ValidateTemplateResult'])
assert (res['Description'] != 'Successfully validated')
@ -291,7 +291,7 @@ class validateTest(unittest.TestCase):
self.m.ReplayAll()
manager = managers.EngineManager()
res = dict(manager.\
res = dict(manager.
validate_template(None, t, params)['ValidateTemplateResult'])
assert (res['Description'] == 'Successfully validated')
@ -307,7 +307,7 @@ class validateTest(unittest.TestCase):
self.m.ReplayAll()
manager = managers.EngineManager()
res = dict(manager.\
res = dict(manager.
validate_template(None, t, params)['ValidateTemplateResult'])
assert (res['Description'] != 'Successfully validated')

@ -39,8 +39,8 @@ def catch_error(action):
ret = func(*arguments, **kwargs)
return SUCCESS if ret is None else ret
except exception.NotAuthorized:
logging.error("Not authorized to make this request. Check " +\
"your credentials (OS_USERNAME, OS_PASSWORD, " +\
logging.error("Not authorized to make this request. Check " +
"your credentials (OS_USERNAME, OS_PASSWORD, " +
"OS_TENANT_NAME, OS_AUTH_URL and OS_AUTH_STRATEGY).")
return FAILURE
except exception.ClientConfigurationError:
@ -107,9 +107,9 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
sys.exit(1)
if not instance_type in instance_types:
logging.error('A JEOS instance type of %s not supported' %\
logging.error('A JEOS instance type of %s not supported' %
instance_type)
logging.error('try: heat jeos-create %s %s [ %s ]' %\
logging.error('try: heat jeos-create %s %s [ %s ]' %
(distro, arch, instances_str))
sys.exit(1)
@ -188,8 +188,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
runoz = options.yes and 'y' or None
if os.access(qcow2_filename, os.R_OK):
while runoz not in ('y', 'n'):
runoz = raw_input('An existing JEOS was found on disk.' \
' Do you want to build a fresh JEOS?' \
runoz = raw_input('An existing JEOS was found on disk.'
' Do you want to build a fresh JEOS?'
' (y/n) ').lower()
if runoz == 'y':
os.remove(qcow2_filename)
@ -199,7 +199,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
elif runoz == 'n':
answer = None
while answer not in ('y', 'n'):
answer = raw_input('Do you want to register your existing' \
answer = raw_input('Do you want to register your existing'
' JEOS file with glance? (y/n) ').lower()
if answer == 'n':
logging.info('No action taken')
@ -207,8 +207,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
elif answer == 'y' and image_registered:
answer = None
while answer not in ('y', 'n'):
answer = raw_input('Do you want to delete the ' \
'existing JEOS in glance?' \
answer = raw_input('Do you want to delete the '
'existing JEOS in glance?'
' (y/n) ').lower()
if answer == 'n':
logging.info('No action taken')
@ -216,8 +216,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
elif answer == 'y':
client.delete_image(image['id'])
if runoz == None or runoz == 'y':
logging.info('Creating JEOS image (%s) - '\
if runoz is None or runoz == 'y':
logging.info('Creating JEOS image (%s) - '
'this takes approximately 10 minutes.' % image_name)
extra_opts = ' '
if options.debug:
@ -230,7 +230,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
if res == 256:
sys.exit(1)
if not os.access(dsk_filename, os.R_OK):
logging.error('oz-install did not create the image,' \
logging.error('oz-install did not create the image,'
' check your oz installation.')
sys.exit(1)
@ -238,7 +238,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
os.system("qemu-img convert -c -O qcow2 %s %s" % (dsk_filename,
qcow2_filename))
logging.info('Registering JEOS image (%s) ' \
logging.info('Registering JEOS image (%s) '
'with OpenStack Glance.' % image_name)
image_meta = {'name': image_name,
@ -258,7 +258,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
for k, v in sorted(image_meta.items()):
logging.debug(" %(k)30s => %(v)s" % locals())
except exception.ClientConnectionError, e:
logging.error((" Failed to connect to the Glance API server." +\
logging.error((" Failed to connect to the Glance API server." +
" Is the server running?" % locals()))
pieces = unicode(e).split('\n')
for piece in pieces:
@ -269,7 +269,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
pieces = unicode(e).split('\n')
for piece in pieces:
logging.error(piece)
logging.warning(" Note: Your image metadata may still be in the " +\
logging.warning(" Note: Your image metadata may still be in the " +
"registry, but the image's status will likely be 'killed'.")

Loading…
Cancel
Save