Skip to content

Commit

Permalink
VirtualMachine: if address state is optional
Browse files Browse the repository at this point in the history
fixes #536
  • Loading branch information
Thomas-Gelf committed Sep 28, 2023
1 parent 109d1d1 commit 23340c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 13 additions & 1 deletion library/Vspheredb/DbObject/VirtualMachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,19 @@ public function setNet($value)
$addresses[$key]->addresses[] = (object) [
'address' => $config->ipAddress,
'prefixLength' => $config->prefixLength,
'state' => $config->state,
// state is not required, and is an IpAddressStatus enumeration:
// * deprecated Indicates that this is a valid but deprecated address that
// should no longer be used as a source address
// * duplicate Indicates the address has been determined to be non-unique
// on the link, this address will not be reachable.
// * inaccessible Indicates that the address is not accessible because
// interface is not operational
// * invalid Indicates that this isn't a valid
// * preferred Indicates that this is a valid address
// * tentative Indicates that the uniqueness of the address on the link
// is presently being verified
// * unknown Indicates that the status cannot be determined
'state' => property_exists($config, 'state') ? $config->state : null,
];
}
}
Expand Down
7 changes: 6 additions & 1 deletion library/Vspheredb/Web/Table/VmNetworkAdapterTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ protected function formatSimple($row)
);
$aIpInfo = [];
foreach ($ipInfo->addresses as $address) {
$aIpInfo[] = sprintf('%s/%s (%s)', $address->address, $address->prefixLength, $address->state);
// Explicit check for isset, as WP had a workaround skipping the property
if (! isset($address->state) || $address->state === null) {
$aIpInfo[] = sprintf('%s/%s', $address->address, $address->prefixLength);
} else {
$aIpInfo[] = sprintf('%s/%s (%s)', $address->address, $address->prefixLength, $address->state);
}
}
if (empty($aIpInfo)) {
$aIpInfo = '';
Expand Down

0 comments on commit 23340c5

Please sign in to comment.