Implement default kubevirt pipeline, support provider network
Change-Id: I82eaaed05668067090703ec3c10ae6151c2ea815
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
new file mode 100644
index 0000000..967c23b
--- /dev/null
+++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/util/KubevirtNetworkingUtil.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2021-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.kubevirtnetworking.util;
+
+import org.apache.commons.lang.StringUtils;
+import org.onosproject.cfg.ConfigProperty;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * An utility that used in KubeVirt networking app.
+ */
+public final class KubevirtNetworkingUtil {
+
+ private static final Logger log = LoggerFactory.getLogger(KubevirtNetworkingUtil.class);
+
+ private static final int PORT_NAME_MAX_LENGTH = 15;
+
+ /**
+ * Prevents object installation from external.
+ */
+ private KubevirtNetworkingUtil() {
+ }
+
+ /**
+ * Obtains the boolean property value with specified property key name.
+ *
+ * @param properties a collection of properties
+ * @param name key name
+ * @return mapping value
+ */
+ public static boolean getPropertyValueAsBoolean(Set<ConfigProperty> properties,
+ String name) {
+ Optional<ConfigProperty> property =
+ properties.stream().filter(p -> p.name().equals(name)).findFirst();
+
+ return property.map(ConfigProperty::asBoolean).orElse(false);
+ }
+
+ /**
+ * Re-structures the OVS port name.
+ * The length of OVS port name should be not large than 15.
+ *
+ * @param portName original port name
+ * @return re-structured OVS port name
+ */
+ public static String structurePortName(String portName) {
+
+ // The size of OVS port name should not be larger than 15
+ if (portName.length() > PORT_NAME_MAX_LENGTH) {
+ return StringUtils.substring(portName, 0, PORT_NAME_MAX_LENGTH);
+ }
+
+ return portName;
+ }
+}