本文整理匯總了Python中cloudinstall.placement.controller.PlacementController.is_assigned_to方法的典型用法代碼示例。如果您正苦於以下問題:Python PlacementController.is_assigned_to方法的具體用法?Python PlacementController.is_assigned_to怎麽用?Python PlacementController.is_assigned_to使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloudinstall.placement.controller.PlacementController
的用法示例。
在下文中一共展示了PlacementController.is_assigned_to方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PlacementControllerTestCase
# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import is_assigned_to [as 別名]
#.........這裏部分代碼省略.........
m2 = next((m for m in singlepc.machines_pending()
if m.instance_id == 'fake_iid_2'))
self.assertEqual(m2.constraints, {'cpu': 8})
def test_load_error_mismatch_charm_name(self):
"""Should safely ignore (and log) a charm name in a placement file
that can't be matched to a loaded charm class."""
singlepc = PlacementController(None, self.conf)
fake_assignments = {
'fake_iid': {
'constraints': {},
'assignments': {'KVM':
['non-existent']}},
'fake_iid_2': {
'constraints': {'cpu': 8},
'assignments':
{'BareMetal': ['nova-compute']}}}
with TemporaryFile(mode='w+', encoding='utf-8') as tempf:
yaml.dump(fake_assignments, tempf)
tempf.seek(0)
singlepc.load(tempf)
self.assertEqual(set([m.instance_id for m in
singlepc.machines_pending()]),
set(['fake_iid_2']))
m2 = next((m for m in singlepc.machines_pending()
if m.instance_id == 'fake_iid_2'))
self.assertEqual(m2.constraints, {'cpu': 8})
def test_is_assigned_to_is_deployed_to(self):
self.assertFalse(self.pc.is_assigned_to(CharmSwiftProxy,
self.mock_machine))
self.assertFalse(self.pc.is_deployed_to(CharmSwiftProxy,
self.mock_machine))
self.pc.assign(self.mock_machine, CharmSwiftProxy, AssignmentType.LXC)
self.assertFalse(self.pc.is_deployed_to(CharmSwiftProxy,
self.mock_machine))
self.assertTrue(self.pc.is_assigned_to(CharmSwiftProxy,
self.mock_machine))
self.pc.mark_deployed(self.mock_machine, CharmSwiftProxy,
AssignmentType.LXC)
self.assertTrue(self.pc.is_deployed_to(CharmSwiftProxy,
self.mock_machine))
self.assertFalse(self.pc.is_assigned_to(CharmSwiftProxy,
self.mock_machine))
def test_double_clear_ok(self):
"""clearing assignments for a machine that isn't assigned (anymore) is
OK and should do nothing
"""
self.pc.assign(self.mock_machine, CharmSwiftProxy, AssignmentType.LXC)
self.pc.clear_assignments(self.mock_machine)
self.pc.clear_assignments(self.mock_machine)
self.pc.clear_assignments(self.mock_machine_2)
def test_gen_defaults_raises_with_no_maas_state(self):
pc = PlacementController(None, self.conf)
self.assertRaises(PlacementError, pc.gen_defaults)
# FIXME: Not sure whats going on with this test, assume
# its from the maas-tag addition. Also not sure why
# it fails now and not in previous commit?