-
Notifications
You must be signed in to change notification settings - Fork 50
Allow overlay DHCP servers to be configured without a VRF. #557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 9 commits
8651a50
f85676a
7a074e3
7b0fbc7
827c8e3
9f9784c
01426e5
8a99930
945796f
9ec939d
caa5b7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,7 +263,8 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>List of DHCP server_vrf pairs where 'srvr_ip' is the IP key and 'srvr_vrf' is the VRF key</div> | ||
| <div>This is an alternative to dhcp_srvr1_ip, dhcp_srvr1_vrf, dhcp_srvr2_ip, dhcp_srvr2_vrf, dhcp_srvr3_ip, dhcp_srvr3_vrf</div> | ||
| <div>'srvr_vrf' is an optional parameter</div> | ||
| <div>This will eventually replace dhcp_srvr1_ip, dhcp_srvr1_vrf, dhcp_srvr2_ip, dhcp_srvr2_vrf, dhcp_srvr3_ip, dhcp_srvr3_vrf</div> | ||
| <div>If both dhcp_servers and any of dhcp_srvr1_ip, dhcp_srvr1_vrf, dhcp_srvr2_ip, dhcp_srvr2_vrf, dhcp_srvr3_ip, dhcp_srvr3_vrf are specified an error message is generated indicating these are mutually exclusive options</div> | ||
| </td> | ||
| </tr> | ||
|
|
@@ -281,6 +282,7 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>DHCP relay IP address of the first DHCP server</div> | ||
| <div>This will eventually be replaced by dhcp_servers</div> | ||
|
||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
@@ -297,6 +299,7 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>VRF ID of first DHCP server</div> | ||
| <div>This is an optional parameter</div> | ||
miguecor marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
@@ -313,6 +316,7 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>DHCP relay IP address of the second DHCP server</div> | ||
| <div>This will eventually be replaced by dhcp_servers</div> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
@@ -329,6 +333,7 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>VRF ID of second DHCP server</div> | ||
| <div>This is an optional parameter</div> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
@@ -345,6 +350,7 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>DHCP relay IP address of the third DHCP server</div> | ||
| <div>This will eventually be replaced by dhcp_servers</div> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
@@ -361,6 +367,7 @@ Parameters | |
| </td> | ||
| <td> | ||
| <div>VRF ID of third DHCP server</div> | ||
| <div>This is an optional parameter</div> | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,41 +129,61 @@ | |
| dhcp_srvr1_ip: | ||
| description: | ||
| - DHCP relay IP address of the first DHCP server | ||
| - If dhcp_servers and dhcp_srvr1_ip are specified an error message is generated | ||
| indicating these are mutually exclusive options | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe reword to say something like: If dhcp_srvr1_ip is set, a deprecation warning will be logged. Please use only dcnm_servers in new playbooks.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Today we actually generate an error message not a warning since the old properties and new property are mutually exclusive so in this case I think the verbiage is appropriate |
||
| - dhcp_servers will eventually replace dhcp_srvr1_ip and dhcp_srvr1_vrf | ||
| type: str | ||
| required: false | ||
| dhcp_srvr1_vrf: | ||
| description: | ||
| - VRF ID of first DHCP server | ||
| - If not specified, will use same VRF as the network VRF | ||
| - For ND version 3.1 and NDFC 12.1 dhcp_srvr1_vrf must be specified for dhcp_srvr1_ip | ||
| - dhcp_servers will eventually replace dhcp_srvr1_ip and dhcp_srvr1_vrf | ||
| type: str | ||
| required: false | ||
| dhcp_srvr2_ip: | ||
| description: | ||
| - DHCP relay IP address of the second DHCP server | ||
| - If dhcp_servers and dhcp_srvr2_ip are specified an error message is generated | ||
| indicating these are mutually exclusive options | ||
| - dhcp_servers will eventually replace dhcp_srvr2_ip and dhcp_srvr2_vrf | ||
| type: str | ||
| required: false | ||
| dhcp_srvr2_vrf: | ||
| description: | ||
| - VRF ID of second DHCP server | ||
| - If not specified, will use same VRF as the network VRF | ||
| - For ND version 3.1 and NDFC 12.1 dhcp_srvr2_vrf must be specified for dhcp_srvr2_ip | ||
| - dhcp_servers will eventually replace dhcp_srvr2_ip and dhcp_srvr2_vrf | ||
| type: str | ||
| required: false | ||
| dhcp_srvr3_ip: | ||
| description: | ||
| - DHCP relay IP address of the third DHCP server | ||
| - If dhcp_servers and dhcp_srvr3_ip are specified an error message is generated | ||
| indicating these are mutually exclusive options | ||
| - dhcp_servers will eventually replace dhcp_srvr3_ip and dhcp_srvr3_vrf | ||
| type: str | ||
| required: false | ||
| dhcp_srvr3_vrf: | ||
| description: | ||
| - VRF ID of third DHCP server | ||
| - If not specified, will use same VRF as the network VRF | ||
| - For ND version 3.1 and NDFC 12.1 dhcp_srvr3_vrf must be specified for dhcp_srvr3_ip | ||
| - dhcp_servers will eventually replace dhcp_srvr3_ip and dhcp_srvr3_vrf | ||
| type: str | ||
| required: false | ||
| dhcp_servers: | ||
| description: | ||
| - List of DHCP server_vrf pairs where 'srvr_ip' is the IP key and 'srvr_vrf' is the VRF key | ||
| - This is an alternative to dhcp_srvr1_ip, dhcp_srvr1_vrf, dhcp_srvr2_ip, dhcp_srvr2_vrf, | ||
| dhcp_srvr3_ip, dhcp_srvr3_vrf | ||
| - The 'srvr_vrf' key is optional, if not specified will use same VRF as the network VRF | ||
| - For ND version 3.1 and NDFC 12.1 'srvr_vrf' must be specified for each DHCP server | ||
| - If both dhcp_servers and any of dhcp_srvr1_ip, dhcp_srvr1_vrf, dhcp_srvr2_ip, | ||
| dhcp_srvr2_vrf, dhcp_srvr3_ip, dhcp_srvr3_vrf are specified an error message is generated | ||
| indicating these are mutually exclusive options | ||
| - This will eventually replace dhcp_srvr1_ip, dhcp_srvr1_vrf, | ||
| dhcp_srvr2_ip, dhcp_srvr2_vrf, dhcp_srvr3_ip, dhcp_srvr3_vrf | ||
| type: list | ||
| elements: dict | ||
| required: false | ||
|
|
@@ -1287,7 +1307,7 @@ def update_create_params(self, net): | |
| "vrfDhcp2": net.get("dhcp_srvr2_vrf", ""), | ||
| "vrfDhcp3": net.get("dhcp_srvr3_vrf", ""), | ||
| "dhcpServers": [ | ||
| {"srvrAddr": srvr["srvr_ip"], "srvrVrf": srvr["srvr_vrf"]} for srvr in net.get("dhcp_servers", []) | ||
| {"srvrAddr": srvr["srvr_ip"], "srvrVrf": srvr.get("srvr_vrf", "")} for srvr in net.get("dhcp_servers", []) | ||
| ], | ||
| "loopbackId": net.get("dhcp_loopback_id", ""), | ||
| "mcastGroup": net.get("multicast_group_address", ""), | ||
|
|
@@ -1324,11 +1344,11 @@ def update_create_params(self, net): | |
| template_conf["vrfDhcp3"] = "" | ||
| if template_conf["dhcpServers"] == []: | ||
| dhcp_srvr_list = [] | ||
| if template_conf["dhcpServerAddr1"] != "" and template_conf["vrfDhcp"] != "": | ||
| if template_conf["dhcpServerAddr1"] != "": | ||
| dhcp_srvr_list.append({"srvrAddr": template_conf["dhcpServerAddr1"], "srvrVrf": template_conf["vrfDhcp"]}) | ||
| if template_conf["dhcpServerAddr2"] != "" and template_conf["vrfDhcp2"] != "": | ||
| if template_conf["dhcpServerAddr2"] != "": | ||
| dhcp_srvr_list.append({"srvrAddr": template_conf["dhcpServerAddr2"], "srvrVrf": template_conf["vrfDhcp2"]}) | ||
| if template_conf["dhcpServerAddr3"] != "" and template_conf["vrfDhcp3"] != "": | ||
| if template_conf["dhcpServerAddr3"] != "": | ||
| dhcp_srvr_list.append({"srvrAddr": template_conf["dhcpServerAddr3"], "srvrVrf": template_conf["vrfDhcp3"]}) | ||
| if dhcp_srvr_list != []: | ||
| template_conf["dhcpServers"] = json.dumps(dict(dhcpServers=dhcp_srvr_list), separators=(",", ":")) | ||
|
|
@@ -2904,14 +2924,14 @@ def validate_input(self): | |
| dict(srvr_ip=net.get("dhcp_srvr2_ip"), srvr_vrf=net.get("dhcp_srvr2_vrf")), | ||
| dict(srvr_ip=net.get("dhcp_srvr3_ip"), srvr_vrf=net.get("dhcp_srvr3_vrf")), | ||
| ]): | ||
| invalid_params.append("DHCP server IP should be specified along with DHCP server VRF") | ||
| invalid_params.append("DHCP server VRF should be specified along with DHCP server IP") | ||
|
|
||
| if net.get("dhcp_servers"): | ||
| dhcp_servers = net.get("dhcp_servers") | ||
| if len(dhcp_servers) > 16: | ||
| invalid_params.append("A maximum of 16 DHCP servers can be specified") | ||
| if any(has_partial_dhcp_config(srvr) for srvr in dhcp_servers): | ||
| invalid_params.append("DHCP server IP should be specified along with DHCP server VRF") | ||
| invalid_params.append("DHCP server VRF should be specified along with DHCP server IP") | ||
|
|
||
| if self.dcnm_version == 11: | ||
| if net.get("netflow_enable") or net.get("intfvlan_nf_monitor") or net.get("vlan_nf_monitor"): | ||
|
|
@@ -3088,24 +3108,31 @@ def dcnm_update_network_information(self, want, have, cfg): | |
| json_to_dict_want["vrfDhcp3"] = json_to_dict_have["vrfDhcp3"] | ||
|
|
||
| if cfg.get("dhcp_servers", None) is None: | ||
| want_have_dhcp_servers = [None] * 3 | ||
| want_dhcp_servers = json.loads(json_to_dict_have["dhcpServers"] or "{}").get("dhcpServers", []) | ||
| want_dhcp_servers += [None] * (16 - len(want_dhcp_servers)) | ||
| if json_to_dict_have["dhcpServerAddr1"] != "": | ||
| want_dhcp_servers[0] = dict(srvrAddr=json_to_dict_have["dhcpServerAddr1"], srvrVrf=json_to_dict_have["vrfDhcp"]) | ||
| if cfg.get("dhcp_srvr1_ip", None) is not None: | ||
| want_have_dhcp_servers[0] = dict(srvrAddr=cfg.get("dhcp_srvr1_ip"), srvrVrf=cfg.get("dhcp_srvr1_vrf")) | ||
| elif json_to_dict_have["dhcpServerAddr1"] != "": | ||
| want_have_dhcp_servers[0] = dict(srvrAddr=json_to_dict_have["dhcpServerAddr1"], srvrVrf=json_to_dict_have["vrfDhcp"]) | ||
| want_dhcp_servers[0] = dict(srvrAddr=cfg.get("dhcp_srvr1_ip"), srvrVrf=json_to_dict_have["vrfDhcp"]) | ||
| if cfg.get("dhcp_srvr1_vrf", None) is not None: | ||
| want_dhcp_servers[0].update({"srvrVrf": cfg.get("dhcp_srvr1_vrf")}) | ||
| if json_to_dict_have["dhcpServerAddr2"] != "": | ||
| want_dhcp_servers[1] = dict(srvrAddr=json_to_dict_have["dhcpServerAddr2"], srvrVrf=json_to_dict_have["vrfDhcp2"]) | ||
| if cfg.get("dhcp_srvr2_ip", None) is not None: | ||
| want_have_dhcp_servers[1] = dict(srvrAddr=cfg.get("dhcp_srvr2_ip"), srvrVrf=cfg.get("dhcp_srvr2_vrf")) | ||
| elif json_to_dict_have["dhcpServerAddr2"] != "": | ||
| want_have_dhcp_servers[1] = dict(srvrAddr=json_to_dict_have["dhcpServerAddr2"], srvrVrf=json_to_dict_have["vrfDhcp2"]) | ||
| want_dhcp_servers[1] = dict(srvrAddr=cfg.get("dhcp_srvr2_ip"), srvrVrf=json_to_dict_have["vrfDhcp2"]) | ||
| if cfg.get("dhcp_srvr2_vrf", None) is not None: | ||
| want_dhcp_servers[1].update({"srvrVrf": cfg.get("dhcp_srvr2_vrf")}) | ||
| if json_to_dict_have["dhcpServerAddr3"] != "": | ||
| want_dhcp_servers[2] = dict(srvrAddr=json_to_dict_have["dhcpServerAddr3"], srvrVrf=json_to_dict_have["vrfDhcp3"]) | ||
| if cfg.get("dhcp_srvr3_ip", None) is not None: | ||
| want_have_dhcp_servers[2] = dict(srvrAddr=cfg.get("dhcp_srvr3_ip"), srvrVrf=cfg.get("dhcp_srvr3_vrf")) | ||
| elif json_to_dict_have["dhcpServerAddr3"] != "": | ||
| want_have_dhcp_servers[2] = dict(srvrAddr=json_to_dict_have["dhcpServerAddr3"], srvrVrf=json_to_dict_have["vrfDhcp3"]) | ||
| want_have_dhcp_servers = [srvr for srvr in want_have_dhcp_servers[:] if srvr is not None] | ||
| if want_have_dhcp_servers != []: | ||
| json_to_dict_want["dhcpServers"] = json.dumps(dict(dhcpServers=want_have_dhcp_servers, separators=(",", ":"))) | ||
| want_dhcp_servers[2] = dict(srvrAddr=cfg.get("dhcp_srvr3_ip"), srvrVrf=json_to_dict_have["vrfDhcp3"]) | ||
| if cfg.get("dhcp_srvr3_vrf", None) is not None: | ||
| want_dhcp_servers[2].update({"srvrVrf": cfg.get("dhcp_srvr3_vrf")}) | ||
| want_dhcp_servers = [srvr for srvr in want_dhcp_servers[:] if srvr is not None] | ||
| if want_dhcp_servers == []: | ||
| json_to_dict_want["dhcpServers"] = "" | ||
| else: | ||
| json_to_dict_want["dhcpServers"] = json_to_dict_have["dhcpServers"] | ||
| json_to_dict_want["dhcpServers"] = json.dumps(dict(dhcpServers=want_dhcp_servers), separators=(",", ":")) | ||
miguecor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if cfg.get("dhcp_loopback_id", None) is None: | ||
| json_to_dict_want["loopbackId"] = json_to_dict_have["loopbackId"] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.