本文整理匯總了Python中cloudinstall.placement.controller.PlacementController.service_is_required方法的典型用法代碼示例。如果您正苦於以下問題:Python PlacementController.service_is_required方法的具體用法?Python PlacementController.service_is_required怎麽用?Python PlacementController.service_is_required使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloudinstall.placement.controller.PlacementController
的用法示例。
在下文中一共展示了PlacementController.service_is_required方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PlacementControllerTestCase
# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import service_is_required [as 別名]
#.........這裏部分代碼省略.........
self.pc.clear_all_assignments()
# check that it's empty:
self.assertEqual(self.pc.assignments, {})
# and that it's still a defaultdict(lambda: defaultdict(list))
mid = self.mock_machine.machine_id
lxcs = self.pc.assignments[mid][AssignmentType.LXC]
self.assertEqual(lxcs, [])
def test_reset_unplaced_none(self):
"""Assign all charms, ensure that unplaced is empty"""
for cc in self.pc.charm_classes():
self.pc.assign(self.mock_machine, cc, AssignmentType.LXC)
self.pc.reset_unplaced()
self.assertEqual(0, len(self.pc.unplaced_services))
def test_reset_unplaced_two(self):
self.pc.assign(self.mock_machine, CharmNovaCompute, AssignmentType.LXC)
self.pc.assign(self.mock_machine_2, CharmKeystone, AssignmentType.KVM)
self.pc.reset_unplaced()
self.assertEqual(len(self.pc.charm_classes()) - 2,
len(self.pc.unplaced_services))
def test_reset_excepting_compute(self):
for cc in self.pc.charm_classes():
if cc.charm_name == 'nova-compute':
continue
self.pc.assign(self.mock_machine, cc, AssignmentType.LXC)
self.pc.reset_unplaced()
self.assertEqual(len(self.pc.unplaced_services), 1)
def test_service_is_required(self):
"Test a sampling of required services and special handling for compute"
self.assertTrue(self.pc.service_is_required(CharmKeystone))
self.assertTrue(self.pc.service_is_required(CharmNovaCompute))
self.assertFalse(self.pc.service_is_required(CharmJujuGui))
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.assertFalse(self.pc.service_is_required(CharmNovaCompute))
def test_swift_unrequired_then_required(self):
"Swift and swift-proxy are both optional until you add swift"
self.assertFalse(self.pc.service_is_required(CharmSwift))
self.assertFalse(self.pc.service_is_required(CharmSwiftProxy))
self.pc.assign(self.mock_machine, CharmSwift, AssignmentType.LXC)
self.assertTrue(self.pc.service_is_required(CharmSwift))
self.assertTrue(self.pc.service_is_required(CharmSwiftProxy))
def test_swift_proxy_unrequired_then_required(self):
"Swift and swift-proxy are both optional until you add swift-proxy"
self.assertFalse(self.pc.service_is_required(CharmSwift))
self.assertFalse(self.pc.service_is_required(CharmSwiftProxy))
self.pc.assign(self.mock_machine, CharmSwiftProxy, AssignmentType.LXC)
self.assertTrue(self.pc.service_is_required(CharmSwift))
# Only one swift-proxy is required, so now that we've added
# it, it is still not required:
self.assertFalse(self.pc.service_is_required(CharmSwiftProxy))
def test_persistence(self):
self.pc.assign(self.mock_machine, CharmNovaCompute, AssignmentType.LXC)