Fix: wait for creation of patch ports which are on tenant bridges

Resolve a NPE issue caused when missing name attribute in status
object in VirtualMachineInstance

Change-Id: I1315a63bbaae250abcc4ed6cec92fb1ed160dfd8
(cherry picked from commit dd4041e154a2850d48ed44800a7189cd04df0e6d)
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupHandler.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupHandler.java
index c551369..674c6ca 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupHandler.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/KubevirtSecurityGroupHandler.java
@@ -297,6 +297,19 @@
 
     private void initializeTenantAclTable(KubevirtNetwork network,
                                             DeviceId deviceId, boolean install) {
+        // FIXME: in bridge initialization phase, some patch ports may not be
+        // available until they are created, we wait for a while ensure all
+        // patch ports are created via network bootstrap
+        while (true) {
+            if (network.tenantToTunnelPort(deviceId) != null) {
+                break;
+            } else {
+                log.info("Wait for tenant patch ports creation for device {} " +
+                         "and network {}", deviceId, network.networkId());
+                waitFor(5);
+            }
+        }
+
         PortNumber patchPort = network.tenantToTunnelPort(deviceId);
         initializeAclTable(deviceId, TENANT_ACL_RECIRC_TABLE, patchPort, install);
     }
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
index b49bbcc..89ff8b2 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
@@ -357,7 +357,15 @@
 
             Set<KubevirtPort> ports = new HashSet<>();
             for (JsonNode interfaceJson : interfacesJson) {
-                String name = interfaceJson.get(NAME).asText();
+                JsonNode jsonName = interfaceJson.get(NAME);
+
+                // in some cases, name attribute may not be available from the
+                // interface, we skip inspect this interface
+                if (jsonName == null) {
+                    continue;
+                }
+
+                String name = jsonName.asText();
                 KubevirtNetwork network = networks.stream()
                         .filter(n -> (NETWORK_PREFIX + n.name()).equals(name) ||
                                      (n.name() + "-net").equals(name))