Skip to content
Snippets Groups Projects
Commit 74e642cd authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Improve reporting on errors.AddressPoolError exceptions


This patch improves the error messages given when a
“errors.AddressPoolError” exception is caught. Includes some small style
fixes.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 2fc6329b
No related branches found
No related tags found
No related merge requests found
...@@ -13495,13 +13495,12 @@ class LUInstanceSetParams(LogicalUnit): ...@@ -13495,13 +13495,12 @@ class LUInstanceSetParams(LogicalUnit):
elif self.op.conflicts_check: elif self.op.conflicts_check:
_CheckForConflictingIp(self, new_ip, pnode) _CheckForConflictingIp(self, new_ip, pnode)
   
if old_ip: if old_ip and old_net:
if old_net: try:
try: self.cfg.ReleaseIp(old_net, old_ip, self.proc.GetECId())
self.cfg.ReleaseIp(old_net, old_ip, self.proc.GetECId()) except errors.AddressPoolError, err:
except errors.AddressPoolError: logging.warning("Releasing IP address '%s' from network '%s'"
logging.warning("Release IP %s not contained in network %s", " failed: %s", old_ip, old_net, err)
old_ip, old_net)
   
# there are no changes in (net, ip) tuple # there are no changes in (net, ip) tuple
elif (old_net is not None and elif (old_net is not None and
...@@ -16246,8 +16245,9 @@ class LUNetworkAdd(LogicalUnit): ...@@ -16246,8 +16245,9 @@ class LUNetworkAdd(LogicalUnit):
# Initialize the associated address pool # Initialize the associated address pool
try: try:
pool = network.AddressPool.InitializeNetwork(nobj) pool = network.AddressPool.InitializeNetwork(nobj)
except errors.AddressPoolError, e: except errors.AddressPoolError, err:
raise errors.OpExecError("Cannot create IP pool for this network: %s" % e) raise errors.OpExecError("Cannot create IP address pool for network"
" '%s': %s" % (self.op.network_name, err))
   
# Check if we need to reserve the nodes and the cluster master IP # Check if we need to reserve the nodes and the cluster master IP
# These may not be allocated to any instances in routed mode, as # These may not be allocated to any instances in routed mode, as
...@@ -16260,25 +16260,26 @@ class LUNetworkAdd(LogicalUnit): ...@@ -16260,25 +16260,26 @@ class LUNetworkAdd(LogicalUnit):
pool.Reserve(ip) pool.Reserve(ip)
self.LogInfo("Reserved IP address of node '%s' (%s)", self.LogInfo("Reserved IP address of node '%s' (%s)",
node.name, ip) node.name, ip)
except errors.AddressPoolError: except errors.AddressPoolError, err:
self.LogWarning("Cannot reserve IP address of node '%s' (%s)", self.LogWarning("Cannot reserve IP address '%s' of node '%s': %s",
node.name, ip) ip, node.name, err)
   
master_ip = self.cfg.GetClusterInfo().master_ip master_ip = self.cfg.GetClusterInfo().master_ip
try: try:
if pool.Contains(master_ip): if pool.Contains(master_ip):
pool.Reserve(master_ip) pool.Reserve(master_ip)
self.LogInfo("Reserved cluster master IP address (%s)", master_ip) self.LogInfo("Reserved cluster master IP address (%s)", master_ip)
except errors.AddressPoolError: except errors.AddressPoolError, err:
self.LogWarning("Cannot reserve cluster master IP address (%s)", self.LogWarning("Cannot reserve cluster master IP address (%s): %s",
master_ip) master_ip, err)
   
if self.op.add_reserved_ips: if self.op.add_reserved_ips:
for ip in self.op.add_reserved_ips: for ip in self.op.add_reserved_ips:
try: try:
pool.Reserve(ip, external=True) pool.Reserve(ip, external=True)
except errors.AddressPoolError, e: except errors.AddressPoolError, err:
raise errors.OpExecError("Cannot reserve IP %s. %s " % (ip, e)) raise errors.OpExecError("Cannot reserve IP address '%s': %s" %
(ip, err))
   
if self.op.tags: if self.op.tags:
for tag in self.op.tags: for tag in self.op.tags:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment