本文整理匯總了Python中cloudinstall.placement.controller.PlacementController.mark_deployed方法的典型用法代碼示例。如果您正苦於以下問題:Python PlacementController.mark_deployed方法的具體用法?Python PlacementController.mark_deployed怎麽用?Python PlacementController.mark_deployed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloudinstall.placement.controller.PlacementController
的用法示例。
在下文中一共展示了PlacementController.mark_deployed方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PlacementControllerTestCase
# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import mark_deployed [as 別名]
#.........這裏部分代碼省略.........
def test_assigned_charm_classes_starts_empty(self):
self.assertEqual(0, len(self.pc.assigned_charm_classes()))
def test_reset_unassigned_undeployed_none(self):
"""Assign all charms, ensure that unassigned is empty"""
for cc in self.pc.charm_classes():
self.pc.assign(self.mock_machine, cc, AssignmentType.LXC)
self.pc.reset_assigned_deployed()
self.assertEqual(0, len(self.pc.unassigned_undeployed_services()))
def test_reset_unassigned_undeployed_two(self):
self.pc.assign(self.mock_machine, CharmNovaCompute, AssignmentType.LXC)
self.pc.assign(self.mock_machine_2, CharmKeystone, AssignmentType.KVM)
self.pc.reset_assigned_deployed()
self.assertEqual(len(self.pc.charm_classes()) - 2,
len(self.pc.unassigned_undeployed_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_assigned_deployed()
self.assertEqual(len(self.pc.unassigned_undeployed_services()), 1)
def test_unassigned_undeployed(self):
all_charms = set(self.pc.charm_classes())
self.pc.assign(self.mock_machine, CharmKeystone, AssignmentType.KVM)
self.pc.assign(self.mock_machine, CharmNovaCompute, AssignmentType.KVM)
self.pc.mark_deployed(self.mock_machine, CharmKeystone,
AssignmentType.KVM)
self.assertTrue(CharmKeystone not in
self.pc.unassigned_undeployed_services())
self.assertTrue(CharmNovaCompute not in
self.pc.unassigned_undeployed_services())
self.assertTrue(self.pc.is_deployed(CharmKeystone))
self.assertTrue(self.pc.is_assigned(CharmNovaCompute))
self.assertTrue(len(all_charms) - 2,
len(self.pc.unassigned_undeployed_services()))
n_k_as = self.pc.assignment_machine_count_for_charm(CharmKeystone)
self.assertEqual(n_k_as, 0)
n_k_dl = self.pc.deployment_machine_count_for_charm(CharmKeystone)
self.assertEqual(n_k_dl, 1)
n_nc_as = self.pc.assignment_machine_count_for_charm(CharmNovaCompute)
self.assertEqual(n_nc_as, 1)
n_nc_dl = self.pc.deployment_machine_count_for_charm(CharmNovaCompute)
self.assertEqual(n_nc_dl, 0)
def test_deployed_charms_starts_empty(self):
"Initially there are no deployed charms"
self.assertEqual(0, len(self.pc.deployed_charm_classes()))
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())
示例2: __init__
# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import mark_deployed [as 別名]
#.........這裏部分代碼省略.........
config=self.config)
asts = self.placement_controller.get_assignments(charm_class)
errs = []
first_deploy = True
for atype, ml in asts.items():
for machine in ml:
mspec = self.get_machine_spec(machine, atype)
if mspec is None:
errs.append(machine)
continue
if first_deploy:
msg = "Deploying {c}".format(c=charm_class.display_name)
if mspec != '':
msg += " to machine {mspec}".format(mspec=mspec)
self.ui.status_info_message(msg)
deploy_err = charm.deploy(mspec)
if deploy_err:
errs.append(machine)
else:
first_deploy = False
else:
# service already deployed, need to add-unit
msg = ("Adding one unit of "
"{c}".format(c=charm_class.display_name))
if mspec != '':
msg += " to machine {mspec}".format(mspec=mspec)
self.ui.status_info_message(msg)
deploy_err = charm.add_unit(machine_spec=mspec)
if deploy_err:
errs.append(machine)
if not deploy_err:
self.placement_controller.mark_deployed(machine,
charm_class,
atype)
had_err = len(errs) > 0
if had_err and not self.config.getopt('headless'):
log.warning("deferred deploying to these machines: {}".format(
errs))
return had_err
def get_machine_spec(self, maas_machine, atype):
"""Given a machine and assignment type, return a juju machine spec.
Returns None on errors, and '' for the subordinate char placeholder.
"""
if self.placement_controller.is_placeholder(maas_machine.instance_id):
# placeholder machines do not use a machine spec
return ""
jm = next((m for m in self.juju_state.machines()
if (m.instance_id == maas_machine.instance_id or
m.machine_id == maas_machine.machine_id)), None)
if jm is None:
log.error("could not find juju machine matching {}"
" (instance id {})".format(maas_machine,
maas_machine.instance_id))
return None
if atype == AssignmentType.BareMetal \
or atype == AssignmentType.DEFAULT:
return jm.machine_id
elif atype == AssignmentType.LXC:
示例3: __init__
# 需要導入模塊: from cloudinstall.placement.controller import PlacementController [as 別名]
# 或者: from cloudinstall.placement.controller.PlacementController import mark_deployed [as 別名]
#.........這裏部分代碼省略.........
config=self.config)
asts = self.placement_controller.get_assignments(charm_class)
errs = []
first_deploy = True
for atype, ml in asts.items():
for machine in ml:
mspec = self.get_machine_spec(machine, atype)
if mspec is None:
errs.append(machine)
continue
if first_deploy:
msg = "Deploying {c}".format(c=charm_class.display_name)
if mspec != '':
msg += " to machine {mspec}".format(mspec=mspec)
self.ui.status_info_message(msg)
deploy_err = charm.deploy(mspec)
if deploy_err:
errs.append(machine)
else:
first_deploy = False
else:
# service already deployed, need to add-unit
msg = ("Adding one unit of "
"{c}".format(c=charm_class.display_name))
if mspec != '':
msg += " to machine {mspec}".format(mspec=mspec)
self.ui.status_info_message(msg)
deploy_err = charm.add_unit(machine_spec=mspec)
if deploy_err:
errs.append(machine)
if not deploy_err:
self.placement_controller.mark_deployed(machine,
charm_class,
atype)
had_err = len(errs) > 0
if had_err and not self.config.getopt('headless'):
log.warning("deferred deploying to these machines: {}".format(
errs))
return had_err
def get_machine_spec(self, maas_machine, atype):
"""Given a machine and assignment type, return a juju machine spec.
Returns None on errors, and '' for the subordinate char placeholder.
"""
if self.placement_controller.is_placeholder(maas_machine.instance_id):
# placeholder machines do not use a machine spec
return ""
jm = next((m for m in self.juju_state.machines()
if (m.instance_id == maas_machine.instance_id or
m.machine_id == maas_machine.machine_id)), None)
if jm is None:
log.error("could not find juju machine matching {}"
" (instance id {})".format(maas_machine,
maas_machine.instance_id))
return None
if atype == AssignmentType.BareMetal \
or atype == AssignmentType.DEFAULT:
return jm.machine_id
elif atype == AssignmentType.LXC: