当前位置: 首页>>代码示例>>Python>>正文


Python Environment.set方法代码示例

本文整理汇总了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)
        )
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:31,代码来源:environment.py

示例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)
     )
开发者ID:Mellanox,项目名称:fuel-web,代码行数:20,代码来源:environment.py


注:本文中的fuelclient.objects.environment.Environment.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。