summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-01 20:23:00 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-01 20:23:00 -0400
commit7f46de87ee543a82c9a95137478676edaba2acc1 (patch)
tree300ea02c54b152fc38fdff920dc4ee92571f6ada
parent0fc5c222d2ff335b9a1de3e910bb8822b6d73031 (diff)
downloadvyos-cloud-init-7f46de87ee543a82c9a95137478676edaba2acc1.tar.gz
vyos-cloud-init-7f46de87ee543a82c9a95137478676edaba2acc1.zip
clean up log message a bit.
-rw-r--r--cloudinit/net/__init__.py36
1 files changed, 22 insertions, 14 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index f5ae7705..6d9ea575 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -908,8 +908,8 @@ def rename_interfaces(renames, strict_present=True, strict_busy=True,
errors.append(msg % (mac, cur_name, new_name))
continue
cur['up'] = False
- cur_ops.append((down, mac, new_name, (cur_name,)))
- ups.append((up, mac, new_name, (new_name,)))
+ cur_ops.append(("down", mac, new_name, (cur_name,)))
+ ups.append(("up", mac, new_name, (new_name,)))
if new_name in cur_byname:
target = cur_byname[new_name]
@@ -920,33 +920,41 @@ def rename_interfaces(renames, strict_present=True, strict_busy=True,
errors.append(msg % (mac, cur_name, new_name))
continue
else:
- cur_ops.append((down, mac, new_name, (new_name,)))
+ cur_ops.append(("down", mac, new_name, (new_name,)))
tmp_name = None
while tmp_name is None or tmp_name in cur_byname:
tmpi += 1
tmp_name = tmpname_fmt % tmpi
- cur_ops.append((rename, mac, new_name, (new_name, tmp_name)))
+ cur_ops.append(("rename", mac, new_name, (new_name, tmp_name)))
target['name'] = tmp_name
cur_byname = update_byname(cur_bymac)
if target['up']:
- ups.append((up, mac, new_name, (tmp_name,)))
+ ups.append(("up", mac, new_name, (tmp_name,)))
- cur_ops.append((rename, mac, new_name, (cur['name'], new_name)))
+ cur_ops.append(("rename", mac, new_name, (cur['name'], new_name)))
cur['name'] = new_name
cur_byname = update_byname(cur_bymac)
ops += cur_ops
- LOG.debug("achieving renaming of %s with ops %s", renames, ops + ups)
+ opmap = {'rename': rename, 'down': down, 'up': up}
- for op, mac, new_name, params in ops + ups:
- try:
- op(*params)
- except Exception as e:
- errors.append(
- "[unknown] Error performing %s%s for %s, %s: %s" %
- (op.__name__, params, mac, new_name, e))
+ if len(ops) + len(ups) == 0:
+ if len(errors):
+ LOG.debug("unable to do any work for renaming of %s", renames)
+ else:
+ LOG.debug("no work necessary for renaming of %s", renames)
+ else:
+ LOG.debug("achieving renaming of %s with ops %s", renames, ops + ups)
+
+ for op, mac, new_name, params in ops + ups:
+ try:
+ opmap.get(op)(*params)
+ except Exception as e:
+ errors.append(
+ "[unknown] Error performing %s%s for %s, %s: %s" %
+ (op, params, mac, new_name, e))
if len(errors):
raise Exception('\n'.join(errors))