Browse Source

Don't store the metadata server address in the Stack

It is basically a global piece of data, so there is nothing to be gained by
dragging some extra state around with us everywhere.

Change-Id: I50ba7391f258dc7d9b1e186f1618fb140e15b26e
Signed-off-by: Zane Bitter <zbitter@redhat.com>
changes/23/9323/1
Zane Bitter 10 years ago
parent
commit
ce8f316fb5
  1. 13
      heat/engine/instance.py
  2. 7
      heat/engine/manager.py
  3. 4
      heat/engine/parser.py
  4. 9
      heat/engine/resources.py
  5. 3
      heat/engine/stack.py
  6. 8
      heat/engine/wait_condition.py

13
heat/engine/instance.py

@ -23,13 +23,13 @@ from email.mime.text import MIMEText
from novaclient.exceptions import NotFound
import heat
from heat.engine.resources import Resource
from heat.engine import resources
from heat.common import exception
logger = logging.getLogger('heat.engine.instance')
class Restarter(Resource):
class Restarter(resources.Resource):
properties_schema = {'InstanceId': {'Type': 'String',
'Required': True}}
@ -57,7 +57,7 @@ class Restarter(Resource):
self.stack.restart_resource(victim.name)
class Instance(Resource):
class Instance(resources.Resource):
# AWS does not require KeyName and InstanceType but we seem to
properties_schema = {'ImageId': {'Type': 'String',
'Required': True},
@ -180,8 +180,9 @@ class Instance(Resource):
attachments.append((json.dumps(metadata),
'cfn-init-data', 'x-cfninitdata'))
if self.stack.metadata_server:
attachments.append((self.stack.metadata_server,
metadata_server = resources.metadata_server()
if metadata_server:
attachments.append((metadata_server,
'cfn-metadata-server', 'x-cfninitdata'))
subparts = [make_subpart(*args) for args in attachments]
@ -238,7 +239,7 @@ class Instance(Resource):
'''
Validate any of the provided params
'''
res = Resource.validate(self)
res = super(Instance, self).validate()
if res:
return res

7
heat/engine/manager.py

@ -186,14 +186,12 @@ class EngineManager(manager.Manager):
return {'Error': 'Stack already exists with that name.'}
user_params = _extract_user_params(params)
metadata_server = config.FLAGS.heat_metadata_server_url
# We don't want to reset the stack template, so we are making
# an instance just for validation.
template_copy = deepcopy(template)
stack_validator = parser.Stack(context, stack_name,
template_copy, 0,
user_params,
metadata_server=metadata_server)
user_params)
response = stack_validator.validate()
stack_validator = None
template_copy = None
@ -201,8 +199,7 @@ class EngineManager(manager.Manager):
response['ValidateTemplateResult']['Description']:
return response
stack = parser.Stack(context, stack_name, template, 0, user_params,
metadata_server=metadata_server)
stack = parser.Stack(context, stack_name, template, 0, user_params)
rt = {}
rt['template'] = template
rt['StackName'] = stack_name

4
heat/engine/parser.py

@ -35,8 +35,7 @@ class Stack(object):
DELETE_FAILED = 'DELETE_FAILED'
DELETE_COMPLETE = 'DELETE_COMPLETE'
def __init__(self, context, stack_name, template, stack_id=0, parms=None,
metadata_server=None):
def __init__(self, context, stack_name, template, stack_id=0, parms=None):
self.id = stack_id
self.context = context
self.t = template
@ -44,7 +43,6 @@ class Stack(object):
self.res = {}
self.doc = None
self.name = stack_name
self.metadata_server = metadata_server
# Default Parameters
self.parms = checkeddict.CheckedDict('Parameters')

9
heat/engine/resources.py

@ -21,7 +21,7 @@ from novaclient.v1_1 import client as nc
from keystoneclient.v2_0 import client as kc
from heat.common import exception
from heat.common.config import HeatEngineConfigOpts
from heat.common import config
from heat.db import api as db_api
from heat.engine import checkeddict
from heat.engine import auth
@ -29,6 +29,13 @@ from heat.engine import auth
logger = logging.getLogger('heat.engine.resources')
def metadata_server():
try:
return config.FLAGS.heat_metadata_server_url
except AttributeError:
return None
class Resource(object):
CREATE_IN_PROGRESS = 'IN_PROGRESS'
CREATE_FAILED = 'CREATE_FAILED'

3
heat/engine/stack.py

@ -67,8 +67,7 @@ class Stack(Resource):
self._nested = parser.Stack(self.stack.context,
self.name,
child_template,
parms=self._params(),
metadata_server=self.stack.metadata_server)
parms=self._params())
rt = {'template': child_template, 'stack_name': self.name}
new_rt = db_api.raw_template_create(None, rt)

8
heat/engine/wait_condition.py

@ -19,12 +19,12 @@ import json
from heat.common import exception
from heat.db import api as db_api
from heat.engine.resources import Resource
from heat.engine import resources
logger = logging.getLogger('heat.engine.wait_condition')
class WaitConditionHandle(Resource):
class WaitConditionHandle(resources.Resource):
'''
the main point of this class is to :
have no dependancies (so the instance can reference it)
@ -39,12 +39,12 @@ class WaitConditionHandle(Resource):
def handle_create(self):
self.instance_id = '%s/stacks/%s/resources/%s' % \
(self.stack.metadata_server,
(resources.metadata_server(),
self.stack.id,
self.name)
class WaitCondition(Resource):
class WaitCondition(resources.Resource):
properties_schema = {'Handle': {'Type': 'String',
'Required': True},
'Timeout': {'Type': 'Number',

Loading…
Cancel
Save