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


Python environment.Environment类代码示例

本文整理汇总了Python中fuelclient.objects.environment.Environment的典型用法代码示例。如果您正苦于以下问题:Python Environment类的具体用法?Python Environment怎么用?Python Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: roles

 def roles(self, uid):
     from fuelclient.objects.node import Node
     from fuelclient.objects.environment import Environment
     node = Node(uid)
     env = Environment(node.data['cluster'])
     facts = env.get_default_facts('deployment', [uid])
     return [f['role'] for f in facts]
开发者ID:Mirantis,项目名称:f2s,代码行数:7,代码来源:fsclient.py

示例2: execute_tasks

    def execute_tasks(self, params):
        """Execute deployment tasks
                fuel node --node 2 --tasks hiera netconfig
                fuel node --node 2 --skip hiera netconfig
                fuel node --node 2 --skip rsync --end pre_deployment
                fuel node --node 2 --end netconfig
                fuel node --node 2 --start hiera --end neutron
                fuel node --node 2 --start post_deployment
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        env_id_to_start = self.get_env_id(node_collection)

        env = Environment(env_id_to_start)

        if params.tasks:
            tasks = params.tasks
        else:
            tasks = env.get_tasks(
                skip=params.skip, end=params.end, start=params.start)

        task = env.execute_tasks(node_collection.collection, tasks=tasks)

        self.serializer.print_to_output(
            task.data,
            "Started tasks {0} for nodes {1}.".format(tasks, node_collection))
开发者ID:kendriu,项目名称:python-fuelclient,代码行数:25,代码来源:node.py

示例3: execute_tasks

    def execute_tasks(self, params):
        """Execute deployment tasks
                fuel node --node 2 --tasks hiera netconfig
                fuel node --node 2 --tasks netconfig --force
                fuel node --node 2 --skip hiera netconfig
                fuel node --node 2 --skip rsync --end pre_deployment_end
                fuel node --node 2 --end netconfig
                fuel node --node 2 --start hiera --end neutron
                fuel node --node 2 --start post_deployment_start
        """
        node_collection = NodeCollection.init_with_ids(params.node)
        env_id_to_start = self.get_env_id(node_collection)

        env = Environment(env_id_to_start)

        tasks = params.tasks or None
        force = params.force or None

        if params.skip or params.end or params.start:
            tasks = env.get_tasks(
                skip=params.skip,
                end=params.end,
                start=params.start,
                include=tasks)

        if not tasks:
            self.serializer.print_to_output({}, "Nothing to run.")
            return

        task = env.execute_tasks(
            node_collection.collection, tasks=tasks, force=force)

        self.serializer.print_to_output(
            task.data,
            "Started tasks {0} for nodes {1}.".format(tasks, node_collection))
开发者ID:heartpandora,项目名称:python-fuelclient,代码行数:35,代码来源:node.py

示例4: TestEnvironmentOstf

class TestEnvironmentOstf(base.UnitTestCase):

    def setUp(self):
        super(TestEnvironmentOstf, self).setUp()

        self.env = Environment(None)

    @mock.patch.object(Environment.connection, 'post_request', mock.Mock(
        return_value=[
            {'id': 1},
            {'id': 2}, ]))
    def test_run_test_sets(self):
        self.assertEqual(self.env._testruns_ids, [])

        testruns = self.env.run_test_sets(['sanity', 'ha'])

        self.assertEqual(len(testruns), 2)
        self.assertIn(1, self.env._testruns_ids)
        self.assertIn(2, self.env._testruns_ids)

    @mock.patch.object(Environment.connection, 'get_request', mock.Mock(
        side_effect=[
            {'id': 1, 'status': 'running'},
            {'id': 2, 'status': 'finished'}, ]))
    def test_get_state_of_tests(self):
        self.env._testruns_ids.extend([1, 2])
        tests = self.env.get_state_of_tests()

        self.env.connection.get_request.assert_has_calls([
            mock.call('testruns/1', ostf=True),
            mock.call('testruns/2', ostf=True)])
        self.assertEqual(tests, [
            {'id': 1, 'status': 'running'},
            {'id': 2, 'status': 'finished'}])
开发者ID:Zipfer,项目名称:fuel-web,代码行数:34,代码来源:test_environment.py

示例5: check

    def check(self, params):
        """To run some health checks:
                fuel --env 1 health --check smoke,sanity
        """
        env = Environment(params.env)

        if env.status not in self._allowed_statuses and not params.force:
            exit_with_error(
                "Environment is not ready to run health check "
                "because it is in {0} state. "
                "Health check is likely to fail because of "
                "this. Use --force flag to proceed anyway.". format(env.status)
            )

        if env.is_customized and not params.force:
            exit_with_error(
                "Environment deployment facts were updated. "
                "Health check is likely to fail because of "
                "that. Use --force flag to proceed anyway."
            )
        test_sets_to_check = params.check or set(
            ts["id"] for ts in env.get_testsets())
        env.run_test_sets(test_sets_to_check)
        tests_state = env.get_state_of_tests()
        self.serializer.print_to_output(
            tests_state,
            env,
            print_method=print_health_check
        )
开发者ID:Axam,项目名称:fuel-web,代码行数:29,代码来源:health.py

示例6: set

    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,代码行数:29,代码来源:environment.py

示例7: delete

    def delete(self, params):
        """Deletes network template for specified environment:
            fuel --env 1 --network-template --delete
        """
        env = Environment(params.env)
        env.delete_network_template_data()

        print("Network template configuration for environment id={0}" " has been deleted.".format(env.id))
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:8,代码来源:network.py

示例8: verify

 def verify(self, params):
     """To verify network configuration from some directory
        for some environment:
             fuel --env 1 network --verify --dir path/to/directory
     """
     env = Environment(params.env)
     response = env.verify_network()
     print("Verification status is '{status}'. message: {message}".format(**response))
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:8,代码来源:network.py

示例9: list

 def list(self, params):
     """To list all health check test sets:
             fuel --env 1 health
         or:
             fuel --env 1 health --list
     """
     env = Environment(params.env)
     test_sets = env.get_testsets()
     self.serializer.print_to_output(test_sets, format_table(test_sets))
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:9,代码来源:health.py

示例10: upload

 def upload(self, params):
     """To upload network configuration from some
        directory for some environment:
             fuel --env 1 network --upload --dir path/to/directory
     """
     env = Environment(params.env)
     network_data = env.read_network_data(directory=params.dir, serializer=self.serializer)
     env.set_network_data(network_data)
     print("Network configuration uploaded.")
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:9,代码来源:network.py

示例11: delete

 def delete(self, params):
     """Also {action_name} information can be left or
        taken from specific directory:
             fuel --env 1 {action_name} --upload \\
             --dir path/to/some/directory
     """
     env = Environment(params.env)
     env.delete_facts(self.action_name)
     print("{0} facts deleted.".format(self.action_name))
开发者ID:Axam,项目名称:fuel-web,代码行数:9,代码来源:fact.py

示例12: get_fuel_node_ip

def get_fuel_node_ip(env):
    fuel_node_ip = None
    from fuelclient.objects.environment import Environment
    e = Environment(env)
    nodes_id = [x.data['id'] for x in e.get_all_nodes()]
    for fact in e.get_default_facts('deployment', [nodes_id[0]]):
        fuel_node_ip = fact['master_ip']
        if fuel_node_ip:
            break
    return fuel_node_ip
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:10,代码来源:utils.py

示例13: upload

 def upload(self, params):
     """To upload settings for some environment from some directory:
             fuel --env 1 settings --upload --dir path/to/directory
     """
     env = Environment(params.env)
     settings_data = env.read_settings_data(
         directory=params.dir,
         serializer=self.serializer
     )
     env.set_settings_data(settings_data, params.force)
     print("Settings configuration uploaded.")
开发者ID:heartpandora,项目名称:python-fuelclient,代码行数:11,代码来源:settings.py

示例14: download

 def download(self, params):
     """To download network configuration in this
        directory for some environment:
             fuel --env 1 network --download
     """
     env = Environment(params.env)
     network_data = env.get_network_data()
     network_file_path = env.write_network_data(network_data, directory=params.dir, serializer=self.serializer)
     print(
         "Network configuration for environment with id={0}" " downloaded to {1}".format(env.id, network_file_path)
     )
开发者ID:tinyxiao,项目名称:python-fuelclient,代码行数:11,代码来源:network.py

示例15: upload

 def upload(self, params):
     """To upload vmware settings for some environment from some directory:
             fuel --env 1 vmware-settings --upload --dir path/to/directory
     """
     env = Environment(params.env)
     vmware_settings_data = env.read_vmware_settings_data(
         directory=params.dir,
         serializer=self.serializer
     )
     env.set_vmware_settings_data(vmware_settings_data)
     print("Vmware settings configuration uploaded.")
开发者ID:aateem,项目名称:python-fuelclient,代码行数:11,代码来源:settings.py


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