Revision ac84befd lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
13493 | 13493 |
params[constants.INIC_MAC] = \ |
13494 | 13494 |
self.cfg.GenerateMAC(new_net_uuid, self.proc.GetECId()) |
13495 | 13495 |
|
13496 |
#if there is a change in nic's ip/network configuration
|
|
13496 |
# if there is a change in (ip, network) tuple
|
|
13497 | 13497 |
new_ip = params.get(constants.INIC_IP, old_ip) |
13498 | 13498 |
if (new_ip, new_net_uuid) != (old_ip, old_net_uuid): |
13499 | 13499 |
if new_ip: |
13500 |
# if IP is pool then require a network and generate one IP |
|
13500 | 13501 |
if new_ip.lower() == constants.NIC_IP_POOL: |
13501 |
if not new_net_uuid: |
|
13502 |
if new_net_uuid: |
|
13503 |
try: |
|
13504 |
new_ip = self.cfg.GenerateIp(new_net_uuid, self.proc.GetECId()) |
|
13505 |
except errors.ReservationError: |
|
13506 |
raise errors.OpPrereqError("Unable to get a free IP" |
|
13507 |
" from the address pool", |
|
13508 |
errors.ECODE_STATE) |
|
13509 |
self.LogInfo("Chose IP %s from network %s", |
|
13510 |
new_ip, |
|
13511 |
new_net_obj.name) |
|
13512 |
params[constants.INIC_IP] = new_ip |
|
13513 |
else: |
|
13502 | 13514 |
raise errors.OpPrereqError("ip=pool, but no network found", |
13503 | 13515 |
errors.ECODE_INVAL) |
13504 |
try: |
|
13505 |
new_ip = self.cfg.GenerateIp(new_net_uuid, self.proc.GetECId()) |
|
13506 |
except errors.ReservationError: |
|
13507 |
raise errors.OpPrereqError("Unable to get a free IP" |
|
13508 |
" from the address pool", |
|
13509 |
errors.ECODE_STATE) |
|
13510 |
self.LogInfo("Chose IP %s from network %s", new_ip, new_net_obj.name) |
|
13511 |
params[constants.INIC_IP] = new_ip |
|
13512 |
elif new_ip != old_ip or new_net_uuid != old_net_uuid: |
|
13516 |
# Reserve new IP if in the new network if any |
|
13517 |
elif new_net_uuid: |
|
13513 | 13518 |
try: |
13514 | 13519 |
self.cfg.ReserveIp(new_net_uuid, new_ip, self.proc.GetECId()) |
13515 | 13520 |
self.LogInfo("Reserving IP %s in network %s", |
... | ... | |
13518 | 13523 |
raise errors.OpPrereqError("IP %s not available in network %s" % |
13519 | 13524 |
(new_ip, new_net_obj.name), |
13520 | 13525 |
errors.ECODE_NOTUNIQUE) |
13521 |
|
|
13522 |
# new net is None |
|
13523 |
elif not new_net_uuid and self.op.conflicts_check: |
|
13526 |
# new network is None so check if new IP is a conflicting IP |
|
13527 |
elif self.op.conflicts_check: |
|
13524 | 13528 |
_CheckForConflictingIp(self, new_ip, pnode) |
13525 | 13529 |
|
13526 |
if old_ip: |
|
13530 |
# release old IP if old network is not None |
|
13531 |
if old_ip and old_net_uuid: |
|
13527 | 13532 |
try: |
13528 | 13533 |
self.cfg.ReleaseIp(old_net_uuid, old_ip, self.proc.GetECId()) |
13529 | 13534 |
except errors.AddressPoolError: |
13530 | 13535 |
logging.warning("Release IP %s not contained in network %s", |
13531 | 13536 |
old_ip, old_net_obj.name) |
13532 | 13537 |
|
13533 |
# there are no changes in (net, ip) tuple
|
|
13538 |
# there are no changes in (ip, network) tuple and old network is not None
|
|
13534 | 13539 |
elif (old_net_uuid is not None and |
13535 | 13540 |
(req_link is not None or req_mode is not None)): |
13536 | 13541 |
raise errors.OpPrereqError("Not allowed to change link or mode of" |
Also available in: Unified diff