Remove return_netmask function

The return_netmask function was provided as a way to make the inventory
script compatible with the old inventory schema. Since this
compatibility has been broken for about 2 major releases, it can be
simplified.

The function assumed that either the container dictionary would have the
old netmask, or a new netmask would exist, so those are the only return
options. Were neither defined, None would be returned as a standard
Python behavior. Thus, simply using the 'netmask' variable is a viable
alternative; if it's present, it will be used, if it's None, the
behavior is the same as before.

Change-Id: Ibdd3ca9dedbb006c2a668939a931c9547160d56a
This commit is contained in:
Nolan Brubaker 2016-08-01 15:29:58 -04:00
parent 5cc9d0b004
commit 6c7c870b7a

View File

@ -562,17 +562,6 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface,
return _network
def return_netmask():
"""Return the netmask for a container."""
# TODO(cloudnull) After a few releases this conditional should be
# simplified. The container address checking that is ssh address
# is only being done to support old inventory.
_old_netmask = container.get(old_netmask)
if _old_netmask:
return container.pop(old_netmask)
elif netmask:
return netmask
base_hosts = inventory['_meta']['hostvars']
lookup = inventory.get(key, list())
@ -607,7 +596,6 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface,
old_address = '%s_address' % q_name
else:
old_address = '%s_address' % interface
old_netmask = '%s_netmask' % q_name
for container_host in hosts:
container = base_hosts[container_host]
@ -637,10 +625,10 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface,
if address:
network['address'] = address
network['netmask'] = return_netmask()
network['netmask'] = netmask
elif is_metal:
network = networks[old_address] = network_entry()
network['netmask'] = return_netmask()
network['netmask'] = netmask
# TODO(cloudnull) After a few releases this conditional should be
# simplified. The container address checking that is ssh address
# is only being done to support old inventory.