本文整理汇总了Python中fuelclient.objects.environment.Environment.set方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.set方法的具体用法?Python Environment.set怎么用?Python Environment.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fuelclient.objects.environment.Environment
的用法示例。
在下文中一共展示了Environment.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import set [as 别名]
def set(self, params):
"""To change environment name:
fuel --env 1 env set --name NewEnvName
"""
acceptable_params = ('name', 'pending_release_id')
env = Environment(params.env, params=params)
# forming message for output and data structure for request body
# TODO(aroma): make it less ugly
msg_template = ("Following attributes are changed for "
"the environment: {env_attributes}")
env_attributes = []
update_kwargs = dict()
for param_name in acceptable_params:
attr_value = getattr(params, param_name, None)
if attr_value:
update_kwargs[param_name] = attr_value
env_attributes.append(
''.join([param_name, '=', str(attr_value)])
)
data = env.set(update_kwargs)
env_attributes = ', '.join(env_attributes)
self.serializer.print_to_output(
data,
msg_template.format(env_attributes=env_attributes)
)
示例2: set
# 需要导入模块: from fuelclient.objects.environment import Environment [as 别名]
# 或者: from fuelclient.objects.environment.Environment import set [as 别名]
def set(self, params):
"""For changing environments name, mode
or network mode exists set action:
fuel --env 1 env set --name NewEmvName --mode ha_compact
"""
env = Environment(params.env, params=params)
data = env.set(name=params.name, mode=params.mode)
msg_templates = []
if params.name:
msg_templates.append(
"Environment with id={id} was renamed to '{name}'.")
if params.mode:
msg_templates.append(
"Mode of environment with id={id} was set to '{mode}'.")
self.serializer.print_to_output(
data,
"\n".join(msg_templates).format(**data)
)