• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python shared.create_node函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_node_get_all_with_empty_filters

    def test_node_get_all_with_empty_filters(self):
        shared.create_node(self.ctx, None, self.profile, name='node1')
        shared.create_node(self.ctx, None, self.profile, name='node2')

        filters = None
        results = db_api.node_get_all(self.ctx, filters=filters)
        self.assertEqual(2, len(results))
开发者ID:onesafe,项目名称:senlin,代码行数:7,代码来源:test_node_api.py


示例2: test_node_get_all_with_limit_marker

    def test_node_get_all_with_limit_marker(self):
        node_ids = ['node1', 'node2', 'node3']
        for v in node_ids:
            shared.create_node(self.ctx, self.cluster, self.profile,
                               id=v, init_at=tu.utcnow())

        nodes = db_api.node_get_all(self.ctx, limit=1)
        self.assertEqual(1, len(nodes))

        nodes = db_api.node_get_all(self.ctx, limit=2)
        self.assertEqual(2, len(nodes))

        nodes = db_api.node_get_all(self.ctx, limit=5)
        self.assertEqual(3, len(nodes))

        nodes = db_api.node_get_all(self.ctx, marker='node1')
        self.assertEqual(2, len(nodes))

        nodes = db_api.node_get_all(self.ctx, marker='node2')
        self.assertEqual(1, len(nodes))

        nodes = db_api.node_get_all(self.ctx, marker='node3')
        self.assertEqual(0, len(nodes))

        nodes = db_api.node_get_all(self.ctx, limit=1, marker='node1')
        self.assertEqual(1, len(nodes))
开发者ID:onesafe,项目名称:senlin,代码行数:26,代码来源:test_node_api.py


示例3: test_node_get_all_sorting

    def test_node_get_all_sorting(self):
        values = [{'id': '001', 'name': 'node1', 'status': 'ACTIVE'},
                  {'id': '002', 'name': 'node3', 'status': 'ERROR'},
                  {'id': '003', 'name': 'node2', 'status': 'UPDATING'}]
        for v in values:
            shared.create_node(self.ctx, self.cluster, self.profile, **v)

        nodes = db_api.node_get_all(self.ctx, sort='name,status')
        self.assertEqual(3, len(nodes))
        # Sorted by name
        self.assertEqual('001', nodes[0].id)
        self.assertEqual('003', nodes[1].id)
        self.assertEqual('002', nodes[2].id)

        nodes = db_api.node_get_all(self.ctx, sort='status,name')
        self.assertEqual(3, len(nodes))
        # Sorted by statuses (ascending)
        self.assertEqual('001', nodes[0].id)
        self.assertEqual('002', nodes[1].id)
        self.assertEqual('003', nodes[2].id)

        nodes = db_api.node_get_all(self.ctx, sort='status:desc,name:desc')
        self.assertEqual(3, len(nodes))
        # Sorted by statuses (descending)
        self.assertEqual('003', nodes[0].id)
        self.assertEqual('002', nodes[1].id)
        self.assertEqual('001', nodes[2].id)
开发者ID:onesafe,项目名称:senlin,代码行数:27,代码来源:test_node_api.py


示例4: test_node_get_by_cluster

    def test_node_get_by_cluster(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)

        node0 = shared.create_node(self.ctx, None, self.profile)
        node1 = shared.create_node(self.ctx, self.cluster, self.profile)
        node2 = shared.create_node(self.ctx, self.cluster, self.profile)
        node3 = shared.create_node(self.ctx, cluster1, self.profile)

        nodes = db_api.node_get_all_by_cluster(self.ctx, self.cluster.id)
        self.assertEqual(2, len(nodes))
        self.assertEqual(set([node1.id, node2.id]),
                         set([nodes[0].id, nodes[1].id]))

        # retrieve orphan nodes
        nodes = db_api.node_get_all_by_cluster(self.ctx, '')
        self.assertEqual(1, len(nodes))
        self.assertEqual(node0.id, nodes[0].id)

        # retrieve all nodes
        nodes = db_api.node_get_all_by_cluster(self.ctx, None)
        self.assertEqual(4, len(nodes))
        self.assertEqual(node0.id, nodes[0].id)

        nodes = db_api.node_get_all_by_cluster(self.ctx, cluster1.id)
        self.assertEqual(1, len(nodes))
        self.assertEqual(node3.id, nodes[0].id)
开发者ID:onesafe,项目名称:senlin,代码行数:26,代码来源:test_node_api.py


示例5: test_node_count_by_cluster

    def test_node_count_by_cluster(self):
        shared.create_cluster(self.ctx, self.profile)

        shared.create_node(self.ctx, self.cluster, self.profile)
        shared.create_node(self.ctx, self.cluster, self.profile)

        res = db_api.node_count_by_cluster(self.ctx, self.cluster.id)
        self.assertEqual(2, res)
开发者ID:onesafe,项目名称:senlin,代码行数:8,代码来源:test_node_api.py


示例6: test_node_get_all_with_admin_context

    def test_node_get_all_with_admin_context(self):
        shared.create_node(self.ctx, None, self.profile, name='node1')
        shared.create_node(self.ctx, None, self.profile, name='node2')

        admin_ctx = utils.dummy_context(project='a_different_project',
                                        is_admin=True)
        results = db_api.node_get_all(admin_ctx, project_safe=True)
        self.assertEqual(2, len(results))
开发者ID:onesafe,项目名称:senlin,代码行数:8,代码来源:test_node_api.py


示例7: test_node_get_by_name

    def test_node_get_by_name(self):
        shared.create_node(self.ctx, self.cluster, self.profile)
        node = db_api.node_get_by_name(self.ctx, 'test_node_name')
        self.assertIsNotNone(node)
        self.assertEqual('test_node_name', node.name)
        self.assertEqual(self.cluster.id, node.cluster_id)

        res = db_api.node_get_by_name(self.ctx, 'BogusName')
        self.assertIsNone(res)
开发者ID:onesafe,项目名称:senlin,代码行数:9,代码来源:test_node_api.py


示例8: test_node_get_by_short_id_admin_context

    def test_node_get_by_short_id_admin_context(self):
        node_id = 'same-part-unique-part'
        shared.create_node(self.ctx, None, self.profile,
                           id=node_id, name='node-1')

        admin_ctx = utils.dummy_context(project='a_different_project',
                                        is_admin=True)
        res = db_api.node_get_by_short_id(admin_ctx, node_id[:11],
                                          project_safe=True)
        self.assertIsNotNone(res)
开发者ID:onesafe,项目名称:senlin,代码行数:10,代码来源:test_node_api.py


示例9: test_node_count_by_cluster_admin_context

    def test_node_count_by_cluster_admin_context(self):
        shared.create_cluster(self.ctx, self.profile)
        shared.create_node(self.ctx, self.cluster, self.profile)
        shared.create_node(self.ctx, self.cluster, self.profile)

        admin_ctx = utils.dummy_context(project='a_different_project',
                                        is_admin=True)
        res = db_api.node_count_by_cluster(admin_ctx, self.cluster.id,
                                           project_safe=True)
        self.assertEqual(2, res)
开发者ID:onesafe,项目名称:senlin,代码行数:10,代码来源:test_node_api.py


示例10: test_node_get_by_physical_id

    def test_node_get_by_physical_id(self):
        shared.create_node(self.ctx, self.cluster, self.profile,
                           physical_id=UUID1)

        node = db_api.node_get_by_physical_id(self.ctx, UUID1)
        self.assertIsNotNone(node)
        self.assertEqual(UUID1, node.physical_id)

        node = db_api.node_get_by_physical_id(self.ctx, UUID2)
        self.assertIsNone(node)
开发者ID:KongJustin,项目名称:senlin,代码行数:10,代码来源:test_node_api.py


示例11: test_node_get_by_name_diff_project

    def test_node_get_by_name_diff_project(self):
        shared.create_node(self.ctx, self.cluster, self.profile)
        res = db_api.node_get_by_name(self.ctx, 'test_node_name')
        self.assertIsNotNone(res)

        ctx_new = utils.dummy_context(project='a_different_project')
        res = db_api.node_get_by_name(ctx_new, 'test_node_name')
        self.assertIsNone(res)
        res = db_api.node_get_by_name(ctx_new, 'test_node_name',
                                      project_safe=False)
        self.assertIsNotNone(res)
开发者ID:onesafe,项目名称:senlin,代码行数:11,代码来源:test_node_api.py


示例12: test_node_get_all_with_cluster_id

    def test_node_get_all_with_cluster_id(self):
        values = [{'name': 'node1'}, {'name': 'node2'}, {'name': 'node3'}]
        for v in values:
            shared.create_node(self.ctx, self.cluster, self.profile, **v)
        shared.create_node(self.ctx, None, self.profile, name='node0')

        nodes = db_api.node_get_all(self.ctx, cluster_id=self.cluster.id)
        self.assertEqual(3, len(nodes))

        names = [node.name for node in nodes]
        [self.assertIn(val['name'], names) for val in values]
开发者ID:onesafe,项目名称:senlin,代码行数:11,代码来源:test_node_api.py


示例13: test_event_get_all_by_cluster

    def test_event_get_all_by_cluster(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        cluster2 = shared.create_cluster(self.ctx, self.profile)
        node1_1 = shared.create_node(self.ctx, cluster1, self.profile)
        node1_2 = shared.create_node(self.ctx, cluster1, self.profile)
        node2_1 = shared.create_node(self.ctx, cluster2, self.profile)
        node_orphan = shared.create_node(self.ctx, None, self.profile)

        # 1 event for cluster 1
        self.create_event(self.ctx, entity=cluster1)
        events = db_api.event_get_all_by_cluster(self.ctx, cluster1.id)
        self.assertEqual(1, len(events))
        events = db_api.event_get_all_by_cluster(self.ctx, cluster2.id)
        self.assertEqual(0, len(events))

        # two more events for cluster 1, with one for an orphan node
        self.create_event(self.ctx, entity=node1_1)
        self.create_event(self.ctx, entity=node1_2)
        self.create_event(self.ctx, entity=node_orphan)

        events = db_api.event_get_all_by_cluster(self.ctx, cluster1.id)
        self.assertEqual(3, len(events))
        events = db_api.event_get_all_by_cluster(self.ctx, cluster2.id)
        self.assertEqual(0, len(events))

        # one more events for cluster 2, with one for an orphan node
        self.create_event(self.ctx, entity=cluster2)
        self.create_event(self.ctx, entity=node_orphan)

        events = db_api.event_get_all_by_cluster(self.ctx, cluster1.id)
        self.assertEqual(3, len(events))
        events = db_api.event_get_all_by_cluster(self.ctx, cluster2.id)
        self.assertEqual(1, len(events))

        # two more events for cluster 2, with one for an orphan node
        self.create_event(self.ctx, entity=node2_1)
        self.create_event(self.ctx, entity=node2_1)
        self.create_event(self.ctx, entity=node_orphan)

        events = db_api.event_get_all_by_cluster(self.ctx, cluster1.id)
        self.assertEqual(3, len(events))
        events = db_api.event_get_all_by_cluster(self.ctx, cluster2.id)
        self.assertEqual(3, len(events))

        # two more events for cluster 1, with one for an orphan node
        self.create_event(self.ctx, entity=cluster1)
        self.create_event(self.ctx, entity=node1_1)
        self.create_event(self.ctx, entity=node_orphan)

        events = db_api.event_get_all_by_cluster(self.ctx, cluster1.id)
        self.assertEqual(5, len(events))
        events = db_api.event_get_all_by_cluster(self.ctx, cluster2.id)
        self.assertEqual(3, len(events))
开发者ID:jonnary,项目名称:senlin,代码行数:53,代码来源:test_event_api.py


示例14: test_node_get_by_cluster_admin_context

    def test_node_get_by_cluster_admin_context(self):
        shared.create_cluster(self.ctx, self.profile)

        node1 = shared.create_node(self.ctx, self.cluster, self.profile)
        node2 = shared.create_node(self.ctx, self.cluster, self.profile)

        admin_ctx = utils.dummy_context(project='a_different_project',
                                        is_admin=True)
        nodes = db_api.node_get_all_by_cluster(admin_ctx, self.cluster.id)
        self.assertEqual(2, len(nodes))
        self.assertEqual(set([node1.id, node2.id]),
                         set([nodes[0].id, nodes[1].id]))
开发者ID:onesafe,项目名称:senlin,代码行数:12,代码来源:test_node_api.py


示例15: test_node_get_by_short_id_diff_project

    def test_node_get_by_short_id_diff_project(self):
        node_id = 'same-part-unique-part'
        shared.create_node(self.ctx, None, self.profile,
                           id=node_id, name='node-1')
        res = db_api.node_get_by_short_id(self.ctx, node_id[:11])
        self.assertIsNotNone(res)

        ctx_new = utils.dummy_context(project='a_different_project')
        res = db_api.node_get_by_short_id(ctx_new, node_id[:11])
        self.assertIsNone(res)
        res = db_api.node_get_by_short_id(ctx_new, node_id[:11],
                                          project_safe=False)
        self.assertIsNotNone(res)
开发者ID:onesafe,项目名称:senlin,代码行数:13,代码来源:test_node_api.py


示例16: test_node_count_by_cluster_diff_project

    def test_node_count_by_cluster_diff_project(self):
        ctx_new = utils.dummy_context(project='a_different_project')
        shared.create_cluster(self.ctx, self.profile)

        shared.create_node(self.ctx, self.cluster, self.profile)
        shared.create_node(self.ctx, self.cluster, self.profile)

        res = db_api.node_count_by_cluster(ctx_new, self.cluster.id)
        self.assertEqual(0, res)

        res = db_api.node_count_by_cluster(ctx_new, self.cluster.id,
                                           project_safe=False)
        self.assertEqual(2, res)
开发者ID:onesafe,项目名称:senlin,代码行数:13,代码来源:test_node_api.py


示例17: test_node_get_all_with_filters

    def test_node_get_all_with_filters(self):
        shared.create_node(self.ctx, None, self.profile, name='node1')
        shared.create_node(self.ctx, None, self.profile, name='node2')

        filters = {'name': ['node1', 'nodex']}
        results = db_api.node_get_all(self.ctx, filters=filters)
        self.assertEqual(1, len(results))
        self.assertEqual('node1', results[0]['name'])

        filters = {'name': 'node1'}
        results = db_api.node_get_all(self.ctx, filters=filters)
        self.assertEqual(1, len(results))
        self.assertEqual('node1', results[0]['name'])
开发者ID:onesafe,项目名称:senlin,代码行数:13,代码来源:test_node_api.py


示例18: test_node_get_all_used_sort_keys

    def test_node_get_all_used_sort_keys(self, mock_paginate):
        node_ids = ['node1', 'node2', 'node3']
        for v in node_ids:
            shared.create_node(self.ctx, self.cluster, self.profile, id=v)

        sort = ','.join(consts.NODE_SORT_KEYS)

        db_api.node_get_all(self.ctx, sort=sort)
        args = mock_paginate.call_args[0]
        used_sort_keys = set(args[3])
        sort_keys = consts.NODE_SORT_KEYS
        sort_keys.append('id')
        expected_keys = set(sort_keys)
        self.assertEqual(expected_keys, used_sort_keys)
开发者ID:onesafe,项目名称:senlin,代码行数:14,代码来源:test_node_api.py


示例19: test_node_get_all_with_project_safe

    def test_node_get_all_with_project_safe(self):
        shared.create_node(self.ctx, None, self.profile, name='node1')
        shared.create_node(self.ctx, None, self.profile, name='node2')

        self.ctx.project = 'a-different-project'
        results = db_api.node_get_all(self.ctx, project_safe=False)
        self.assertEqual(2, len(results))

        self.ctx.project = 'a-different-project'
        results = db_api.node_get_all(self.ctx)
        self.assertEqual(0, len(results))

        results = db_api.node_get_all(self.ctx, project_safe=True)
        self.assertEqual(0, len(results))
开发者ID:onesafe,项目名称:senlin,代码行数:14,代码来源:test_node_api.py


示例20: test_node_get_by_physical_id_diff_project

    def test_node_get_by_physical_id_diff_project(self):
        shared.create_node(self.ctx, self.cluster, self.profile,
                           physical_id=UUID1)

        node = db_api.node_get_by_physical_id(self.ctx, UUID1)
        self.assertIsNotNone(node)
        self.assertEqual(UUID1, node.physical_id)

        ctx_new = utils.dummy_context(project='a_different_project')
        node = db_api.node_get_by_physical_id(ctx_new, UUID1)
        self.assertIsNone(node)
        node = db_api.node_get_by_physical_id(ctx_new, UUID1,
                                              project_safe=False)
        self.assertIsNotNone(node)
开发者ID:Tennyson53,项目名称:senlin,代码行数:14,代码来源:test_node_api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python shared.create_profile函数代码示例发布时间:2022-05-27
下一篇:
Python shared.create_cluster函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap