From: Ondrej Lichtner olichtne@redhat.com
You can now set a Device (RemoteDevice on the Controller) objects as values for IpParameters. This will get the ip address list of the Device and use the first address as the value for the IpParam object.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com
--- v2: * import Device on demand (Device class arrives on Slave later) and check isinstance Device instead of RemoteDevice (not available on Slave) * fix IpParam Exception string --- lnst/Common/Parameters.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lnst/Common/Parameters.py b/lnst/Common/Parameters.py index dcf9bab..16385b4 100644 --- a/lnst/Common/Parameters.py +++ b/lnst/Common/Parameters.py @@ -77,12 +77,17 @@ class StrParam(Param): class IpParam(Param): @Param.val.setter def val(self, value): + #runtime import this because the Device class arrives on the Slave + #during recipe execution, not during Slave init + from lnst.Devices.Device import Device if isinstance(value, BaseIpAddress): self._val = value elif isinstance(value, str): self._val = IpAddress(value) + elif isinstance(value, Device): + self.val = value.ips[0] else: - raise ParamError("Value must be a BaseIpAddress or string object." + raise ParamError("Value must be a BaseIpAddress, string or Device object." "Not {}".format(type(value))) self.set = True