Revision 3c286190 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
2037 | 2037 |
|
2038 | 2038 |
# Verify global configuration |
2039 | 2039 |
jobs.append([ |
2040 |
opcodes.OpClusterVerifyConfig(ignore_errors=self.op.ignore_errors) |
|
2040 |
opcodes.OpClusterVerifyConfig(ignore_errors=self.op.ignore_errors),
|
|
2041 | 2041 |
]) |
2042 | 2042 |
|
2043 | 2043 |
# Always depend on global verification |
... | ... | |
3189 | 3189 |
|
3190 | 3190 |
""" |
3191 | 3191 |
env = { |
3192 |
"CLUSTER_TAGS": " ".join(self.cfg.GetClusterInfo().GetTags()) |
|
3192 |
"CLUSTER_TAGS": " ".join(self.cfg.GetClusterInfo().GetTags()),
|
|
3193 | 3193 |
} |
3194 | 3194 |
|
3195 | 3195 |
env.update(("NODE_TAGS_%s" % node.name, " ".join(node.GetTags())) |
... | ... | |
8200 | 8200 |
target_node=self.op.target_node, |
8201 | 8201 |
allow_runtime_changes=allow_runtime_changes, |
8202 | 8202 |
ignore_ipolicy=self.op.ignore_ipolicy)] |
8203 |
for inst in _GetNodePrimaryInstances(self.cfg, self.op.node_name) |
|
8204 |
] |
|
8203 |
for inst in _GetNodePrimaryInstances(self.cfg, self.op.node_name)] |
|
8205 | 8204 |
|
8206 | 8205 |
# TODO: Run iallocator in this opcode and pass correct placement options to |
8207 | 8206 |
# OpInstanceMigrate. Since other jobs can modify the cluster between |
... | ... | |
9115 | 9114 |
for i in range(disk_count)]) |
9116 | 9115 |
|
9117 | 9116 |
if template_name == constants.DT_PLAIN: |
9117 |
|
|
9118 | 9118 |
def logical_id_fn(idx, _, disk): |
9119 | 9119 |
vg = disk.get(constants.IDISK_VG, vgname) |
9120 | 9120 |
return (vg, names[idx]) |
9121 |
|
|
9121 | 9122 |
elif template_name in (constants.DT_FILE, constants.DT_SHARED_FILE): |
9122 | 9123 |
logical_id_fn = \ |
9123 | 9124 |
lambda _, disk_index, disk: (file_driver, |
... | ... | |
10292 | 10293 |
if self.op.conflicts_check: |
10293 | 10294 |
_CheckForConflictingIp(self, nic.ip, self.pnode.name) |
10294 | 10295 |
|
10295 |
|
|
10296 | 10296 |
# mirror node verification |
10297 | 10297 |
if self.op.disk_template in constants.DTS_INT_MIRROR: |
10298 | 10298 |
if self.op.snode == pnode.name: |
... | ... | |
12045 | 12045 |
disks=[], |
12046 | 12046 |
mode=constants.REPLACE_DISK_CHG, |
12047 | 12047 |
early_release=self.op.early_release)] |
12048 |
for instance_name in self.instance_names |
|
12049 |
] |
|
12048 |
for instance_name in self.instance_names] |
|
12050 | 12049 |
|
12051 | 12050 |
else: |
12052 | 12051 |
raise errors.ProgrammerError("No iallocator or remote node") |
... | ... | |
12957 | 12956 |
" in cluster" % mac, |
12958 | 12957 |
errors.ECODE_NOTUNIQUE) |
12959 | 12958 |
elif new_net != old_net: |
12959 |
|
|
12960 | 12960 |
def get_net_prefix(net): |
12961 | 12961 |
if net: |
12962 | 12962 |
uuid = self.cfg.LookupNetwork(net) |
... | ... | |
12964 | 12964 |
nobj = self.cfg.GetNetwork(uuid) |
12965 | 12965 |
return nobj.mac_prefix |
12966 | 12966 |
return None |
12967 |
|
|
12967 | 12968 |
new_prefix = get_net_prefix(new_net) |
12968 | 12969 |
old_prefix = get_net_prefix(old_net) |
12969 | 12970 |
if old_prefix != new_prefix: |
... | ... | |
15551 | 15552 |
result = ial.out_text |
15552 | 15553 |
return result |
15553 | 15554 |
|
15555 |
|
|
15554 | 15556 |
# Network LUs |
15555 | 15557 |
class LUNetworkAdd(LogicalUnit): |
15556 | 15558 |
"""Logical unit for creating networks. |
... | ... | |
15590 | 15592 |
self.op.network, errors.ECODE_EXISTS) |
15591 | 15593 |
|
15592 | 15594 |
if self.op.mac_prefix: |
15593 |
utils.NormalizeAndValidateMac(self.op.mac_prefix+":00:00:00")
|
|
15595 |
utils.NormalizeAndValidateMac(self.op.mac_prefix + ":00:00:00")
|
|
15594 | 15596 |
|
15595 | 15597 |
# Check tag validity |
15596 | 15598 |
for tag in self.op.tags: |
15597 | 15599 |
objects.TaggableObject.ValidateTag(tag) |
15598 | 15600 |
|
15599 |
|
|
15600 | 15601 |
def BuildHooksEnv(self): |
15601 | 15602 |
"""Build hooks env. |
15602 | 15603 |
|
... | ... | |
15681 | 15682 |
locking.LEVEL_NETWORK: [self.network_uuid], |
15682 | 15683 |
} |
15683 | 15684 |
|
15684 |
|
|
15685 | 15685 |
def CheckPrereq(self): |
15686 | 15686 |
"""Check prerequisites. |
15687 | 15687 |
|
... | ... | |
15744 | 15744 |
raise errors.OpPrereqError("Cannot modify gateway and reserved ips" |
15745 | 15745 |
" at once", errors.ECODE_INVAL) |
15746 | 15746 |
|
15747 |
|
|
15748 | 15747 |
def ExpandNames(self): |
15749 | 15748 |
self.network_uuid = self.cfg.LookupNetwork(self.op.network_name) |
15750 | 15749 |
self.network = self.cfg.GetNetwork(self.network_uuid) |
... | ... | |
15788 | 15787 |
if self.op.mac_prefix == constants.VALUE_NONE: |
15789 | 15788 |
self.mac_prefix = None |
15790 | 15789 |
else: |
15791 |
utils.NormalizeAndValidateMac(self.op.mac_prefix+":00:00:00")
|
|
15790 |
utils.NormalizeAndValidateMac(self.op.mac_prefix + ":00:00:00")
|
|
15792 | 15791 |
self.mac_prefix = self.op.mac_prefix |
15793 | 15792 |
|
15794 | 15793 |
if self.op.gateway6: |
... | ... | |
15803 | 15802 |
else: |
15804 | 15803 |
self.network6 = self.op.network6 |
15805 | 15804 |
|
15806 |
|
|
15807 |
|
|
15808 | 15805 |
def BuildHooksEnv(self): |
15809 | 15806 |
"""Build hooks env. |
15810 | 15807 |
|
... | ... | |
15939 | 15936 |
all_nodes = lu.cfg.GetAllNodesInfo() |
15940 | 15937 |
network_to_instances = dict((uuid, []) for uuid in self.wanted) |
15941 | 15938 |
|
15942 |
|
|
15943 | 15939 |
for group in all_groups.values(): |
15944 | 15940 |
if do_instances: |
15945 | 15941 |
group_nodes = [node.name for node in all_nodes.values() if |
... | ... | |
15998 | 15994 |
return self.nq.OldStyleQuery(self) |
15999 | 15995 |
|
16000 | 15996 |
|
16001 |
|
|
16002 | 15997 |
class LUNetworkConnect(LogicalUnit): |
16003 | 15998 |
"""Connect a network to a nodegroup |
16004 | 15999 |
|
... | ... | |
16052 | 16047 |
nodes = self.cfg.GetNodeGroup(self.group_uuid).members |
16053 | 16048 |
return (nodes, nodes) |
16054 | 16049 |
|
16055 |
|
|
16056 | 16050 |
def CheckPrereq(self): |
16057 | 16051 |
l = lambda value: ", ".join("%s: %s/%s" % (i[0], i[1], i[2]) |
16058 | 16052 |
for i in value) |
... | ... | |
16147 | 16141 |
nodes = self.cfg.GetNodeGroup(self.group_uuid).members |
16148 | 16142 |
return (nodes, nodes) |
16149 | 16143 |
|
16150 |
|
|
16151 | 16144 |
def CheckPrereq(self): |
16152 | 16145 |
l = lambda value: ", ".join("%s: %s/%s" % (i[0], i[1], i[2]) |
16153 | 16146 |
for i in value) |
... | ... | |
16213 | 16206 |
raise errors.OpPrereqError("Unknown query resource '%s'" % name, |
16214 | 16207 |
errors.ECODE_INVAL) |
16215 | 16208 |
|
16209 |
|
|
16216 | 16210 |
def _CheckForConflictingIp(lu, ip, node): |
16217 | 16211 |
"""In case of conflicting ip raise error. |
16218 | 16212 |
|
Also available in: Unified diff