diff options
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/net/__init__.py | 4 | ||||
-rw-r--r-- | cloudinit/net/dhcp.py | 24 |
2 files changed, 26 insertions, 2 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index 244305d1..65d45edf 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -167,6 +167,10 @@ def master_is_openvswitch(devname): return os.path.exists(ovs_path) +def is_ib_interface(devname): + return read_sys_net_safe(devname, "type") == "32" + + @functools.lru_cache(maxsize=None) def openvswitch_is_installed() -> bool: """Return a bool indicating if Open vSwitch is installed in the system.""" diff --git a/cloudinit/net/dhcp.py b/cloudinit/net/dhcp.py index 661b9848..a8949ebc 100644 --- a/cloudinit/net/dhcp.py +++ b/cloudinit/net/dhcp.py @@ -14,8 +14,13 @@ from io import StringIO import configobj -from cloudinit import subp, util -from cloudinit.net import find_fallback_nic, get_devicelist +from cloudinit import subp, temp_utils, util +from cloudinit.net import ( + find_fallback_nic, + get_devicelist, + get_interface_mac, + is_ib_interface, +) LOG = logging.getLogger(__name__) @@ -136,6 +141,9 @@ def dhcp_discovery(dhclient_cmd_path, interface, dhcp_log_func=None): # link up before attempting discovery. Since we are using -sf /bin/true, # we need to do that "link up" ourselves first. subp.subp(["ip", "link", "set", "dev", interface, "up"], capture=True) + # For INFINIBAND port the dhlient must be sent with dhcp-client-identifier. + # So here we are checking if the interface is INFINIBAND or not. + # If yes, we are generating the the client-id to be used with the dhclient cmd = [ dhclient_cmd_path, "-1", @@ -148,6 +156,18 @@ def dhcp_discovery(dhclient_cmd_path, interface, dhcp_log_func=None): "-sf", "/bin/true", ] + if is_ib_interface(interface): + dhcp_client_identifier = "20:%s" % get_interface_mac(interface)[36:] + interface_dhclient_content = ( + 'interface "%s" ' + "{send dhcp-client-identifier %s;}" + % (interface, dhcp_client_identifier) + ) + tmp_dir = temp_utils.get_tmp_ancestor(needs_exe=True) + file_name = os.path.join(tmp_dir, interface + "-dhclient.conf") + util.write_file(file_name, interface_dhclient_content) + cmd.append("-cf") + cmd.append(file_name) out, err = subp.subp(cmd, capture=True) # Wait for pid file and lease file to appear, and for the process |