chore(xo-server-sdn-controller): use ?. to simplify tests (#4459)

This commit is contained in:
BenjiReis
2019-08-28 16:49:38 +02:00
committed by Julien Fontanet
parent 3890d4d9d1
commit 5dfb299e37
2 changed files with 3 additions and 4 deletions

View File

@@ -714,8 +714,7 @@ class SDNController extends EventEmitter {
_setControllerNeeded(xapi) {
const controller = find(xapi.objects.all, { $type: 'SDN_controller' })
return !(
controller !== undefined &&
controller.protocol === PROTOCOL &&
controller?.protocol === PROTOCOL &&
controller.address === '' &&
controller.port === 0
)
@@ -818,7 +817,7 @@ class SDNController extends EventEmitter {
for (const host of hosts) {
const pif = find(host.$PIFs, { network: network.$ref })
if (pif !== undefined && pif.currently_attached && host.$metrics.live) {
if (pif?.currently_attached && host.$metrics.live) {
newCenter = host
}
}

View File

@@ -146,7 +146,7 @@ export class OvsdbClient {
let opResult
do {
opResult = jsonObjects[0].result[i]
if (opResult !== undefined && opResult.error !== undefined) {
if (opResult?.error !== undefined) {
error = opResult.error
details = opResult.details
}