當前位置: 首頁>>代碼示例>>Python>>正文


Python PlacementController.get_charm_state方法代碼示例

本文整理匯總了Python中cloudinstall.placement.controller.PlacementController.get_charm_state方法的典型用法代碼示例。如果您正苦於以下問題:Python PlacementController.get_charm_state方法的具體用法?Python PlacementController.get_charm_state怎麽用?Python PlacementController.get_charm_state使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cloudinstall.placement.controller.PlacementController的用法示例。


在下文中一共展示了PlacementController.get_charm_state方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: PlacementControllerTestCase

# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import get_charm_state [as 別名]

#.........這裏部分代碼省略.........
    def test_mark_deployed_unsets_assignment(self):
        "Setting a placement to deployed removes it from assignment dict"
        self.pc.assign(self.mock_machine, CharmKeystone, AssignmentType.KVM)
        self.assertEqual([CharmKeystone], self.pc.assigned_charm_classes())
        self.pc.mark_deployed(self.mock_machine, CharmKeystone,
                              AssignmentType.KVM)
        self.assertEqual([CharmKeystone], self.pc.deployed_charm_classes())
        self.assertEqual([], self.pc.assigned_charm_classes())

    def test_set_deployed_unsets_assignment_only_once(self):
        "Setting a placement to deployed removes it from assignment dict"
        self.pc.assign(self.mock_machine, CharmNovaCompute, AssignmentType.KVM)
        self.pc.assign(self.mock_machine_2, CharmNovaCompute,
                       AssignmentType.KVM)
        self.assertEqual([CharmNovaCompute], self.pc.assigned_charm_classes())
        ad = self.pc.get_assignments(CharmNovaCompute)
        dd = self.pc.get_deployments(CharmNovaCompute)
        from pprint import pformat
        print("Assignments is {}".format(pformat(ad)))
        print("Deployments is {}".format(pformat(dd)))
        self.assertEqual(set([self.mock_machine, self.mock_machine_2]),
                         set(ad[AssignmentType.KVM]))
        self.assertEqual(len(dd.items()), 0)

        self.pc.mark_deployed(self.mock_machine, CharmNovaCompute,
                              AssignmentType.KVM)
        self.assertEqual([CharmNovaCompute], self.pc.deployed_charm_classes())
        self.assertEqual([CharmNovaCompute], self.pc.assigned_charm_classes())
        ad = self.pc.get_assignments(CharmNovaCompute)
        dd = self.pc.get_deployments(CharmNovaCompute)
        self.assertEqual([self.mock_machine_2], ad[AssignmentType.KVM])
        self.assertEqual([self.mock_machine], dd[AssignmentType.KVM])

    def test_get_charm_state(self):
        "Test a sampling of required services and special handling for compute"
        self.assertEqual(self.pc.get_charm_state(CharmKeystone)[0],
                         CharmState.REQUIRED)
        self.assertEqual(self.pc.get_charm_state(CharmNovaCompute)[0],
                         CharmState.REQUIRED)

    def test_one_compute_required(self):
        """after being assigned at least once, novacompute is no longer
        considered 'required' (aka required)"""
        self.pc.assign(self.mock_machine, CharmNovaCompute, AssignmentType.LXC)
        self.assertNotEqual(self.pc.get_charm_state(CharmNovaCompute)[0],
                            CharmState.REQUIRED)

    def test_swift_unrequired_then_required_default(self):
        "Swift and swift-proxy are both optional until you add swift"
        self.assertEqual(CharmState.OPTIONAL,
                         self.pc.get_charm_state(CharmSwift)[0])
        self.assertEqual(CharmState.OPTIONAL,
                         self.pc.get_charm_state(CharmSwiftProxy)[0])
        self.pc.assign(self.mock_machine, CharmSwift, AssignmentType.LXC)
        self.assertEqual(CharmState.REQUIRED,
                         self.pc.get_charm_state(CharmSwift)[0])
        self.assertEqual(CharmState.REQUIRED,
                         self.pc.get_charm_state(CharmSwiftProxy)[0])

    def test_swift_proxy_unrequired_then_required_default(self):
        "Swift and swift-proxy are both optional until you add swift-proxy"
        self.assertEqual(CharmState.OPTIONAL,
                         self.pc.get_charm_state(CharmSwift)[0])
        self.assertEqual(CharmState.OPTIONAL,
                         self.pc.get_charm_state(CharmSwiftProxy)[0])
開發者ID:laboshinl,項目名稱:openstack-installer,代碼行數:69,代碼來源:test_placement_controller.py


注:本文中的cloudinstall.placement.controller.PlacementController.get_charm_state方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。