本文整理汇总了Python中heat.engine.clients.Clients类的典型用法代码示例。如果您正苦于以下问题:Python Clients类的具体用法?Python Clients怎么用?Python Clients使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Clients类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, context, stack_name, tmpl, env=None,
stack_id=None, action=None, status=None,
status_reason='', timeout_mins=None, resolve_data=True,
disable_rollback=True, parent_resource=None, owner_id=None,
adopt_stack_data=None, stack_user_project_id=None,
created_time=None, updated_time=None,
user_creds_id=None, tenant_id=None, validate_parameters=True):
'''
Initialise from a context, name, Template object and (optionally)
Environment object. The database ID may also be initialised, if the
stack is already in the database.
'''
if owner_id is None:
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(_('Invalid stack name %s'
' must contain only alphanumeric or '
'\"_-.\" characters, must start with alpha'
) % stack_name)
self.id = stack_id
self.owner_id = owner_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.action = action
self.status = status
self.status_reason = status_reason
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
self.parent_resource = parent_resource
self._resources = None
self._dependencies = None
self._access_allowed_handlers = {}
self._db_resources = None
self.adopt_stack_data = adopt_stack_data
self.stack_user_project_id = stack_user_project_id
self.created_time = created_time
self.updated_time = updated_time
self.user_creds_id = user_creds_id
# This will use the provided tenant ID when loading the stack
# from the DB or get it from the context for new stacks.
self.tenant_id = tenant_id or self.context.tenant_id
resources.initialise()
self.env = env or environment.Environment({})
self.parameters = self.t.parameters(self.identifier(),
user_params=self.env.params)
self.parameters.validate(validate_value=validate_parameters,
context=context)
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[self.t.OUTPUTS])
else:
self.outputs = {}
示例2: __init__
def __init__(
self,
context,
stack_name,
tmpl,
env=None,
stack_id=None,
action=None,
status=None,
status_reason="",
timeout_mins=60,
resolve_data=True,
disable_rollback=True,
parent_resource=None,
owner_id=None,
):
"""
Initialise from a context, name, Template object and (optionally)
Environment object. The database ID may also be initialised, if the
stack is already in the database.
"""
if owner_id is None:
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(
_(
"Invalid stack name %s"
" must contain only alphanumeric or "
'"_-." characters, must start with alpha'
)
% stack_name
)
self.id = stack_id
self.owner_id = owner_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.action = action
self.status = status
self.status_reason = status_reason
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
self.parent_resource = parent_resource
self._resources = None
self._dependencies = None
resources.initialise()
self.env = env or environment.Environment({})
self.parameters = Parameters(self.name, self.t, user_params=self.env.params)
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[template.OUTPUTS])
else:
self.outputs = {}
示例3: __init__
def __init__(self, context, stack_name, tmpl, parameters=None,
stack_id=None, state=None, state_description='',
timeout_mins=60, resolve_data=True, disable_rollback=True):
'''
Initialise from a context, name, Template object and (optionally)
Parameters object. The database ID may also be initialised, if the
stack is already in the database.
'''
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(_('Invalid stack name %s'
' must contain only alphanumeric or '
'\"_-.\" characters, must start with alpha'
) % stack_name)
self.id = stack_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.state = state
self.state_description = state_description
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
resources.initialise()
if parameters is None:
parameters = Parameters(self.name, self.t)
self.parameters = parameters
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[template.OUTPUTS])
else:
self.outputs = {}
template_resources = self.t[template.RESOURCES]
self.resources = dict((name,
resource.Resource(name, data, self))
for (name, data) in template_resources.items())
self.dependencies = self._get_dependencies(self.resources.itervalues())
示例4: Stack
class Stack(object):
ACTIONS = (CREATE, DELETE, UPDATE, ROLLBACK
) = ('CREATE', 'DELETE', 'UPDATE', 'ROLLBACK')
CREATE_IN_PROGRESS = 'CREATE_IN_PROGRESS'
CREATE_FAILED = 'CREATE_FAILED'
CREATE_COMPLETE = 'CREATE_COMPLETE'
DELETE_IN_PROGRESS = 'DELETE_IN_PROGRESS'
DELETE_FAILED = 'DELETE_FAILED'
DELETE_COMPLETE = 'DELETE_COMPLETE'
UPDATE_IN_PROGRESS = 'UPDATE_IN_PROGRESS'
UPDATE_COMPLETE = 'UPDATE_COMPLETE'
UPDATE_FAILED = 'UPDATE_FAILED'
ROLLBACK_IN_PROGRESS = 'ROLLBACK_IN_PROGRESS'
ROLLBACK_COMPLETE = 'ROLLBACK_COMPLETE'
ROLLBACK_FAILED = 'ROLLBACK_FAILED'
created_time = timestamp.Timestamp(db_api.stack_get, 'created_at')
updated_time = timestamp.Timestamp(db_api.stack_get, 'updated_at')
_zones = None
def __init__(self, context, stack_name, tmpl, parameters=None,
stack_id=None, state=None, state_description='',
timeout_mins=60, resolve_data=True, disable_rollback=True):
'''
Initialise from a context, name, Template object and (optionally)
Parameters object. The database ID may also be initialised, if the
stack is already in the database.
'''
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(_('Invalid stack name %s'
' must contain only alphanumeric or '
'\"_-.\" characters, must start with alpha'
) % stack_name)
self.id = stack_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.state = state
self.state_description = state_description
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
resources.initialise()
if parameters is None:
parameters = Parameters(self.name, self.t)
self.parameters = parameters
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[template.OUTPUTS])
else:
self.outputs = {}
template_resources = self.t[template.RESOURCES]
self.resources = dict((name,
resource.Resource(name, data, self))
for (name, data) in template_resources.items())
self.dependencies = self._get_dependencies(self.resources.itervalues())
def _set_param_stackid(self):
'''
Update self.parameters with the current ARN which is then provided
via the Parameters class as the AWS::StackId pseudo parameter
'''
# This can fail if constructor called without a valid context,
# as it is in many tests
try:
stack_arn = self.identifier().arn()
except (AttributeError, ValueError, TypeError):
logger.warning("Unable to set parameters StackId identifier")
else:
self.parameters.set_stack_id(stack_arn)
@staticmethod
def _get_dependencies(resources):
'''Return the dependency graph for a list of resources.'''
deps = dependencies.Dependencies()
for resource in resources:
resource.add_dependencies(deps)
return deps
@classmethod
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:
#.........这里部分代码省略.........
示例5: Stack
class Stack(collections.Mapping):
ACTIONS = (CREATE, DELETE, UPDATE, ROLLBACK, SUSPEND, RESUME, ADOPT
) = ('CREATE', 'DELETE', 'UPDATE', 'ROLLBACK', 'SUSPEND',
'RESUME', 'ADOPT')
STATUSES = (IN_PROGRESS, FAILED, COMPLETE
) = ('IN_PROGRESS', 'FAILED', 'COMPLETE')
_zones = None
def __init__(self, context, stack_name, tmpl, env=None,
stack_id=None, action=None, status=None,
status_reason='', timeout_mins=None, resolve_data=True,
disable_rollback=True, parent_resource=None, owner_id=None,
adopt_stack_data=None, stack_user_project_id=None,
created_time=None, updated_time=None,
user_creds_id=None, tenant_id=None, validate_parameters=True):
'''
Initialise from a context, name, Template object and (optionally)
Environment object. The database ID may also be initialised, if the
stack is already in the database.
'''
if owner_id is None:
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(_('Invalid stack name %s'
' must contain only alphanumeric or '
'\"_-.\" characters, must start with alpha'
) % stack_name)
self.id = stack_id
self.owner_id = owner_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.action = action
self.status = status
self.status_reason = status_reason
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
self.parent_resource = parent_resource
self._resources = None
self._dependencies = None
self._access_allowed_handlers = {}
self._db_resources = None
self.adopt_stack_data = adopt_stack_data
self.stack_user_project_id = stack_user_project_id
self.created_time = created_time
self.updated_time = updated_time
self.user_creds_id = user_creds_id
# This will use the provided tenant ID when loading the stack
# from the DB or get it from the context for new stacks.
self.tenant_id = tenant_id or self.context.tenant_id
resources.initialise()
self.env = env or environment.Environment({})
self.parameters = self.t.parameters(self.identifier(),
user_params=self.env.params)
self.parameters.validate(validate_value=validate_parameters,
context=context)
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[self.t.OUTPUTS])
else:
self.outputs = {}
def stored_context(self):
if self.user_creds_id:
creds = db_api.user_creds_get(self.user_creds_id)
# Maintain request_id from self.context so we retain tracability
# in situations where servicing a request requires switching from
# the request context to the stored context
creds['request_id'] = self.context.request_id
# We don't store roles in the user_creds table, so disable the
# policy check for admin by setting is_admin=False.
creds['is_admin'] = False
return common_context.RequestContext.from_dict(creds)
else:
msg = _("Attempt to use stored_context with no user_creds")
raise exception.Error(msg)
@property
def resources(self):
if self._resources is None:
self._resources = dict((name, resource.Resource(name, data, self))
for (name, data) in
self.t.resource_definitions(self).items())
# There is no need to continue storing the db resources
# after resource creation
self._db_resources = None
return self._resources
def db_resource_get(self, name):
if not self.id:
return None
#.........这里部分代码省略.........
示例6: Stack
class Stack(object):
ACTIONS = (CREATE, DELETE, UPDATE, ROLLBACK, SUSPEND, RESUME
) = ('CREATE', 'DELETE', 'UPDATE', 'ROLLBACK', 'SUSPEND',
'RESUME')
STATUSES = (IN_PROGRESS, FAILED, COMPLETE
) = ('IN_PROGRESS', 'FAILED', 'COMPLETE')
created_time = timestamp.Timestamp(functools.partial(db_api.stack_get,
show_deleted=True),
'created_at')
updated_time = timestamp.Timestamp(functools.partial(db_api.stack_get,
show_deleted=True),
'updated_at')
_zones = None
def __init__(self, context, stack_name, tmpl, env=None,
stack_id=None, action=None, status=None,
status_reason='', timeout_mins=60, resolve_data=True,
disable_rollback=True, parent_resource=None, owner_id=None):
'''
Initialise from a context, name, Template object and (optionally)
Environment object. The database ID may also be initialised, if the
stack is already in the database.
'''
if owner_id is None:
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(_('Invalid stack name %s'
' must contain only alphanumeric or '
'\"_-.\" characters, must start with alpha'
) % stack_name)
self.id = stack_id
self.owner_id = owner_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.action = action
self.status = status
self.status_reason = status_reason
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
self.parent_resource = parent_resource
self._resources = None
self._dependencies = None
resources.initialise()
self.env = env or environment.Environment({})
self.parameters = Parameters(self.name, self.t,
user_params=self.env.params)
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[template.OUTPUTS])
else:
self.outputs = {}
@property
def resources(self):
if self._resources is None:
template_resources = self.t[template.RESOURCES]
self._resources = dict((name, resource.Resource(name, data, self))
for (name, data) in
template_resources.items())
return self._resources
@property
def dependencies(self):
if self._dependencies is None:
self._dependencies = self._get_dependencies(
self.resources.itervalues())
return self._dependencies
def reset_dependencies(self):
self._dependencies = None
@property
def root_stack(self):
'''
Return the root stack if this is nested (otherwise return self).
'''
if (self.parent_resource and self.parent_resource.stack):
return self.parent_resource.stack.root_stack
return self
def total_resources(self):
'''
Total number of resources in a stack, including nested stacks below.
'''
total = 0
for res in iter(self.resources.values()):
if hasattr(res, 'nested') and res.nested():
total += res.nested().total_resources()
total += 1
#.........这里部分代码省略.........
示例7: Stack
class Stack(collections.Mapping):
ACTIONS = (CREATE, DELETE, UPDATE, ROLLBACK, SUSPEND, RESUME) = (
"CREATE",
"DELETE",
"UPDATE",
"ROLLBACK",
"SUSPEND",
"RESUME",
)
STATUSES = (IN_PROGRESS, FAILED, COMPLETE) = ("IN_PROGRESS", "FAILED", "COMPLETE")
created_time = timestamp.Timestamp(functools.partial(db_api.stack_get, show_deleted=True), "created_at")
updated_time = timestamp.Timestamp(functools.partial(db_api.stack_get, show_deleted=True), "updated_at")
_zones = None
def __init__(
self,
context,
stack_name,
tmpl,
env=None,
stack_id=None,
action=None,
status=None,
status_reason="",
timeout_mins=60,
resolve_data=True,
disable_rollback=True,
parent_resource=None,
owner_id=None,
):
"""
Initialise from a context, name, Template object and (optionally)
Environment object. The database ID may also be initialised, if the
stack is already in the database.
"""
if owner_id is None:
if re.match("[a-zA-Z][a-zA-Z0-9_.-]*$", stack_name) is None:
raise ValueError(
_(
"Invalid stack name %s"
" must contain only alphanumeric or "
'"_-." characters, must start with alpha'
)
% stack_name
)
self.id = stack_id
self.owner_id = owner_id
self.context = context
self.clients = Clients(context)
self.t = tmpl
self.name = stack_name
self.action = action
self.status = status
self.status_reason = status_reason
self.timeout_mins = timeout_mins
self.disable_rollback = disable_rollback
self.parent_resource = parent_resource
self._resources = None
self._dependencies = None
resources.initialise()
self.env = env or environment.Environment({})
self.parameters = Parameters(self.name, self.t, user_params=self.env.params)
self._set_param_stackid()
if resolve_data:
self.outputs = self.resolve_static_data(self.t[template.OUTPUTS])
else:
self.outputs = {}
@property
def resources(self):
if self._resources is None:
template_resources = self.t[template.RESOURCES]
self._resources = dict(
(name, resource.Resource(name, data, self)) for (name, data) in template_resources.items()
)
return self._resources
@property
def dependencies(self):
if self._dependencies is None:
self._dependencies = self._get_dependencies(self.resources.itervalues())
return self._dependencies
def reset_dependencies(self):
self._dependencies = None
@property
def root_stack(self):
"""
Return the root stack if this is nested (otherwise return self).
#.........这里部分代码省略.........