Fix networks validation for Trove

When creating Trove instances with a specific network configuration,
some validation logic would fail if the network/port resources did
not already exist.

For example, if a network and a trove instance were to be created
as part of the same stack, the network ID would not exist yet and
result in the ID being an empty string.

This commit fixes that logic to specifically test whether the value
is None, rather than the truthy test of None or ''

Change-Id: I12c98828271be05d1d98d653eeb2ae21ede058f7
This commit is contained in:
Andy Botting 2024-03-20 14:00:57 +11:00
parent 76d175c275
commit 9cf2d2fa30
2 changed files with 2 additions and 3 deletions

View File

@ -365,8 +365,7 @@ class TroveCluster(resource.Resource):
% self.PORT)
raise exception.StackValidationFailed(message=msg)
if (bool(nic.get(self.NET) is not None) ==
bool(nic.get(self.PORT) is not None)):
if (nic.get(self.NET) is None) == (nic.get(self.PORT) is None):
msg = (_("Either %(net)s or %(port)s must be provided.")
% {'net': self.NET, 'port': self.PORT})
raise exception.StackValidationFailed(message=msg)

View File

@ -685,7 +685,7 @@ class Instance(resource.Resource):
msg = _("Can not use %s property on Nova-network.") % self.PORT
raise exception.StackValidationFailed(message=msg)
if bool(nic.get(self.NET)) == bool(nic.get(self.PORT)):
if (nic.get(self.NET) is None) == (nic.get(self.PORT) is None):
msg = _("Either %(net)s or %(port)s must be provided.") % {
'net': self.NET, 'port': self.PORT}
raise exception.StackValidationFailed(message=msg)