[ONOS-3953] Implements Security Group of Openstack
Change-Id: I30766097a2894a26e46a7a399176d99e95af6abf
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/OpenstackPortInfo.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/OpenstackPortInfo.java
index 0099ea9..0ab8681 100644
--- a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/OpenstackPortInfo.java
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/OpenstackPortInfo.java
@@ -18,6 +18,10 @@
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
import org.onosproject.net.DeviceId;
+
+import java.util.Collection;
+import java.util.Collections;
+
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -29,70 +33,174 @@
private final DeviceId deviceId;
private final long vni;
private final Ip4Address gatewayIP;
+ private final Collection<String> securityGroups;
- public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni, Ip4Address gatewayIP) {
+ /**
+ * Returns OpenstackPortInfo reference.
+ *
+ * @param hostIp host IP address
+ * @param hostMac host MAC address
+ * @param deviceId device ID
+ * @param vni tunnel ID
+ * @param gatewayIP gateway IP address
+ * @param securityGroups security group list
+ */
+ public OpenstackPortInfo(Ip4Address hostIp, MacAddress hostMac, DeviceId deviceId, long vni,
+ Ip4Address gatewayIP, Collection<String> securityGroups) {
this.hostIp = hostIp;
this.hostMac = hostMac;
this.deviceId = deviceId;
this.vni = vni;
this.gatewayIP = gatewayIP;
+ this.securityGroups = securityGroups;
}
+ /**
+ * Returns IP address of the port.
+ *
+ * @return IP address
+ */
public Ip4Address ip() {
return hostIp;
}
+ /**
+ * Returns MAC address of the port.
+ *
+ * @return MAC address
+ */
public MacAddress mac() {
return hostMac;
}
+ /**
+ * Returns device ID.
+ *
+ * @return device ID
+ */
public DeviceId deviceId() {
return deviceId;
}
+ /**
+ * Returns tunnel ID.
+ *
+ * @return tunnel ID
+ */
public long vni() {
return vni;
}
+ /**
+ * Returns gateway IP address.
+ *
+ * @return gateway IP address
+ */
public Ip4Address gatewayIP() {
return gatewayIP;
}
+ /**
+ * Returns Security Group ID list.
+ *
+ * @return list of Security Group ID
+ */
+ public Collection<String> securityGroups() {
+ return Collections.unmodifiableCollection(securityGroups);
+ }
+
+ /**
+ * Returns the builder of the OpenstackPortInfo.
+ *
+ * @return OpenstackPortInfo builder reference
+ */
public static OpenstackPortInfo.Builder builder() {
return new Builder();
}
+ /**
+ * Represents the OpenstackPortInfo Builder.
+ *
+ */
public static final class Builder {
private Ip4Address hostIp;
private MacAddress hostMac;
private DeviceId deviceId;
private long vni;
private Ip4Address gatewayIP;
+ private Collection<String> securityGroups;
+ /**
+ * Sets the IP address of the port.
+ *
+ * @param gatewayIP
+ * @return Builder reference
+ */
public Builder setGatewayIP(Ip4Address gatewayIP) {
this.gatewayIP = checkNotNull(gatewayIP, "gatewayIP cannot be null");
return this;
}
+ /**
+ * Sets the host IP address of the port.
+ *
+ * @param hostIp host IP address
+ * @return Builder reference
+ */
public Builder setHostIp(Ip4Address hostIp) {
this.hostIp = checkNotNull(hostIp, "hostIp cannot be null");
return this;
}
+ /**
+ * Sets the host MAC address of the port.
+ *
+ * @param hostMac host MAC address
+ * @return Builder reference
+ */
public Builder setHostMac(MacAddress hostMac) {
this.hostMac = checkNotNull(hostMac, "hostMac cannot be bull");
return this;
}
+ /**
+ * Sets the device ID.
+ *
+ * @param deviceId device ID
+ * @return Builder reference
+ */
public Builder setDeviceId(DeviceId deviceId) {
this.deviceId = checkNotNull(deviceId, "deviceId cannot be null");
return this;
}
+ /**
+ * Sets the tunnel ID.
+ *
+ * @param vni tunnel ID
+ * @return Builder reference
+ */
public Builder setVni(long vni) {
this.vni = checkNotNull(vni, "vni cannot be null");
return this;
}
+
+ /**
+ * Sets the security group ID list.
+ *
+ * @param securityGroups security group ID list
+ * @return Builder reference
+ */
+ public Builder setSecurityGroups(Collection<String> securityGroups) {
+ this.securityGroups = securityGroups;
+ return this;
+ }
+
+ /**
+ * Builds the OpenstackPortInfo reference.
+ *
+ * @return OpenstackPortInfo reference
+ */
public OpenstackPortInfo build() {
return new OpenstackPortInfo(this);
}
@@ -104,5 +212,6 @@
deviceId = builder.deviceId;
vni = builder.vni;
gatewayIP = builder.gatewayIP;
+ securityGroups = builder.securityGroups;
}
}