summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-21 10:19:06 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-21 10:19:06 -0400
commit65d52719de2b088e5c28a037122cb6f6b479a58d (patch)
treeb6881fbb02f5b552363d97c0983670af8a93c6c9
parent87199f2812d4ccd3f9a9a5d9458543552f6552d2 (diff)
downloadcloud-init-65d52719de2b088e5c28a037122cb6f6b479a58d.tar.gz
sort attributes in sections, change 'mac_address' to 'hwaddress'
-rw-r--r--cloudinit/net/eni.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
index 1fea240d..bb48a6eb 100644
--- a/cloudinit/net/eni.py
+++ b/cloudinit/net/eni.py
@@ -64,7 +64,7 @@ def _iface_add_subnet(iface, subnet):
key = key.replace('_', '-')
content.append(" {} {}".format(key, value))
- return content
+ return sorted(content)
# TODO: switch to valid_map for attrs
@@ -80,16 +80,18 @@ def _iface_add_attrs(iface):
'subnets',
'type',
]
+ renames = {'mac_address': 'hwaddress'}
if iface['type'] not in ['bond', 'bridge', 'vlan']:
ignore_map.append('mac_address')
for key, value in iface.items():
- if value and key not in ignore_map:
- if type(value) == list:
- value = " ".join(value)
- content.append(" {} {}".format(key, value))
+ if not value or key in ignore_map:
+ continue
+ if type(value) == list:
+ value = " ".join(value)
+ content.append(" {} {}".format(renames.get(key, key), value))
- return content
+ return sorted(content)
def _iface_start_entry(iface, index):