Add missing POD related class into kryo, identify master and worker
Change-Id: I9a696f46034749fc42ae9401774fa5ce31c1aaee
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtPodStore.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtPodStore.java
index 3b1a2fc..97c032b 100644
--- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtPodStore.java
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/impl/DistributedKubevirtPodStore.java
@@ -66,6 +66,7 @@
import io.fabric8.kubernetes.api.model.ResourceFieldSelector;
import io.fabric8.kubernetes.api.model.ResourceRequirements;
import io.fabric8.kubernetes.api.model.SELinuxOptions;
+import io.fabric8.kubernetes.api.model.SeccompProfile;
import io.fabric8.kubernetes.api.model.SecretEnvSource;
import io.fabric8.kubernetes.api.model.SecretKeySelector;
import io.fabric8.kubernetes.api.model.SecretVolumeSource;
@@ -176,6 +177,7 @@
.register(SecurityContext.class)
.register(PodSecurityContext.class)
.register(SELinuxOptions.class)
+ .register(SeccompProfile.class)
.register(Volume.class)
.register(VolumeDevice.class)
.register(VolumeMount.class)
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtApiConfigHandler.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtApiConfigHandler.java
index dc3946d..0e7de69 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtApiConfigHandler.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtApiConfigHandler.java
@@ -49,6 +49,7 @@
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
+import java.util.stream.Collectors;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.onlab.util.Tools.groupedThreads;
@@ -158,17 +159,17 @@
}
}
- String roleStr = node.getMetadata().getLabels().keySet().stream()
+ Set<String> rolesFull = node.getMetadata().getLabels().keySet().stream()
.filter(l -> l.contains(K8S_ROLE))
- .findFirst().orElse(null);
+ .collect(Collectors.toSet());
KubevirtNode.Type nodeType = WORKER;
- if (roleStr != null) {
+
+ for (String roleStr : rolesFull) {
String role = roleStr.split("/")[1];
if (MASTER.name().equalsIgnoreCase(role)) {
nodeType = MASTER;
- } else {
- nodeType = WORKER;
+ break;
}
}
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtNodeHandler.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtNodeHandler.java
index c6f67a3..55fd13c 100644
--- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtNodeHandler.java
+++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/impl/DefaultKubevirtNodeHandler.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.kubevirtnode.impl;
+import com.google.common.collect.Lists;
+import org.onlab.packet.IpAddress;
import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterService;
@@ -22,6 +24,7 @@
import org.onosproject.cluster.NodeId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
+import org.onosproject.kubevirtnode.api.KubevirtApiConfigService;
import org.onosproject.kubevirtnode.api.KubevirtNode;
import org.onosproject.kubevirtnode.api.KubevirtNodeAdminService;
import org.onosproject.kubevirtnode.api.KubevirtNodeEvent;
@@ -140,6 +143,9 @@
protected KubevirtNodeAdminService nodeAdminService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
+ protected KubevirtApiConfigService apiConfigService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY)
protected ComponentConfigService componentConfigService;
/** OVSDB server listen port. */
@@ -293,9 +299,9 @@
private void createBridge(KubevirtNode node, String bridgeName, DeviceId devId) {
Device device = deviceService.getDevice(node.ovsdb());
- List<ControllerInfo> controllers = clusterService.getNodes().stream()
- .map(n -> new ControllerInfo(n.ip(), DEFAULT_OFPORT, DEFAULT_OF_PROTO))
- .collect(Collectors.toList());
+ IpAddress serverIp = apiConfigService.apiConfig().ipAddress();
+ ControllerInfo controlInfo = new ControllerInfo(serverIp, DEFAULT_OFPORT, DEFAULT_OF_PROTO);
+ List<ControllerInfo> controllers = Lists.newArrayList(controlInfo);
String dpid = devId.toString().substring(DPID_BEGIN);