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>
This commit is contained in:
parent
fdfb967cef
commit
6b0e7a4314
6
bin/heat
6
bin/heat
@ -422,14 +422,14 @@ def parse_options(parser, cli_args):
|
|||||||
command = lookup_command(parser, command_name)
|
command = lookup_command(parser, command_name)
|
||||||
|
|
||||||
if options.debug:
|
if options.debug:
|
||||||
logging.basicConfig(format='%(levelname)s:%(message)s',\
|
logging.basicConfig(format='%(levelname)s:%(message)s',
|
||||||
level=logging.DEBUG)
|
level=logging.DEBUG)
|
||||||
logging.debug("Debug level logging enabled")
|
logging.debug("Debug level logging enabled")
|
||||||
elif options.verbose:
|
elif options.verbose:
|
||||||
logging.basicConfig(format='%(levelname)s:%(message)s',\
|
logging.basicConfig(format='%(levelname)s:%(message)s',
|
||||||
level=logging.INFO)
|
level=logging.INFO)
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(format='%(levelname)s:%(message)s',\
|
logging.basicConfig(format='%(levelname)s:%(message)s',
|
||||||
level=logging.WARNING)
|
level=logging.WARNING)
|
||||||
|
|
||||||
return (options, command, args)
|
return (options, command, args)
|
||||||
|
@ -63,7 +63,7 @@ class StackController(object):
|
|||||||
'ListStacksResult': {'StackSummaries': []}}}
|
'ListStacksResult': {'StackSummaries': []}}}
|
||||||
results = res['ListStacksResponse']['ListStacksResult']
|
results = res['ListStacksResponse']['ListStacksResult']
|
||||||
summaries = results['StackSummaries']
|
summaries = results['StackSummaries']
|
||||||
if stack_list != None:
|
if stack_list is not None:
|
||||||
for s in stack_list['stacks']:
|
for s in stack_list['stacks']:
|
||||||
summaries.append(s)
|
summaries.append(s)
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class StackController(object):
|
|||||||
except rpc_common.RemoteError as ex:
|
except rpc_common.RemoteError as ex:
|
||||||
return webob.exc.HTTPBadRequest(str(ex))
|
return webob.exc.HTTPBadRequest(str(ex))
|
||||||
|
|
||||||
if res == None:
|
if res is None:
|
||||||
return {'DeleteStackResult': ''}
|
return {'DeleteStackResult': ''}
|
||||||
else:
|
else:
|
||||||
return {'DeleteStackResult': res['Error']}
|
return {'DeleteStackResult': res['Error']}
|
||||||
|
@ -126,7 +126,7 @@ class Hook(object):
|
|||||||
ev_name in self.triggers:
|
ev_name in self.triggers:
|
||||||
CommandRunner(self.action).run(user=self.runas)
|
CommandRunner(self.action).run(user=self.runas)
|
||||||
else:
|
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__()))
|
(ev_name, ev_object, ev_resource, self.__str__()))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -428,7 +428,7 @@ class PackagesHandler(object):
|
|||||||
# FIXME:print non-error, but skipping pkg
|
# FIXME:print non-error, but skipping pkg
|
||||||
pass
|
pass
|
||||||
elif not RpmHelper.yum_package_available(pkg):
|
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)
|
pkg)
|
||||||
elif not ver:
|
elif not ver:
|
||||||
installs.append(pkg)
|
installs.append(pkg)
|
||||||
|
@ -144,7 +144,7 @@ def stack_create(context, values):
|
|||||||
def stack_delete(context, stack_name):
|
def stack_delete(context, stack_name):
|
||||||
s = stack_get(context, stack_name)
|
s = stack_get(context, stack_name)
|
||||||
if not s:
|
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'))
|
(stack_name, 'that does not exist'))
|
||||||
|
|
||||||
session = Session.object_session(s)
|
session = Session.object_session(s)
|
||||||
@ -220,7 +220,7 @@ def watch_rule_delete(context, watch_name):
|
|||||||
filter_by(name=watch_name).first()
|
filter_by(name=watch_name).first()
|
||||||
|
|
||||||
if not wr:
|
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'))
|
(watch_name, 'that does not exist'))
|
||||||
|
|
||||||
session = Session.object_session(wr)
|
session = Session.object_session(wr)
|
||||||
@ -251,7 +251,7 @@ def watch_data_delete(context, watch_name):
|
|||||||
filter_by(name=watch_name).all()
|
filter_by(name=watch_name).all()
|
||||||
|
|
||||||
if not ds:
|
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'))
|
(watch_name, 'that does not exist'))
|
||||||
|
|
||||||
session = Session.object_session(ds)
|
session = Session.object_session(ds)
|
||||||
|
@ -116,7 +116,7 @@ class RawTemplate(BASE, HeatBase):
|
|||||||
__tablename__ = 'raw_template'
|
__tablename__ = 'raw_template'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
template = Column(Json)
|
template = Column(Json)
|
||||||
parsed_template = relationship("ParsedTemplate",\
|
parsed_template = relationship("ParsedTemplate",
|
||||||
uselist=False, backref="raw_template")
|
uselist=False, backref="raw_template")
|
||||||
|
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class ParsedTemplate(BASE, HeatBase):
|
|||||||
__tablename__ = 'parsed_template'
|
__tablename__ = 'parsed_template'
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
template = Column(Json)
|
template = Column(Json)
|
||||||
raw_template_id = Column(Integer, ForeignKey('raw_template.id'),\
|
raw_template_id = Column(Integer, ForeignKey('raw_template.id'),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class Stack(BASE, HeatBase):
|
|||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
name = Column(String, unique=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)
|
nullable=False)
|
||||||
raw_template = relationship(RawTemplate,
|
raw_template = relationship(RawTemplate,
|
||||||
backref=backref('stack'))
|
backref=backref('stack'))
|
||||||
@ -149,7 +149,7 @@ class Event(BASE, HeatBase):
|
|||||||
__tablename__ = 'event'
|
__tablename__ = 'event'
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
stack_id = Column(Integer, ForeignKey('stack.id'),\
|
stack_id = Column(Integer, ForeignKey('stack.id'),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
stack = relationship(Stack,
|
stack = relationship(Stack,
|
||||||
backref=backref('events'))
|
backref=backref('events'))
|
||||||
@ -172,12 +172,12 @@ class Resource(BASE, HeatBase):
|
|||||||
name = Column('name', String, nullable=False)
|
name = Column('name', String, nullable=False)
|
||||||
nova_instance = Column('nova_instance', String)
|
nova_instance = Column('nova_instance', String)
|
||||||
state_description = Column('state_description', 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)
|
nullable=True)
|
||||||
parsed_template = relationship(ParsedTemplate,
|
parsed_template = relationship(ParsedTemplate,
|
||||||
backref=backref('resources'))
|
backref=backref('resources'))
|
||||||
|
|
||||||
stack_id = Column(Integer, ForeignKey('stack.id'),\
|
stack_id = Column(Integer, ForeignKey('stack.id'),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
stack = relationship(Stack, backref=backref('resources'))
|
stack = relationship(Stack, backref=backref('resources'))
|
||||||
|
|
||||||
@ -205,6 +205,6 @@ class WatchData(BASE, HeatBase):
|
|||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
data = Column('data', Json)
|
data = Column('data', Json)
|
||||||
|
|
||||||
watch_rule_id = Column(Integer, ForeignKey('watch_rule.id'),\
|
watch_rule_id = Column(Integer, ForeignKey('watch_rule.id'),
|
||||||
nullable=False)
|
nullable=False)
|
||||||
watch_rule = relationship(WatchRule, backref=backref('watch_data'))
|
watch_rule = relationship(WatchRule, backref=backref('watch_data'))
|
||||||
|
@ -69,7 +69,7 @@ class CheckedDict(collections.MutableMapping):
|
|||||||
if 'AllowedPattern' in self.data[key]:
|
if 'AllowedPattern' in self.data[key]:
|
||||||
rc = re.match('^%s$' % self.data[key]['AllowedPattern'],
|
rc = re.match('^%s$' % self.data[key]['AllowedPattern'],
|
||||||
value)
|
value)
|
||||||
if rc == None:
|
if rc is None:
|
||||||
raise ValueError('%s: Pattern %s does not match %s' %
|
raise ValueError('%s: Pattern %s does not match %s' %
|
||||||
(self.name,
|
(self.name,
|
||||||
self.data[key]['AllowedPattern'],
|
self.data[key]['AllowedPattern'],
|
||||||
@ -154,11 +154,11 @@ class Properties(CheckedDict):
|
|||||||
if 'Required' in self.data[key]:
|
if 'Required' in self.data[key]:
|
||||||
if self.data[key]['Required'] \
|
if self.data[key]['Required'] \
|
||||||
and not 'Value' in self.data[key]:
|
and not 'Value' in self.data[key]:
|
||||||
return {'Error': \
|
return {'Error':
|
||||||
'%s Property must be provided' % key}
|
'%s Property must be provided' % key}
|
||||||
|
|
||||||
# are there unimplemented Properties
|
# are there unimplemented Properties
|
||||||
if not self.data[key]['Implemented'] and 'Value' in self.data[key]:
|
if not self.data[key]['Implemented'] and 'Value' in self.data[key]:
|
||||||
return {'Error': \
|
return {'Error':
|
||||||
'%s Property not implemented yet' % key}
|
'%s Property not implemented yet' % key}
|
||||||
return None
|
return None
|
||||||
|
@ -61,7 +61,7 @@ class CloudWatchAlarm(Resource):
|
|||||||
return Resource.validate(self)
|
return Resource.validate(self)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
|
@ -32,7 +32,7 @@ class ElasticIp(Resource):
|
|||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
"""Allocate a floating IP for the current tenant."""
|
"""Allocate a floating IP for the current tenant."""
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
super(ElasticIp, self).create()
|
super(ElasticIp, self).create()
|
||||||
@ -53,7 +53,7 @@ class ElasticIp(Resource):
|
|||||||
'''
|
'''
|
||||||
get the ipaddress here
|
get the ipaddress here
|
||||||
'''
|
'''
|
||||||
if self.instance_id != None:
|
if self.instance_id is not None:
|
||||||
try:
|
try:
|
||||||
ips = self.nova().floating_ips.get(self.instance_id)
|
ips = self.nova().floating_ips.get(self.instance_id)
|
||||||
self.ipaddress = ips.ip
|
self.ipaddress = ips.ip
|
||||||
@ -71,7 +71,7 @@ class ElasticIp(Resource):
|
|||||||
self.state_set(self.DELETE_IN_PROGRESS)
|
self.state_set(self.DELETE_IN_PROGRESS)
|
||||||
Resource.delete(self)
|
Resource.delete(self)
|
||||||
|
|
||||||
if self.instance_id != None:
|
if self.instance_id is not None:
|
||||||
self.nova().floating_ips.delete(self.instance_id)
|
self.nova().floating_ips.delete(self.instance_id)
|
||||||
|
|
||||||
self.state_set(self.DELETE_COMPLETE)
|
self.state_set(self.DELETE_COMPLETE)
|
||||||
@ -112,12 +112,12 @@ class ElasticIpAssociation(Resource):
|
|||||||
def create(self):
|
def create(self):
|
||||||
"""Add a floating IP address to a server."""
|
"""Add a floating IP address to a server."""
|
||||||
|
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
super(ElasticIpAssociation, self).create()
|
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['InstanceId'],
|
||||||
self.properties['EIP']))
|
self.properties['EIP']))
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class EscalationPolicy(Resource):
|
|||||||
return Resource.validate(self)
|
return Resource.validate(self)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
|
@ -49,7 +49,7 @@ class Restarter(Resource):
|
|||||||
super(Restarter, self).__init__(name, json_snippet, stack)
|
super(Restarter, self).__init__(name, json_snippet, stack)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
@ -64,7 +64,7 @@ class Restarter(Resource):
|
|||||||
self.state_set(self.DELETE_COMPLETE)
|
self.state_set(self.DELETE_COMPLETE)
|
||||||
|
|
||||||
def alarm(self):
|
def alarm(self):
|
||||||
logger.notice('%s Alarm, restarting resource: %s' % \
|
logger.notice('%s Alarm, restarting resource: %s' %
|
||||||
(self.name, self.properties['InstanceId']))
|
(self.name, self.properties['InstanceId']))
|
||||||
self.stack.restart_resource(self.properties['InstanceId'])
|
self.stack.restart_resource(self.properties['InstanceId'])
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ class Instance(Resource):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
@ -255,7 +255,7 @@ class Instance(Resource):
|
|||||||
if k.name == self.stack.parms['KeyName']:
|
if k.name == self.stack.parms['KeyName']:
|
||||||
valid_key = True
|
valid_key = True
|
||||||
if not valid_key:
|
if not valid_key:
|
||||||
return {'Error': \
|
return {'Error':
|
||||||
'Provided KeyName is not registered with nova'}
|
'Provided KeyName is not registered with nova'}
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class EngineManager(manager.Manager):
|
|||||||
|
|
||||||
res = {'stacks': []}
|
res = {'stacks': []}
|
||||||
stacks = db_api.stack_get_all(None)
|
stacks = db_api.stack_get_all(None)
|
||||||
if stacks == None:
|
if stacks is None:
|
||||||
return res
|
return res
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
ps = parser.Stack(context, s.name,
|
ps = parser.Stack(context, s.name,
|
||||||
@ -181,7 +181,7 @@ class EngineManager(manager.Manager):
|
|||||||
stack.parsed_template_id = new_pt.id
|
stack.parsed_template_id = new_pt.id
|
||||||
stack.create()
|
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)}}
|
'created_at': str(new_s.created_at)}}
|
||||||
|
|
||||||
def validate_template(self, context, template, params):
|
def validate_template(self, context, template, params):
|
||||||
@ -432,7 +432,7 @@ class EngineManager(manager.Manager):
|
|||||||
|
|
||||||
alarming = self.do_data_cmp(wr.rule, data,
|
alarming = self.do_data_cmp(wr.rule, data,
|
||||||
int(wr.rule['Threshold']))
|
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'],
|
(wr.rule['MetricName'],
|
||||||
int(wr.rule['Threshold']),
|
int(wr.rule['Threshold']),
|
||||||
data, alarming, wr.state))
|
data, alarming, wr.state))
|
||||||
|
@ -64,7 +64,7 @@ class Stack(object):
|
|||||||
self.parms.addschema(p, ps[p])
|
self.parms.addschema(p, ps[p])
|
||||||
|
|
||||||
# user Parameters
|
# user Parameters
|
||||||
if parms != None:
|
if parms is not None:
|
||||||
self._apply_user_parameters(parms)
|
self._apply_user_parameters(parms)
|
||||||
|
|
||||||
self.resources = {}
|
self.resources = {}
|
||||||
@ -107,7 +107,7 @@ class Stack(object):
|
|||||||
'Parameters': []}}
|
'Parameters': []}}
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if response == None:
|
if response is None:
|
||||||
response = {'ValidateTemplateResult': {
|
response = {'ValidateTemplateResult': {
|
||||||
'Description': 'Successfully validated',
|
'Description': 'Successfully validated',
|
||||||
'Parameters': []}}
|
'Parameters': []}}
|
||||||
@ -164,7 +164,7 @@ class Stack(object):
|
|||||||
if pt:
|
if pt:
|
||||||
pt.update_and_save({'template': self.t.copy()})
|
pt.update_and_save({'template': self.t.copy()})
|
||||||
else:
|
else:
|
||||||
logger.warn('Cant find parsed template to update %d' % \
|
logger.warn('Cant find parsed template to update %d' %
|
||||||
self.parsed_template_id)
|
self.parsed_template_id)
|
||||||
|
|
||||||
def status_set(self, new_status, reason='change in resource state'):
|
def status_set(self, new_status, reason='change in resource state'):
|
||||||
@ -320,7 +320,7 @@ class Stack(object):
|
|||||||
try:
|
try:
|
||||||
key_name = 'Parameters.member.%s.ParameterKey' % s[2]
|
key_name = 'Parameters.member.%s.ParameterKey' % s[2]
|
||||||
value_name = 'Parameters.member.%s.ParameterValue' % 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))
|
(key_name, value_name))
|
||||||
self.parms[parms[key_name]] = parms[value_name]
|
self.parms[parms[key_name]] = parms[value_name]
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -191,7 +191,7 @@ class Resource(object):
|
|||||||
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ \
|
http://docs.amazonwebservices.com/AWSCloudFormation/latest/UserGuide/ \
|
||||||
intrinsic-function-reference-ref.html
|
intrinsic-function-reference-ref.html
|
||||||
'''
|
'''
|
||||||
if self.instance_id != None:
|
if self.instance_id is not None:
|
||||||
return unicode(self.instance_id)
|
return unicode(self.instance_id)
|
||||||
else:
|
else:
|
||||||
return unicode(self.name)
|
return unicode(self.name)
|
||||||
@ -224,7 +224,7 @@ class GenericResource(Resource):
|
|||||||
super(GenericResource, self).__init__(name, json_snippet, stack)
|
super(GenericResource, self).__init__(name, json_snippet, stack)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
super(GenericResource, self).create()
|
super(GenericResource, self).create()
|
||||||
|
@ -35,7 +35,7 @@ class SecurityGroup(Resource):
|
|||||||
super(SecurityGroup, self).__init__(name, json_snippet, stack)
|
super(SecurityGroup, self).__init__(name, json_snippet, stack)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
@ -85,7 +85,7 @@ class SecurityGroup(Resource):
|
|||||||
self.state_set(self.DELETE_IN_PROGRESS)
|
self.state_set(self.DELETE_IN_PROGRESS)
|
||||||
Resource.delete(self)
|
Resource.delete(self)
|
||||||
|
|
||||||
if self.instance_id != None:
|
if self.instance_id is not None:
|
||||||
try:
|
try:
|
||||||
sec = self.nova().security_groups.get(self.instance_id)
|
sec = self.nova().security_groups.get(self.instance_id)
|
||||||
except NotFound:
|
except NotFound:
|
||||||
|
@ -34,7 +34,7 @@ class Volume(Resource):
|
|||||||
super(Volume, self).__init__(name, json_snippet, stack)
|
super(Volume, self).__init__(name, json_snippet, stack)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
super(Volume, self).create()
|
super(Volume, self).create()
|
||||||
@ -63,7 +63,7 @@ class Volume(Resource):
|
|||||||
self.state == self.DELETE_COMPLETE:
|
self.state == self.DELETE_COMPLETE:
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.instance_id != None:
|
if self.instance_id is not None:
|
||||||
vol = self.nova('volume').volumes.get(self.instance_id)
|
vol = self.nova('volume').volumes.get(self.instance_id)
|
||||||
if vol.status == 'in-use':
|
if vol.status == 'in-use':
|
||||||
logger.warn('cant delete volume when in-use')
|
logger.warn('cant delete volume when in-use')
|
||||||
@ -72,7 +72,7 @@ class Volume(Resource):
|
|||||||
self.state_set(self.DELETE_IN_PROGRESS)
|
self.state_set(self.DELETE_IN_PROGRESS)
|
||||||
Resource.delete(self)
|
Resource.delete(self)
|
||||||
|
|
||||||
if self.instance_id != None:
|
if self.instance_id is not None:
|
||||||
self.nova('volume').volumes.delete(self.instance_id)
|
self.nova('volume').volumes.delete(self.instance_id)
|
||||||
self.state_set(self.DELETE_COMPLETE)
|
self.state_set(self.DELETE_COMPLETE)
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class VolumeAttachment(Resource):
|
|||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
|
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
super(VolumeAttachment, self).create()
|
super(VolumeAttachment, self).create()
|
||||||
@ -130,7 +130,7 @@ class VolumeAttachment(Resource):
|
|||||||
|
|
||||||
server_id = self.properties['InstanceId']
|
server_id = self.properties['InstanceId']
|
||||||
volume_id = self.properties['VolumeId']
|
volume_id = self.properties['VolumeId']
|
||||||
logger.info('VolumeAttachment un-attaching %s %s' % \
|
logger.info('VolumeAttachment un-attaching %s %s' %
|
||||||
(server_id, volume_id))
|
(server_id, volume_id))
|
||||||
|
|
||||||
volapi = self.nova().volumes
|
volapi = self.nova().volumes
|
||||||
|
@ -39,7 +39,7 @@ class WaitConditionHandle(Resource):
|
|||||||
self.instance_id = ''
|
self.instance_id = ''
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
@ -85,13 +85,13 @@ class WaitCondition(Resource):
|
|||||||
self.count = int(self.t['Properties'].get('Count', '1'))
|
self.count = int(self.t['Properties'].get('Count', '1'))
|
||||||
|
|
||||||
def _get_handle_resource_id(self):
|
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.handle_url = self.t['Properties'].get('Handle', None)
|
||||||
self.resource_id = self.handle_url.split('/')[-1]
|
self.resource_id = self.handle_url.split('/')[-1]
|
||||||
return self.resource_id
|
return self.resource_id
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
if self.state != None:
|
if self.state is not None:
|
||||||
return
|
return
|
||||||
self.state_set(self.CREATE_IN_PROGRESS)
|
self.state_set(self.CREATE_IN_PROGRESS)
|
||||||
Resource.create(self)
|
Resource.create(self)
|
||||||
|
@ -46,7 +46,7 @@ class API(wsgi.Router):
|
|||||||
controller=metadata_controller, action='create_stack',
|
controller=metadata_controller, action='create_stack',
|
||||||
conditions=dict(method=['PUT']))
|
conditions=dict(method=['PUT']))
|
||||||
mapper.connect('/stacks/:stack_name/resources/:resource_id',
|
mapper.connect('/stacks/:stack_name/resources/:resource_id',
|
||||||
controller=metadata_controller,\
|
controller=metadata_controller,
|
||||||
action='update_metadata',
|
action='update_metadata',
|
||||||
conditions=dict(method=['PUT']))
|
conditions=dict(method=['PUT']))
|
||||||
mapper.connect('/events/',
|
mapper.connect('/events/',
|
||||||
|
@ -33,7 +33,7 @@ def parse_mailmap(mailmap='.mailmap'):
|
|||||||
for l in fp:
|
for l in fp:
|
||||||
l = l.strip()
|
l = l.strip()
|
||||||
if not l.startswith('#') and ' ' in l:
|
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('<')]
|
if x.startswith('<')]
|
||||||
mapping[alias] = canonical_email
|
mapping[alias] = canonical_email
|
||||||
return mapping
|
return mapping
|
||||||
|
@ -107,7 +107,7 @@ class TestBinHeat():
|
|||||||
print "Waiting for OpenStack to initialize and assign network address"
|
print "Waiting for OpenStack to initialize and assign network address"
|
||||||
ip = None
|
ip = None
|
||||||
tries = 0
|
tries = 0
|
||||||
while ip == None:
|
while ip is None:
|
||||||
tries += 1
|
tries += 1
|
||||||
assert tries < 500
|
assert tries < 500
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
@ -117,7 +117,7 @@ runas=root
|
|||||||
|
|
||||||
|
|
||||||
def tearDown_metadata_files():
|
def tearDown_metadata_files():
|
||||||
shutil.rmtree('/tmp/_files_test_',\
|
shutil.rmtree('/tmp/_files_test_',
|
||||||
ignore_errors=True)
|
ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
@ -183,8 +183,8 @@ class MetadataTest(unittest.TestCase):
|
|||||||
self.m.StubOutWithMock(os, 'chmod')
|
self.m.StubOutWithMock(os, 'chmod')
|
||||||
|
|
||||||
subprocess.Popen(['su', 'root', '-c',
|
subprocess.Popen(['su', 'root', '-c',
|
||||||
'wget -O /tmp/CloudFormationRailsSample.zip ' + \
|
'wget -O /tmp/CloudFormationRailsSample.zip ' +
|
||||||
'https://s3.amazonaws.com/cloudformation-' + \
|
'https://s3.amazonaws.com/cloudformation-' +
|
||||||
'examples/CloudFormationRailsSample.zip'],
|
'examples/CloudFormationRailsSample.zip'],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE).AndReturn(PopenMock())
|
stderr=subprocess.PIPE).AndReturn(PopenMock())
|
||||||
|
@ -41,7 +41,7 @@ class instancesTest(unittest.TestCase):
|
|||||||
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
||||||
|
|
||||||
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
|
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)
|
stack).AndReturn(None)
|
||||||
|
|
||||||
self.m.StubOutWithMock(instances.Instance, 'nova')
|
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']['ImageId'] = 'CentOS 5.2'
|
||||||
t['Resources']['WebServer']['Properties']['InstanceType'] = \
|
t['Resources']['WebServer']['Properties']['InstanceType'] = \
|
||||||
'256 MB Server'
|
'256 MB Server'
|
||||||
instance = instances.Instance('test_resource_name',\
|
instance = instances.Instance('test_resource_name',
|
||||||
t['Resources']['WebServer'], stack)
|
t['Resources']['WebServer'], stack)
|
||||||
|
|
||||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||||
@ -64,11 +64,11 @@ class instancesTest(unittest.TestCase):
|
|||||||
instance.stack.resolve_base64(instance.t)
|
instance.stack.resolve_base64(instance.t)
|
||||||
|
|
||||||
# need to resolve the template functions
|
# need to resolve the template functions
|
||||||
server_userdata = instance._build_userdata(\
|
server_userdata = instance._build_userdata(
|
||||||
instance.t['Properties']['UserData'])
|
instance.t['Properties']['UserData'])
|
||||||
self.m.StubOutWithMock(self.fc.servers, 'create')
|
self.m.StubOutWithMock(self.fc.servers, 'create')
|
||||||
self.fc.servers.create(image=1, flavor=1, key_name='test',\
|
self.fc.servers.create(image=1, flavor=1, key_name='test',
|
||||||
name='test_resource_name', security_groups=None,\
|
name='test_resource_name', security_groups=None,
|
||||||
userdata=server_userdata).\
|
userdata=server_userdata).\
|
||||||
AndReturn(self.fc.servers.list()[1])
|
AndReturn(self.fc.servers.list()[1])
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
@ -91,7 +91,7 @@ class instancesTest(unittest.TestCase):
|
|||||||
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
||||||
|
|
||||||
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
|
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)
|
stack).AndReturn(None)
|
||||||
|
|
||||||
self.m.StubOutWithMock(instances.Instance, 'nova')
|
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']['ImageId'] = 'CentOS 5.2'
|
||||||
t['Resources']['WebServer']['Properties']['InstanceType'] = \
|
t['Resources']['WebServer']['Properties']['InstanceType'] = \
|
||||||
'256 MB Server'
|
'256 MB Server'
|
||||||
instance = instances.Instance('test_resource_name',\
|
instance = instances.Instance('test_resource_name',
|
||||||
t['Resources']['WebServer'], stack)
|
t['Resources']['WebServer'], stack)
|
||||||
|
|
||||||
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
instance.itype_oflavor['256 MB Server'] = '256 MB Server'
|
||||||
@ -114,11 +114,11 @@ class instancesTest(unittest.TestCase):
|
|||||||
instance.stack.resolve_base64(instance.t)
|
instance.stack.resolve_base64(instance.t)
|
||||||
|
|
||||||
# need to resolve the template functions
|
# need to resolve the template functions
|
||||||
server_userdata = instance._build_userdata(\
|
server_userdata = instance._build_userdata(
|
||||||
instance.t['Properties']['UserData'])
|
instance.t['Properties']['UserData'])
|
||||||
self.m.StubOutWithMock(self.fc.servers, 'create')
|
self.m.StubOutWithMock(self.fc.servers, 'create')
|
||||||
self.fc.servers.create(image=1, flavor=1, key_name='test',\
|
self.fc.servers.create(image=1, flavor=1, key_name='test',
|
||||||
name='test_resource_name', security_groups=None,\
|
name='test_resource_name', security_groups=None,
|
||||||
userdata=server_userdata).\
|
userdata=server_userdata).\
|
||||||
AndReturn(self.fc.servers.list()[1])
|
AndReturn(self.fc.servers.list()[1])
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
@ -131,7 +131,7 @@ class instancesTest(unittest.TestCase):
|
|||||||
assert(instance.id > 0)
|
assert(instance.id > 0)
|
||||||
|
|
||||||
instance.delete()
|
instance.delete()
|
||||||
assert(instance.instance_id == None)
|
assert(instance.instance_id is None)
|
||||||
assert(instance.state == instance.DELETE_COMPLETE)
|
assert(instance.state == instance.DELETE_COMPLETE)
|
||||||
|
|
||||||
# allows testing of the test directly, shown below
|
# 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_attributes(instance.t)
|
||||||
instance.stack.resolve_joins(instance.t)
|
instance.stack.resolve_joins(instance.t)
|
||||||
instance.stack.resolve_base64(instance.t)
|
instance.stack.resolve_base64(instance.t)
|
||||||
server_userdata = instance._build_userdata(\
|
server_userdata = instance._build_userdata(
|
||||||
instance.t['Properties']['UserData'])
|
instance.t['Properties']['UserData'])
|
||||||
self.m.StubOutWithMock(self.fc.servers, 'create')
|
self.m.StubOutWithMock(self.fc.servers, 'create')
|
||||||
self.fc.servers.create(image=744, flavor=3, key_name='test',\
|
self.fc.servers.create(image=744, flavor=3, key_name='test',
|
||||||
name='WebServer', security_groups=None,\
|
name='WebServer', security_groups=None,
|
||||||
userdata=server_userdata).\
|
userdata=server_userdata).\
|
||||||
AndReturn(self.fc.servers.list()[-1])
|
AndReturn(self.fc.servers.list()[-1])
|
||||||
return stack
|
return stack
|
||||||
@ -61,7 +61,7 @@ class stacksTest(unittest.TestCase):
|
|||||||
stack = self.start_wordpress_stack('test_stack')
|
stack = self.start_wordpress_stack('test_stack')
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
stack.create_blocking()
|
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'].instance_id > 0)
|
||||||
assert(stack.resources['WebServer'].ipaddress != '0.0.0.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
|
pt['raw_template_id'] = new_rt.id
|
||||||
new_pt = db_api.parsed_template_create(None, pt)
|
new_pt = db_api.parsed_template_create(None, pt)
|
||||||
stack.create_blocking()
|
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'].instance_id > 0)
|
||||||
stack.delete_blocking()
|
stack.delete_blocking()
|
||||||
assert(stack.resources['WebServer'].state == 'DELETE_COMPLETE')
|
assert(stack.resources['WebServer'].state == 'DELETE_COMPLETE')
|
||||||
@ -105,7 +105,7 @@ class stacksTest(unittest.TestCase):
|
|||||||
pt['raw_template_id'] = new_rt.id
|
pt['raw_template_id'] = new_rt.id
|
||||||
new_pt = db_api.parsed_template_create(None, pt)
|
new_pt = db_api.parsed_template_create(None, pt)
|
||||||
stack.create_blocking()
|
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'].instance_id > 0)
|
||||||
|
|
||||||
m = manager.EngineManager()
|
m = manager.EngineManager()
|
||||||
@ -122,9 +122,9 @@ class stacksTest(unittest.TestCase):
|
|||||||
assert(result['LogicalResourceId'] == 'WebServer')
|
assert(result['LogicalResourceId'] == 'WebServer')
|
||||||
# Big long user data field.. it mentions 'wordpress'
|
# Big long user data field.. it mentions 'wordpress'
|
||||||
# a few times so this should work.
|
# a few times so this should work.
|
||||||
assert(result['ResourceProperties']['UserData'].find('wordpress')\
|
assert(result['ResourceProperties']['UserData'].find('wordpress')
|
||||||
!= -1)
|
!= -1)
|
||||||
assert(result['ResourceProperties']['ImageId']\
|
assert(result['ResourceProperties']['ImageId']
|
||||||
== 'F16-x86_64-gold')
|
== 'F16-x86_64-gold')
|
||||||
assert(result['ResourceProperties']['InstanceType'] == 'm1.large')
|
assert(result['ResourceProperties']['InstanceType'] == 'm1.large')
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ class validateTest(unittest.TestCase):
|
|||||||
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
||||||
|
|
||||||
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
|
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)
|
stack).AndReturn(None)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
@ -226,7 +226,7 @@ class validateTest(unittest.TestCase):
|
|||||||
stack.resolve_attributes(volumeattach.t)
|
stack.resolve_attributes(volumeattach.t)
|
||||||
stack.resolve_joins(volumeattach.t)
|
stack.resolve_joins(volumeattach.t)
|
||||||
stack.resolve_base64(volumeattach.t)
|
stack.resolve_base64(volumeattach.t)
|
||||||
assert(volumeattach.validate() == None)
|
assert(volumeattach.validate() is None)
|
||||||
|
|
||||||
def test_validate_volumeattach_invalid(self):
|
def test_validate_volumeattach_invalid(self):
|
||||||
t = json.loads(test_template_volumeattach % 'sda')
|
t = json.loads(test_template_volumeattach % 'sda')
|
||||||
@ -236,7 +236,7 @@ class validateTest(unittest.TestCase):
|
|||||||
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
stack = parser.Stack(None, 'test_stack', t, 0, params)
|
||||||
|
|
||||||
self.m.StubOutWithMock(db_api, 'resource_get_by_name_and_stack')
|
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)
|
stack).AndReturn(None)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
@ -258,7 +258,7 @@ class validateTest(unittest.TestCase):
|
|||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
manager = managers.EngineManager()
|
manager = managers.EngineManager()
|
||||||
res = dict(manager.\
|
res = dict(manager.
|
||||||
validate_template(None, t, params)['ValidateTemplateResult'])
|
validate_template(None, t, params)['ValidateTemplateResult'])
|
||||||
print 'res %s' % res
|
print 'res %s' % res
|
||||||
assert (res['Description'] == 'Successfully validated')
|
assert (res['Description'] == 'Successfully validated')
|
||||||
@ -275,7 +275,7 @@ class validateTest(unittest.TestCase):
|
|||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
manager = managers.EngineManager()
|
manager = managers.EngineManager()
|
||||||
res = dict(manager.\
|
res = dict(manager.
|
||||||
validate_template(None, t, params)['ValidateTemplateResult'])
|
validate_template(None, t, params)['ValidateTemplateResult'])
|
||||||
assert (res['Description'] != 'Successfully validated')
|
assert (res['Description'] != 'Successfully validated')
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ class validateTest(unittest.TestCase):
|
|||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
manager = managers.EngineManager()
|
manager = managers.EngineManager()
|
||||||
res = dict(manager.\
|
res = dict(manager.
|
||||||
validate_template(None, t, params)['ValidateTemplateResult'])
|
validate_template(None, t, params)['ValidateTemplateResult'])
|
||||||
assert (res['Description'] == 'Successfully validated')
|
assert (res['Description'] == 'Successfully validated')
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ class validateTest(unittest.TestCase):
|
|||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
manager = managers.EngineManager()
|
manager = managers.EngineManager()
|
||||||
res = dict(manager.\
|
res = dict(manager.
|
||||||
validate_template(None, t, params)['ValidateTemplateResult'])
|
validate_template(None, t, params)['ValidateTemplateResult'])
|
||||||
assert (res['Description'] != 'Successfully validated')
|
assert (res['Description'] != 'Successfully validated')
|
||||||
|
|
||||||
|
@ -39,8 +39,8 @@ def catch_error(action):
|
|||||||
ret = func(*arguments, **kwargs)
|
ret = func(*arguments, **kwargs)
|
||||||
return SUCCESS if ret is None else ret
|
return SUCCESS if ret is None else ret
|
||||||
except exception.NotAuthorized:
|
except exception.NotAuthorized:
|
||||||
logging.error("Not authorized to make this request. Check " +\
|
logging.error("Not authorized to make this request. Check " +
|
||||||
"your credentials (OS_USERNAME, OS_PASSWORD, " +\
|
"your credentials (OS_USERNAME, OS_PASSWORD, " +
|
||||||
"OS_TENANT_NAME, OS_AUTH_URL and OS_AUTH_STRATEGY).")
|
"OS_TENANT_NAME, OS_AUTH_URL and OS_AUTH_STRATEGY).")
|
||||||
return FAILURE
|
return FAILURE
|
||||||
except exception.ClientConfigurationError:
|
except exception.ClientConfigurationError:
|
||||||
@ -107,9 +107,9 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if not instance_type in instance_types:
|
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)
|
instance_type)
|
||||||
logging.error('try: heat jeos-create %s %s [ %s ]' %\
|
logging.error('try: heat jeos-create %s %s [ %s ]' %
|
||||||
(distro, arch, instances_str))
|
(distro, arch, instances_str))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
runoz = options.yes and 'y' or None
|
runoz = options.yes and 'y' or None
|
||||||
if os.access(qcow2_filename, os.R_OK):
|
if os.access(qcow2_filename, os.R_OK):
|
||||||
while runoz not in ('y', 'n'):
|
while runoz not in ('y', 'n'):
|
||||||
runoz = raw_input('An existing JEOS was found on disk.' \
|
runoz = raw_input('An existing JEOS was found on disk.'
|
||||||
' Do you want to build a fresh JEOS?' \
|
' Do you want to build a fresh JEOS?'
|
||||||
' (y/n) ').lower()
|
' (y/n) ').lower()
|
||||||
if runoz == 'y':
|
if runoz == 'y':
|
||||||
os.remove(qcow2_filename)
|
os.remove(qcow2_filename)
|
||||||
@ -199,7 +199,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
elif runoz == 'n':
|
elif runoz == 'n':
|
||||||
answer = None
|
answer = None
|
||||||
while answer not in ('y', 'n'):
|
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()
|
' JEOS file with glance? (y/n) ').lower()
|
||||||
if answer == 'n':
|
if answer == 'n':
|
||||||
logging.info('No action taken')
|
logging.info('No action taken')
|
||||||
@ -207,8 +207,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
elif answer == 'y' and image_registered:
|
elif answer == 'y' and image_registered:
|
||||||
answer = None
|
answer = None
|
||||||
while answer not in ('y', 'n'):
|
while answer not in ('y', 'n'):
|
||||||
answer = raw_input('Do you want to delete the ' \
|
answer = raw_input('Do you want to delete the '
|
||||||
'existing JEOS in glance?' \
|
'existing JEOS in glance?'
|
||||||
' (y/n) ').lower()
|
' (y/n) ').lower()
|
||||||
if answer == 'n':
|
if answer == 'n':
|
||||||
logging.info('No action taken')
|
logging.info('No action taken')
|
||||||
@ -216,8 +216,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
elif answer == 'y':
|
elif answer == 'y':
|
||||||
client.delete_image(image['id'])
|
client.delete_image(image['id'])
|
||||||
|
|
||||||
if runoz == None or runoz == 'y':
|
if runoz is None or runoz == 'y':
|
||||||
logging.info('Creating JEOS image (%s) - '\
|
logging.info('Creating JEOS image (%s) - '
|
||||||
'this takes approximately 10 minutes.' % image_name)
|
'this takes approximately 10 minutes.' % image_name)
|
||||||
extra_opts = ' '
|
extra_opts = ' '
|
||||||
if options.debug:
|
if options.debug:
|
||||||
@ -230,7 +230,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
if res == 256:
|
if res == 256:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if not os.access(dsk_filename, os.R_OK):
|
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.')
|
' check your oz installation.')
|
||||||
sys.exit(1)
|
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,
|
os.system("qemu-img convert -c -O qcow2 %s %s" % (dsk_filename,
|
||||||
qcow2_filename))
|
qcow2_filename))
|
||||||
|
|
||||||
logging.info('Registering JEOS image (%s) ' \
|
logging.info('Registering JEOS image (%s) '
|
||||||
'with OpenStack Glance.' % image_name)
|
'with OpenStack Glance.' % image_name)
|
||||||
|
|
||||||
image_meta = {'name': 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()):
|
for k, v in sorted(image_meta.items()):
|
||||||
logging.debug(" %(k)30s => %(v)s" % locals())
|
logging.debug(" %(k)30s => %(v)s" % locals())
|
||||||
except exception.ClientConnectionError, e:
|
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()))
|
" Is the server running?" % locals()))
|
||||||
pieces = unicode(e).split('\n')
|
pieces = unicode(e).split('\n')
|
||||||
for piece in pieces:
|
for piece in pieces:
|
||||||
@ -269,7 +269,7 @@ def jeos_create(options, arguments, jeos_path, cfntools_path):
|
|||||||
pieces = unicode(e).split('\n')
|
pieces = unicode(e).split('\n')
|
||||||
for piece in pieces:
|
for piece in pieces:
|
||||||
logging.error(piece)
|
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'.")
|
"registry, but the image's status will likely be 'killed'.")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user