Revision 8b2eda35 lib/cmdlib/network.py
b/lib/cmdlib/network.py | ||
---|---|---|
30 | 30 |
from ganeti import query |
31 | 31 |
from ganeti import utils |
32 | 32 |
from ganeti.cmdlib.base import LogicalUnit, NoHooksLU, QueryBase |
33 |
from ganeti.cmdlib.common import ShareAll, CheckNodeGroupInstances
|
|
33 |
from ganeti.cmdlib.common import ShareAll |
|
34 | 34 |
|
35 | 35 |
|
36 | 36 |
def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6, |
... | ... | |
580 | 580 |
self.group_uuid = self.cfg.LookupNodeGroup(self.group_name) |
581 | 581 |
|
582 | 582 |
self.needed_locks = { |
583 |
locking.LEVEL_INSTANCE: [], |
|
584 | 583 |
locking.LEVEL_NODEGROUP: [self.group_uuid], |
585 | 584 |
} |
586 |
self.share_locks[locking.LEVEL_INSTANCE] = 1 |
|
587 | 585 |
|
588 | 586 |
if self.op.conflicts_check: |
587 |
self.needed_locks[locking.LEVEL_INSTANCE] = locking.ALL_SET |
|
589 | 588 |
self.needed_locks[locking.LEVEL_NETWORK] = [self.network_uuid] |
590 | 589 |
self.share_locks[locking.LEVEL_NETWORK] = 1 |
590 |
self.share_locks[locking.LEVEL_INSTANCE] = 1 |
|
591 | 591 |
|
592 | 592 |
def DeclareLocks(self, level): |
593 |
if level == locking.LEVEL_INSTANCE: |
|
594 |
assert not self.needed_locks[locking.LEVEL_INSTANCE] |
|
595 |
|
|
596 |
# Lock instances optimistically, needs verification once group lock has |
|
597 |
# been acquired |
|
598 |
if self.op.conflicts_check: |
|
599 |
self.needed_locks[locking.LEVEL_INSTANCE] = \ |
|
600 |
self.cfg.GetNodeGroupInstances(self.group_uuid) |
|
593 |
pass |
|
601 | 594 |
|
602 | 595 |
def BuildHooksEnv(self): |
603 | 596 |
ret = { |
... | ... | |
618 | 611 |
|
619 | 612 |
# Check if locked instances are still correct |
620 | 613 |
owned_instances = frozenset(self.owned_locks(locking.LEVEL_INSTANCE)) |
621 |
if self.op.conflicts_check: |
|
622 |
CheckNodeGroupInstances(self.cfg, self.group_uuid, owned_instances) |
|
623 | 614 |
|
624 | 615 |
self.netparams = { |
625 | 616 |
constants.NIC_MODE: self.network_mode, |
... | ... | |
666 | 657 |
self.group_uuid = self.cfg.LookupNodeGroup(self.group_name) |
667 | 658 |
|
668 | 659 |
self.needed_locks = { |
669 |
locking.LEVEL_INSTANCE: [],
|
|
660 |
locking.LEVEL_INSTANCE: locking.ALL_SET,
|
|
670 | 661 |
locking.LEVEL_NODEGROUP: [self.group_uuid], |
671 | 662 |
} |
672 | 663 |
self.share_locks[locking.LEVEL_INSTANCE] = 1 |
673 | 664 |
|
674 | 665 |
def DeclareLocks(self, level): |
675 |
if level == locking.LEVEL_INSTANCE: |
|
676 |
assert not self.needed_locks[locking.LEVEL_INSTANCE] |
|
677 |
|
|
678 |
# Lock instances optimistically, needs verification once group lock has |
|
679 |
# been acquired |
|
680 |
self.needed_locks[locking.LEVEL_INSTANCE] = \ |
|
681 |
self.cfg.GetNodeGroupInstances(self.group_uuid) |
|
666 |
pass |
|
682 | 667 |
|
683 | 668 |
def BuildHooksEnv(self): |
684 | 669 |
ret = { |
... | ... | |
697 | 682 |
|
698 | 683 |
# Check if locked instances are still correct |
699 | 684 |
owned_instances = frozenset(self.owned_locks(locking.LEVEL_INSTANCE)) |
700 |
CheckNodeGroupInstances(self.cfg, self.group_uuid, owned_instances) |
|
701 | 685 |
|
702 | 686 |
self.group = self.cfg.GetNodeGroup(self.group_uuid) |
703 | 687 |
self.connected = True |
Also available in: Unified diff