infiniband: Change the default value of p_key into None

The current default `p_key` value is `-1`, which is only useful for the
recognizability with NetworkManager API. NetworkManager chooses the
`-1` as the default pkey value only because the connection should be
created on the physical infiniband interface by default and the
positive pkey value would make the connection created on the virtual
infiniband partition. But NetworkManager should also have represented
the default value as not specifying the pkey property initially.

Therefore, change the default value of `p_key` into `None`.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
This commit is contained in:
Wen Liang 2022-05-16 06:24:53 -04:00 committed by Fernando Fernández Mancera
parent be2d0e847c
commit e8cdb2bc58
3 changed files with 18 additions and 10 deletions

View file

@ -348,7 +348,7 @@ class IfcfgUtil:
if (connection["infiniband"]["transport_mode"] == "connected")
else "no"
)
if connection["infiniband"]["p_key"] != -1:
if connection["infiniband"]["p_key"] is not None:
ifcfg["PKEY"] = "yes"
ifcfg["PKEY_ID"] = str(connection["infiniband"]["p_key"])
if connection["parent"]:
@ -846,7 +846,7 @@ class NMUtil:
NM.SETTING_INFINIBAND_TRANSPORT_MODE,
connection["infiniband"]["transport_mode"],
)
if connection["infiniband"]["p_key"] != -1:
if connection["infiniband"]["p_key"] is not None:
s_infiniband.set_property(
NM.SETTING_INFINIBAND_P_KEY, connection["infiniband"]["p_key"]
)
@ -2012,7 +2012,7 @@ class Cmd(object):
"interface exists" % (connection["interface_name"]),
)
elif connection["type"] == "infiniband":
if connection["infiniband"]["p_key"] == -1:
if connection["infiniband"]["p_key"] is None:
self.log_fatal(
idx,
"profile specifies interface_name '%s' but no such "