Clean up var names shadowing internals
Several vars shaddowing internal names dict, map etc. Prefix the vars with underscore. Related: blueprint network-data-v2-ports Change-Id: Ia5a31ef0c6b711534cd372f504a1cb598751d45a
This commit is contained in:
parent
74c1226b6d
commit
27decd09fd
|
@ -108,7 +108,7 @@ PORT_PATH_TPL = 'network/ports/deployed_{net_name_lower}.yaml'
|
|||
|
||||
|
||||
def get_net_name_map(conn, role_net_map):
|
||||
map = {}
|
||||
_map = {}
|
||||
networks = set()
|
||||
|
||||
for role, nets in role_net_map.items():
|
||||
|
@ -116,7 +116,7 @@ def get_net_name_map(conn, role_net_map):
|
|||
|
||||
for name_lower in networks:
|
||||
if name_lower == CTLPLANE_NETWORK:
|
||||
map[name_lower] = name_lower
|
||||
_map[name_lower] = name_lower
|
||||
continue
|
||||
|
||||
net = conn.network.find_network(name_or_id=name_lower)
|
||||
|
@ -132,9 +132,9 @@ def get_net_name_map(conn, role_net_map):
|
|||
'please make sure the network tag tripleo_network_name'
|
||||
'=$NET_NAME is set.'.format(name_lower))
|
||||
|
||||
map[name_lower] = name_upper.pop()
|
||||
_map[name_lower] = name_upper.pop()
|
||||
|
||||
return map
|
||||
return _map
|
||||
|
||||
|
||||
def update_environment(environment, node_port_map, role_net_map, net_name_map):
|
||||
|
@ -152,8 +152,8 @@ def update_environment(environment, node_port_map, role_net_map, net_name_map):
|
|||
DEFAULT_THT_DIR, PORT_PATH_TPL.format(net_name_lower=net))
|
||||
resource_registry.update({registry_key: template_path})
|
||||
|
||||
p_map = parameter_defaults.setdefault('NodePortMap', {})
|
||||
p_map.update(node_port_map)
|
||||
_map = parameter_defaults.setdefault('NodePortMap', {})
|
||||
_map.update(node_port_map)
|
||||
|
||||
|
||||
def run_module():
|
||||
|
|
|
@ -184,15 +184,15 @@ def is_vip_network(conn, network_id):
|
|||
|
||||
def get_network_info(conn, network_id):
|
||||
|
||||
def pop_defaults(dict):
|
||||
if dict['mtu'] == DEFAULT_NETWORK_MTU:
|
||||
dict.pop('mtu')
|
||||
if dict['shared'] == DEFAULT_NETWROK_SHARED:
|
||||
dict.pop('shared')
|
||||
if dict['admin_state_up'] == DEFAULT_NETWORK_ADMIN_STATE_UP:
|
||||
dict.pop('admin_state_up')
|
||||
if dict['vip'] == DEFAULT_NETWORK_VIP:
|
||||
dict.pop('vip')
|
||||
def pop_defaults(_dict):
|
||||
if _dict['mtu'] == DEFAULT_NETWORK_MTU:
|
||||
_dict.pop('mtu')
|
||||
if _dict['shared'] == DEFAULT_NETWROK_SHARED:
|
||||
_dict.pop('shared')
|
||||
if _dict['admin_state_up'] == DEFAULT_NETWORK_ADMIN_STATE_UP:
|
||||
_dict.pop('admin_state_up')
|
||||
if _dict['vip'] == DEFAULT_NETWORK_VIP:
|
||||
_dict.pop('vip')
|
||||
|
||||
network = conn.network.get_network(network_id)
|
||||
tag_dict = tripleo_resource_tags_to_dict(network.tags)
|
||||
|
@ -219,25 +219,25 @@ def get_network_info(conn, network_id):
|
|||
|
||||
def get_subnet_info(conn, subnet_id):
|
||||
|
||||
def pop_defaults(dict):
|
||||
if dict['enable_dhcp'] == DEFAULT_SUBNET_DHCP_ENABLED:
|
||||
dict.pop('enable_dhcp')
|
||||
if dict['network_type'] == DEFAULT_NETWORK_TYPE:
|
||||
dict.pop('network_type')
|
||||
if dict['vlan'] is None:
|
||||
dict.pop('vlan')
|
||||
if dict['segmentation_id'] is None:
|
||||
dict.pop('segmentation_id')
|
||||
def pop_defaults(_dict):
|
||||
if _dict['enable_dhcp'] == DEFAULT_SUBNET_DHCP_ENABLED:
|
||||
_dict.pop('enable_dhcp')
|
||||
if _dict['network_type'] == DEFAULT_NETWORK_TYPE:
|
||||
_dict.pop('network_type')
|
||||
if _dict['vlan'] is None:
|
||||
_dict.pop('vlan')
|
||||
if _dict['segmentation_id'] is None:
|
||||
_dict.pop('segmentation_id')
|
||||
|
||||
try:
|
||||
if dict['ipv6_address_mode'] == DEFAULT_SUBNET_IPV6_ADDRESS_MODE:
|
||||
dict.pop('ipv6_address_mode')
|
||||
if _dict['ipv6_address_mode'] == DEFAULT_SUBNET_IPV6_ADDRESS_MODE:
|
||||
_dict.pop('ipv6_address_mode')
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
if dict['ipv6_ra_mode'] == DEFAULT_SUBNET_IPV6_RA_MODE:
|
||||
dict.pop('ipv6_ra_mode')
|
||||
if _dict['ipv6_ra_mode'] == DEFAULT_SUBNET_IPV6_RA_MODE:
|
||||
_dict.pop('ipv6_ra_mode')
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue