Revision 189ed529 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
40 | 40 |
import shutil |
41 | 41 |
import itertools |
42 | 42 |
import operator |
43 |
import ipaddr |
|
44 | 43 |
|
45 | 44 |
from ganeti import ssh |
46 | 45 |
from ganeti import utils |
... | ... | |
15197 | 15196 |
def ExpandNames(self): |
15198 | 15197 |
self.network_uuid = self.cfg.GenerateUniqueID(self.proc.GetECId()) |
15199 | 15198 |
self.needed_locks = {} |
15199 |
if self.op.conflicts_check: |
|
15200 |
self.needed_locks = { |
|
15201 |
locking.LEVEL_NODE: locking.ALL_SET, |
|
15202 |
} |
|
15203 |
self.share_locks[locking.LEVEL_NODE] = 1 |
|
15200 | 15204 |
self.add_locks[locking.LEVEL_NETWORK] = self.network_uuid |
15201 | 15205 |
|
15202 | 15206 |
def CheckPrereq(self): |
... | ... | |
15216 | 15220 |
raise errors.OpPrereqError("Network '%s' already defined" % |
15217 | 15221 |
self.op.network, errors.ECODE_EXISTS) |
15218 | 15222 |
|
15219 |
|
|
15220 | 15223 |
def BuildHooksEnv(self): |
15221 | 15224 |
"""Build hooks env. |
15222 | 15225 |
|
... | ... | |
15254 | 15257 |
# Check if we need to reserve the nodes and the cluster master IP |
15255 | 15258 |
# These may not be allocated to any instances in routed mode, as |
15256 | 15259 |
# they wouldn't function anyway. |
15257 |
for node in self.cfg.GetAllNodesInfo().values(): |
|
15258 |
for ip in [node.primary_ip, node.secondary_ip]: |
|
15259 |
try: |
|
15260 |
pool.Reserve(ip) |
|
15261 |
self.LogInfo("Reserved node %s's IP (%s)", node.name, ip) |
|
15260 |
if self.op.conflicts_check: |
|
15261 |
for node in self.cfg.GetAllNodesInfo().values(): |
|
15262 |
for ip in [node.primary_ip, node.secondary_ip]: |
|
15263 |
try: |
|
15264 |
pool.Reserve(ip) |
|
15265 |
self.LogInfo("Reserved node %s's IP (%s)", node.name, ip) |
|
15262 | 15266 |
|
15263 |
except errors.AddressPoolError: |
|
15264 |
pass |
|
15267 |
except errors.AddressPoolError:
|
|
15268 |
pass
|
|
15265 | 15269 |
|
15266 |
master_ip = self.cfg.GetClusterInfo().master_ip |
|
15267 |
try: |
|
15268 |
pool.Reserve(master_ip) |
|
15269 |
self.LogInfo("Reserved cluster master IP (%s)", master_ip) |
|
15270 |
except errors.AddressPoolError: |
|
15271 |
pass |
|
15270 |
master_ip = self.cfg.GetClusterInfo().master_ip
|
|
15271 |
try:
|
|
15272 |
pool.Reserve(master_ip)
|
|
15273 |
self.LogInfo("Reserved cluster master IP (%s)", master_ip)
|
|
15274 |
except errors.AddressPoolError:
|
|
15275 |
pass
|
|
15272 | 15276 |
|
15273 | 15277 |
if self.op.add_reserved_ips: |
15274 | 15278 |
for ip in self.op.add_reserved_ips: |
... | ... | |
15289 | 15293 |
def ExpandNames(self): |
15290 | 15294 |
self.network_uuid = self.cfg.LookupNetwork(self.op.network_name) |
15291 | 15295 |
|
15296 |
if not self.network_uuid: |
|
15297 |
raise errors.OpPrereqError("Network %s not found" % self.op.network_name, |
|
15298 |
errors.ECODE_INVAL) |
|
15292 | 15299 |
self.needed_locks = { |
15293 | 15300 |
locking.LEVEL_NETWORK: [self.network_uuid], |
15301 |
locking.LEVEL_NODEGROUP: locking.ALL_SET, |
|
15294 | 15302 |
} |
15303 |
self.share_locks[locking.LEVEL_NODEGROUP] = 1 |
|
15295 | 15304 |
|
15296 | 15305 |
|
15297 | 15306 |
def CheckPrereq(self): |
... | ... | |
15302 | 15311 |
cluster. |
15303 | 15312 |
|
15304 | 15313 |
""" |
15305 |
if not self.network_uuid: |
|
15306 |
raise errors.OpPrereqError("Network %s not found" % self.op.network_name, |
|
15307 |
errors.ECODE_INVAL) |
|
15308 | 15314 |
|
15309 | 15315 |
# Verify that the network is not conncted. |
15310 | 15316 |
node_groups = [group.name |
15311 | 15317 |
for group in self.cfg.GetAllNodeGroupsInfo().values() |
15312 |
for network in group.networks.keys()
|
|
15313 |
if network == self.network_uuid]
|
|
15318 |
for net in group.networks.keys() |
|
15319 |
if net == self.network_uuid] |
|
15314 | 15320 |
|
15315 | 15321 |
if node_groups: |
15316 | 15322 |
self.LogWarning("Nework '%s' is connected to the following" |
Also available in: Unified diff