Revision da4a52a3 lib/cmdlib/network.py
b/lib/cmdlib/network.py | ||
---|---|---|
471 | 471 |
for instance in all_instances.values(): |
472 | 472 |
for nic in instance.nics: |
473 | 473 |
if nic.network in network_uuids: |
474 |
network_to_instances[nic.network].append(instance.name)
|
|
474 |
network_to_instances[nic.network].append(instance.uuid)
|
|
475 | 475 |
break |
476 | 476 |
|
477 | 477 |
if query.NETQ_STATS in self.requested_data: |
... | ... | |
541 | 541 |
""" |
542 | 542 |
conflicts = [] |
543 | 543 |
|
544 |
for (_, instance) in lu.cfg.GetMultiInstanceInfo(instances):
|
|
544 |
for instance in instances:
|
|
545 | 545 |
instconflicts = [(idx, nic.ip) |
546 | 546 |
for (idx, nic) in enumerate(instance.nics) |
547 | 547 |
if check_fn(nic)] |
... | ... | |
597 | 597 |
# been acquired |
598 | 598 |
if self.op.conflicts_check: |
599 | 599 |
self.needed_locks[locking.LEVEL_INSTANCE] = \ |
600 |
self.cfg.GetNodeGroupInstances(self.group_uuid) |
|
600 |
self.cfg.GetInstanceNames( |
|
601 |
self.cfg.GetNodeGroupInstances(self.group_uuid)) |
|
601 | 602 |
|
602 | 603 |
def BuildHooksEnv(self): |
603 | 604 |
ret = { |
... | ... | |
617 | 618 |
assert self.group_uuid in owned_groups |
618 | 619 |
|
619 | 620 |
# Check if locked instances are still correct |
620 |
owned_instances = frozenset(self.owned_locks(locking.LEVEL_INSTANCE)) |
|
621 |
owned_instance_names = frozenset(self.owned_locks(locking.LEVEL_INSTANCE))
|
|
621 | 622 |
if self.op.conflicts_check: |
622 |
CheckNodeGroupInstances(self.cfg, self.group_uuid, owned_instances) |
|
623 |
CheckNodeGroupInstances(self.cfg, self.group_uuid, owned_instance_names)
|
|
623 | 624 |
|
624 | 625 |
self.netparams = { |
625 | 626 |
constants.NIC_MODE: self.network_mode, |
... | ... | |
640 | 641 |
elif self.op.conflicts_check: |
641 | 642 |
pool = network.AddressPool(self.cfg.GetNetwork(self.network_uuid)) |
642 | 643 |
|
643 |
_NetworkConflictCheck(self, lambda nic: pool.Contains(nic.ip), |
|
644 |
"connect to", owned_instances) |
|
644 |
_NetworkConflictCheck( |
|
645 |
self, lambda nic: pool.Contains(nic.ip), "connect to", |
|
646 |
self.cfg.GetMultiInstanceInfoByName(owned_instance_names)) |
|
645 | 647 |
|
646 | 648 |
def Exec(self, feedback_fn): |
647 | 649 |
# Connect the network and update the group only if not already connected |
... | ... | |
678 | 680 |
# Lock instances optimistically, needs verification once group lock has |
679 | 681 |
# been acquired |
680 | 682 |
self.needed_locks[locking.LEVEL_INSTANCE] = \ |
681 |
self.cfg.GetNodeGroupInstances(self.group_uuid) |
|
683 |
self.cfg.GetInstanceNames( |
|
684 |
self.cfg.GetNodeGroupInstances(self.group_uuid)) |
|
682 | 685 |
|
683 | 686 |
def BuildHooksEnv(self): |
684 | 687 |
ret = { |
... | ... | |
708 | 711 |
|
709 | 712 |
# We need this check only if network is not already connected |
710 | 713 |
else: |
711 |
_NetworkConflictCheck(self, lambda nic: nic.network == self.network_uuid, |
|
712 |
"disconnect from", owned_instances) |
|
714 |
_NetworkConflictCheck( |
|
715 |
self, lambda nic: nic.network == self.network_uuid, "disconnect from", |
|
716 |
self.cfg.GetMultiInstanceInfoByName(owned_instances)) |
|
713 | 717 |
|
714 | 718 |
def Exec(self, feedback_fn): |
715 | 719 |
# Disconnect the network and update the group only if network is connected |
Also available in: Unified diff