本文整理汇总了Python中heat.engine.template.Template类的典型用法代码示例。如果您正苦于以下问题:Python Template类的具体用法?Python Template怎么用?Python Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Template类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore
def restore(self, snapshot):
'''
Restore the given snapshot, invoking handle_restore on all resources.
'''
if snapshot.stack_id != self.id:
self.state_set(self.RESTORE, self.FAILED,
"Can't restore snapshot from other stack")
return
self.updated_time = datetime.utcnow()
tmpl = Template(snapshot.data['template'])
for name, defn in tmpl.resource_definitions(self).iteritems():
rsrc = resource.Resource(name, defn, self)
data = snapshot.data['resources'].get(name)
handle_restore = getattr(rsrc, 'handle_restore', None)
if callable(handle_restore):
defn = handle_restore(defn, data)
tmpl.add_resource(defn, name)
newstack = self.__class__(self.context, self.name, tmpl, self.env,
timeout_mins=self.timeout_mins,
disable_rollback=self.disable_rollback)
newstack.parameters.set_stack_id(self.identifier())
updater = scheduler.TaskRunner(self.update_task, newstack,
action=self.RESTORE)
updater()
示例2: load
def load(cls, context, stack_id=None, stack=None, resolve_data=True,
parent_resource=None, show_deleted=True):
'''Retrieve a Stack from the database.'''
if stack is None:
stack = db_api.stack_get(context, stack_id,
show_deleted=show_deleted,
eager_load=True)
if stack is None:
message = _('No stack exists with id "%s"') % str(stack_id)
raise exception.NotFound(message)
template = Template.load(
context, stack.raw_template_id, stack.raw_template)
env = environment.Environment(stack.parameters)
stack = cls(context, stack.name, template, env,
stack.id, stack.action, stack.status, stack.status_reason,
stack.timeout, resolve_data, stack.disable_rollback,
parent_resource, owner_id=stack.owner_id,
stack_user_project_id=stack.stack_user_project_id,
created_time=stack.created_at,
updated_time=stack.updated_at,
user_creds_id=stack.user_creds_id, tenant_id=stack.tenant,
validate_parameters=False)
return stack
示例3: _from_db
def _from_db(cls, context, stack, parent_resource=None, resolve_data=True, use_stored_context=False):
template = Template.load(context, stack.raw_template_id, stack.raw_template)
env = environment.Environment(stack.parameters)
return cls(
context,
stack.name,
template,
env,
stack.id,
stack.action,
stack.status,
stack.status_reason,
stack.timeout,
resolve_data,
stack.disable_rollback,
parent_resource,
owner_id=stack.owner_id,
stack_user_project_id=stack.stack_user_project_id,
created_time=stack.created_at,
updated_time=stack.updated_at,
user_creds_id=stack.user_creds_id,
tenant_id=stack.tenant,
validate_parameters=False,
use_stored_context=use_stored_context,
)
示例4: load
def load(cls, context, stack_id=None, stack=None, resolve_data=True, parent_resource=None, show_deleted=True):
"""Retrieve a Stack from the database."""
if stack is None:
stack = db_api.stack_get(context, stack_id, show_deleted=show_deleted)
if stack is None:
message = _('No stack exists with id "%s"') % str(stack_id)
raise exception.NotFound(message)
template = Template.load(context, stack.raw_template_id)
env = environment.Environment(stack.parameters)
stack = cls(
context,
stack.name,
template,
env,
stack.id,
stack.action,
stack.status,
stack.status_reason,
stack.timeout,
resolve_data,
stack.disable_rollback,
parent_resource,
owner_id=stack.owner_id,
)
return stack
示例5: load
def load(cls, context, stack_id=None, stack=None, resolve_data=True):
'''Retrieve a Stack from the database.'''
if stack is None:
stack = db_api.stack_get(context, stack_id)
if stack is None:
message = 'No stack exists with id "%s"' % str(stack_id)
raise exception.NotFound(message)
template = Template.load(context, stack.raw_template_id)
params = Parameters(stack.name, template, stack.parameters)
stack = cls(context, stack.name, template, params,
stack.id, stack.status, stack.status_reason, stack.timeout,
resolve_data, stack.disable_rollback)
return stack
示例6: _backup_stack
def _backup_stack(self, create_if_missing=True):
"""
Get a Stack containing any in-progress resources from the previous
stack state prior to an update.
"""
s = db_api.stack_get_by_name_and_owner_id(self.context, self._backup_name(), owner_id=self.id)
if s is not None:
LOG.debug("Loaded existing backup stack")
return self.load(self.context, stack=s)
elif create_if_missing:
templ = Template.load(self.context, self.t.id)
templ.files = copy.deepcopy(self.t.files)
prev = type(self)(self.context, self.name, templ, self.env, owner_id=self.id)
prev.store(backup=True)
LOG.debug("Created new backup stack")
return prev
else:
return None
示例7: _from_db
def _from_db(cls, context, stack, parent_resource=None, resolve_data=True,
use_stored_context=False):
template = Template.load(
context, stack.raw_template_id, stack.raw_template)
env = environment.Environment(stack.parameters)
return cls(context, stack.name, template, env,
stack.id, stack.action, stack.status, stack.status_reason,
stack.timeout, resolve_data, stack.disable_rollback,
parent_resource, owner_id=stack.owner_id,
stack_user_project_id=stack.stack_user_project_id,
created_time=stack.created_at,
updated_time=stack.updated_at,
user_creds_id=stack.user_creds_id, tenant_id=stack.tenant,
use_stored_context=use_stored_context,
username=stack.username,
#add by xm-20150603
stack_apps_style=stack.stack_apps_style, isscaler=stack.isscaler,
enduser=stack.enduser, description=stack.description,
app_name=stack.app_name, template_id=stack.template_id)