CORD-534 Added separate interfaces for Network and ServiceNetwork
Which are useful to implement OpenStack and XOS client implementation.
And removed "get" from get methods.
Change-Id: Icb477e48179a03e88003b1a38dd8f4ea83d92886
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java b/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java
index afb2a1e..db5681c 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java
@@ -20,51 +20,53 @@
import org.openstack4j.model.network.Subnet;
/**
- * Service for administering the inventory of virtual network and service network.
+ * Service for administering the inventory of {@link Network} and
+ * {@link ServiceNetwork}.
*/
-public interface CordVtnAdminService extends CordVtnService {
+public interface CordVtnAdminService extends CordVtnService, NetworkService,
+ ServiceNetworkService {
/**
- * Creates vtn port with given service port information.
+ * Creates a service port with the given information.
*
* @param servicePort the new service port
*/
- void createVtnPort(ServicePort servicePort);
+ void createServicePort(ServicePort servicePort);
/**
- * Updates vtn port with given service port information.
+ * Updates a service port with the given information.
*
* @param servicePort the updated service port
*/
- void updateVtnPort(ServicePort servicePort);
+ void updateServicePort(ServicePort servicePort);
/**
- * Removes vtn port with given port id.
+ * Removes a service port with the given port id.
*
* @param portId port id
*/
- void removeVtnPort(PortId portId);
+ void removeServicePort(PortId portId);
/**
- * Creates vtn network with given service network information.
+ * Creates a service network with the given information.
*
* @param serviceNet the new service network
*/
- void createVtnNetwork(ServiceNetwork serviceNet);
+ void createServiceNetwork(ServiceNetwork serviceNet);
/**
- * Updates the vtn network with given service network information.
+ * Updates a service network with the given information.
*
* @param serviceNet the updated service network
*/
- void updateVtnNetwork(ServiceNetwork serviceNet);
+ void updateServiceNetwork(ServiceNetwork serviceNet);
/**
- * Removes the vtn network.
+ * Removes a service network with the given network id.
*
* @param netId network id
*/
- void removeVtnNetwork(NetworkId netId);
+ void removeServiceNetwork(NetworkId netId);
/**
* Creates a port.
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnService.java b/src/main/java/org/opencord/cordvtn/api/CordVtnService.java
index 5b0849e..1a9f78f 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnService.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnService.java
@@ -16,35 +16,23 @@
package org.opencord.cordvtn.api;
import org.onosproject.event.ListenerService;
-import org.openstack4j.model.network.Network;
-import org.openstack4j.model.network.Port;
-import org.openstack4j.model.network.Subnet;
import java.util.Set;
/**
- * Service for interacting with the inventory of VTN network and port.
+ * Service for interacting with the inventory of {@link VtnNetwork} and
+ * {@link VtnPort}.
*/
public interface CordVtnService
extends ListenerService<VtnNetworkEvent, VtnNetworkListener> {
/**
- * Returns the service port with the given port id.
+ * Returns the VTN port with the given port id.
*
* @param portId port id
* @return service port
*/
- VtnPort getVtnPort(PortId portId);
-
- /**
- * Returns the vtn port with the given port id. It returns the VTN port with
- * the default settings if no service port exists for the port.
- *
- * @param portId port id
- * @return vtn port for the port, of the default vtn port if no service port
- * exists for the port
- */
- VtnPort getVtnPortOrDefault(PortId portId);
+ VtnPort vtnPort(PortId portId);
/**
* Returns the VTN port with the given port name.
@@ -52,98 +40,27 @@
* @param portName port name
* @return vtn port
*/
- VtnPort getVtnPort(String portName);
+ VtnPort vtnPort(String portName);
/**
- * Returns all service ports.
+ * Returns all VTN ports.
*
* @return set of service ports
*/
- Set<VtnPort> getVtnPorts();
+ Set<VtnPort> vtnPorts();
/**
- * Returns the service network with the given network id.
+ * Returns the VTN network with the given network id.
*
* @param netId network id
* @return service network
*/
- VtnNetwork getVtnNetwork(NetworkId netId);
+ VtnNetwork vtnNetwork(NetworkId netId);
/**
- * Returns the vtn network with the given network id. It returns the VTN
- * network with default settings if no service network exists for the network.
- *
- * @param netId network id
- * @return vtn network for the network id, or the default vtn network if no
- * service network is created for the network
- */
- VtnNetwork getVtnNetworkOrDefault(NetworkId netId);
-
- /**
- * Returns all service networks.
+ * Returns all VTN networks.
*
* @return set of service networks
*/
- Set<VtnNetwork> getVtnNetworks();
-
- /**
- * Returns the port with the given port id.
- *
- * @param portId port id
- * @return port
- */
- Port getPort(PortId portId);
-
- /**
- * Returns all ports.
- *
- * @return set of ports
- */
- Set<Port> getPorts();
-
- /**
- * Returns the network with the given network id.
- *
- * @param netId network id
- * @return network
- */
- Network getNetwork(NetworkId netId);
-
- /**
- * Returns all networks.
- *
- * @return set of networks
- */
- Set<Network> getNetworks();
-
- /**
- * Returns the subnet with the given subnet id.
- *
- * @param subnetId subnet id
- * @return subnet
- */
- Subnet getSubnet(SubnetId subnetId);
-
- /**
- * Returns all subnets.
- *
- * @return set of subnets
- */
- Set<Subnet> getSubnets();
-
- /**
- * Returns instance attached to the given port.
- *
- * @param portId port identifier
- * @return instance, or null if no instance for the port
- */
- Instance getInstance(PortId portId);
-
- /**
- * Returns instances in the given network.
- *
- * @param netId network identifier
- * @return set of instances, empty set if no instances in the network
- */
- Set<Instance> getInstances(NetworkId netId);
+ Set<VtnNetwork> vtnNetworks();
}
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java b/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
index bfa84f7..42b71c8 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
@@ -30,16 +30,16 @@
/**
* Creates vtn network.
*
- * @param serviceNet the new vtn network
+ * @param vtnNet vtn network
*/
- void createVtnNetwork(VtnNetwork serviceNet);
+ void createVtnNetwork(VtnNetwork vtnNet);
/**
* Updates the vtn network.
*
- * @param serviceNet the updated vtn network
+ * @param vtnNet vtn network
*/
- void updateVtnNetwork(VtnNetwork serviceNet);
+ void updateVtnNetwork(VtnNetwork vtnNet);
/**
* Returns the vtn network with the given network id.
@@ -47,17 +47,17 @@
* @param netId network id
* @return vtn network
*/
- VtnNetwork getVtnNetwork(NetworkId netId);
+ VtnNetwork vtnNetwork(NetworkId netId);
/**
* Returns all vtn networks.
*
* @return set of vtn networks
*/
- Set<VtnNetwork> getVtnNetworks();
+ Set<VtnNetwork> vtnNetworks();
/**
- * Removes the vtn network.
+ * Removes the vtn network with the given network id.
*
* @param netId network id
*/
@@ -66,16 +66,16 @@
/**
* Creates vtn port.
*
- * @param servicePort the new vtn port
+ * @param vtnPort the new vtn port
*/
- void createVtnPort(VtnPort servicePort);
+ void createVtnPort(VtnPort vtnPort);
/**
* Updates the vtn port.
*
- * @param servicePort vtn port
+ * @param vtnPort vtn port
*/
- void updateVtnPort(VtnPort servicePort);
+ void updateVtnPort(VtnPort vtnPort);
/**
* Returns the vtn port with the given port id.
@@ -83,14 +83,14 @@
* @param portId port id
* @return vtn port
*/
- VtnPort getVtnPort(PortId portId);
+ VtnPort vtnPort(PortId portId);
/**
* Returns all vtn ports.
*
* @return set of vtn ports
*/
- Set<VtnPort> getVtnPorts();
+ Set<VtnPort> vtnPorts();
/**
* Removes vtn port.
@@ -119,14 +119,14 @@
* @param netId network id
* @return network
*/
- Network getNetwork(NetworkId netId);
+ Network network(NetworkId netId);
/**
* Returns all networks.
*
* @return set of networks
*/
- Set<Network> getNetworks();
+ Set<Network> networks();
/**
* Removes the network with the given network id.
@@ -155,14 +155,14 @@
* @param portId port id
* @return port
*/
- Port getPort(PortId portId);
+ Port port(PortId portId);
/**
* Returns all ports.
*
* @return set of ports
*/
- Set<Port> getPorts();
+ Set<Port> ports();
/**
* Removes the port with the given port id.
@@ -191,14 +191,14 @@
* @param subnetId subnet id
* @return subnet
*/
- Subnet getSubnet(SubnetId subnetId);
+ Subnet subnet(SubnetId subnetId);
/**
* Returns all subnets.
*
* @return set of subnets
*/
- Set<Subnet> getSubnets();
+ Set<Subnet> subnets();
/**
* Removes the subnet with the given subnet id.
diff --git a/src/main/java/org/opencord/cordvtn/api/NetworkService.java b/src/main/java/org/opencord/cordvtn/api/NetworkService.java
new file mode 100644
index 0000000..aa178e5
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/api/NetworkService.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.opencord.cordvtn.api;
+
+import org.openstack4j.model.network.Network;
+import org.openstack4j.model.network.Port;
+import org.openstack4j.model.network.Subnet;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of {@link Network}, {@link Port},
+ * and {@link Subnet}.
+ */
+public interface NetworkService {
+
+ /**
+ * Returns the network with the supplied network ID.
+ *
+ * @param netId network id
+ * @return network
+ */
+ Network network(NetworkId netId);
+
+ /**
+ * Returns all networks registered in the service.
+ *
+ * @return set of networks
+ */
+ Set<Network> networks();
+
+ /**
+ * Returns the port with the supplied port ID.
+ *
+ * @param portId port id
+ * @return port
+ */
+ Port port(PortId portId);
+
+ /**
+ * Returns all ports registered in the service.
+ *
+ * @return set of ports
+ */
+ Set<Port> ports();
+
+ /**
+ * Returns the subnet with the supplied subnet ID.
+ *
+ * @param subnetId subnet id
+ * @return subnet
+ */
+ Subnet subnet(SubnetId subnetId);
+
+ /**
+ * Returns all subnets registered in the service.
+ *
+ * @return set of subnets
+ */
+ Set<Subnet> subnets();
+}
diff --git a/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java b/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java
index 6da6833..90de69c 100644
--- a/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java
+++ b/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java
@@ -24,7 +24,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Representation of a service network.
+ * Representation of a service network which holds service specific information,
+ * like service type or dependency, in addition to the common network.
*/
public class ServiceNetwork {
diff --git a/src/main/java/org/opencord/cordvtn/api/ServiceNetworkService.java b/src/main/java/org/opencord/cordvtn/api/ServiceNetworkService.java
new file mode 100644
index 0000000..1b387b7
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/api/ServiceNetworkService.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.opencord.cordvtn.api;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of {@link ServiceNetwork} and
+ * {@link ServicePort}.
+ */
+public interface ServiceNetworkService {
+
+ /**
+ * Returns the service network with the supplied network ID.
+ *
+ * @param netId network id
+ * @return service network
+ */
+ ServiceNetwork serviceNetwork(NetworkId netId);
+
+ /**
+ * Returns all service networks registered in the service.
+ *
+ * @return set of service networks
+ */
+ Set<ServiceNetwork> serviceNetworks();
+
+ /**
+ * Returns the service port with the supplied port ID.
+ *
+ * @param portId port id
+ * @return service port
+ */
+ ServicePort servicePort(PortId portId);
+
+ /**
+ * Returns all service ports registered in the service.
+ *
+ * @return set of service ports
+ */
+ Set<ServicePort> servicePorts();
+}
diff --git a/src/main/java/org/opencord/cordvtn/api/ServicePort.java b/src/main/java/org/opencord/cordvtn/api/ServicePort.java
index 3ed18ee..a6e048b 100644
--- a/src/main/java/org/opencord/cordvtn/api/ServicePort.java
+++ b/src/main/java/org/opencord/cordvtn/api/ServicePort.java
@@ -26,7 +26,8 @@
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Representation of a service port.
+ * Representation of a service port which holds service specific port information,
+ * like vlan tag or additional addresses, to the common network port.
*/
public class ServicePort {
diff --git a/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java b/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java
index 644a939..55fb595 100644
--- a/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java
+++ b/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java
@@ -32,8 +32,11 @@
import static org.opencord.cordvtn.api.ServiceNetwork.ServiceNetworkType.PRIVATE;
/**
- * Representation of the network containing all network information consumed by
- * VTN service.
+ * Representation of a network holding the basic virtual network and additional
+ * service network specific information.
+ * All the services making use of {@link CordVtnService} are intended to interface
+ * with this VtnNetwork, and not allowed to directly access {@link Network} or
+ * {@link ServiceNetwork}.
*/
public final class VtnNetwork extends ServiceNetwork {
diff --git a/src/main/java/org/opencord/cordvtn/api/VtnPort.java b/src/main/java/org/opencord/cordvtn/api/VtnPort.java
index a7d8385..af1bd99 100644
--- a/src/main/java/org/opencord/cordvtn/api/VtnPort.java
+++ b/src/main/java/org/opencord/cordvtn/api/VtnPort.java
@@ -30,7 +30,11 @@
import static com.google.common.base.Preconditions.checkNotNull;
/**
- * Representation of the port containing all port information consumed by VTN service.
+ * Representation of a port holding the basic virtual port and additional service
+ * port specific information.
+ * All the services making use of {@link CordVtnService} are intended to interface
+ * with this VtnPort, and not allowed to directly access {@link Port} or
+ * {@link ServicePort}.
*/
public final class VtnPort extends ServicePort {
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnManager.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnManager.java
index d645b8f..d7aead8 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnManager.java
@@ -15,13 +15,13 @@
*/
package org.opencord.cordvtn.impl;
+import com.google.common.collect.ImmutableSet;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.Tools;
import org.onosproject.event.ListenerRegistry;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
@@ -32,8 +32,10 @@
import org.opencord.cordvtn.api.CordVtnStoreDelegate;
import org.opencord.cordvtn.api.Instance;
import org.opencord.cordvtn.api.NetworkId;
+import org.opencord.cordvtn.api.NetworkService;
import org.opencord.cordvtn.api.PortId;
import org.opencord.cordvtn.api.ServiceNetwork;
+import org.opencord.cordvtn.api.ServiceNetworkService;
import org.opencord.cordvtn.api.ServicePort;
import org.opencord.cordvtn.api.SubnetId;
import org.opencord.cordvtn.api.VtnNetwork;
@@ -45,13 +47,12 @@
import org.openstack4j.model.network.Subnet;
import org.slf4j.Logger;
+import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
-import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.opencord.cordvtn.api.Instance.NETWORK_ID;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -60,7 +61,8 @@
@Component(immediate = true)
@Service
public class CordVtnManager extends ListenerRegistry<VtnNetworkEvent, VtnNetworkListener>
- implements CordVtnAdminService, CordVtnService {
+ implements CordVtnAdminService, CordVtnService, NetworkService,
+ ServiceNetworkService {
protected final Logger log = getLogger(getClass());
@@ -85,8 +87,6 @@
private static final String ERR_SYNC = "VTN store is out of sync: ";
private static final String ERR_NOT_FOUND = " does not exist";
- private static final String ERR_IN_USE_INSTANCE = "There are instances still in use on the network %s";
- private static final String ERR_IN_USE_NETWORK = "There are subscribers still in use on the network %s";
private static final String ERR_IN_USE_PORT = "There are ports still in use on the network %s";
private static final String ERR_SUBNET_DUPLICATE = "Subnet already exists for network %s";
@@ -116,10 +116,10 @@
}
@Override
- public void createVtnNetwork(ServiceNetwork serviceNet) {
+ public void createServiceNetwork(ServiceNetwork serviceNet) {
checkNotNull(serviceNet, ERR_NULL_SERVICE_NET);
synchronized (this) {
- Network network = store.getNetwork(serviceNet.id());
+ Network network = store.network(serviceNet.id());
if (network == null) {
final String error = ERR_SYNC + NETWORK + serviceNet.id() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
@@ -133,7 +133,7 @@
// TODO check VTN network instead of network
serviceNet.providers().stream().forEach(provider -> {
- if (store.getNetwork(provider.id()) == null) {
+ if (store.network(provider.id()) == null) {
final String error = ERR_SYNC + PROVIDER + provider.id() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
}
@@ -145,10 +145,10 @@
}
@Override
- public void updateVtnNetwork(ServiceNetwork serviceNet) {
+ public void updateServiceNetwork(ServiceNetwork serviceNet) {
checkNotNull(serviceNet, ERR_NULL_SERVICE_NET);
synchronized (this) {
- VtnNetwork existing = store.getVtnNetwork(serviceNet.id());
+ VtnNetwork existing = store.vtnNetwork(serviceNet.id());
if (existing == null) {
final String error = ERR_SYNC + NETWORK + serviceNet.id() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
@@ -163,7 +163,7 @@
}
@Override
- public void removeVtnNetwork(NetworkId netId) {
+ public void removeServiceNetwork(NetworkId netId) {
checkNotNull(netId, ERR_NULL_NET_ID);
// TODO check if the network still exists?
store.removeVtnNetwork(netId);
@@ -171,10 +171,10 @@
}
@Override
- public void createVtnPort(ServicePort servicePort) {
+ public void createServicePort(ServicePort servicePort) {
checkNotNull(servicePort, ERR_NULL_SERVICE_PORT);
synchronized (this) {
- Port port = store.getPort(servicePort.id());
+ Port port = store.port(servicePort.id());
if (port == null) {
final String error = ERR_SYNC + PORT + servicePort.id() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
@@ -185,10 +185,10 @@
}
@Override
- public void updateVtnPort(ServicePort servicePort) {
+ public void updateServicePort(ServicePort servicePort) {
checkNotNull(servicePort, ERR_NULL_SERVICE_PORT);
synchronized (this) {
- VtnPort vtnPort = store.getVtnPort(servicePort.id());
+ VtnPort vtnPort = store.vtnPort(servicePort.id());
if (vtnPort == null) {
final String error = ERR_SYNC + PORT + servicePort.id() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
@@ -199,7 +199,7 @@
}
@Override
- public void removeVtnPort(PortId portId) {
+ public void removeServicePort(PortId portId) {
checkNotNull(portId, ERR_NULL_PORT_ID);
store.removeVtnPort(portId);
log.info(String.format(MSG_SERVICE_PORT, REMOVED, portId));
@@ -231,7 +231,7 @@
public void createPort(Port port) {
checkNotNull(port, ERR_NULL_PORT);
synchronized (this) {
- if (store.getNetwork(NetworkId.of(port.getNetworkId())) == null) {
+ if (store.network(NetworkId.of(port.getNetworkId())) == null) {
final String error = ERR_SYNC + port.getNetworkId() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
}
@@ -244,7 +244,7 @@
public void updatePort(Port port) {
checkNotNull(port, ERR_NULL_PORT);
synchronized (this) {
- if (store.getNetwork(NetworkId.of(port.getNetworkId())) == null) {
+ if (store.network(NetworkId.of(port.getNetworkId())) == null) {
final String error = ERR_SYNC + port.getNetworkId() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
}
@@ -261,7 +261,7 @@
final String error = String.format(ERR_IN_USE_PORT, portId);
throw new IllegalStateException(error);
}
- removeVtnPort(portId);
+ removeServicePort(portId);
store.removePort(portId);
log.info(String.format(MSG_PORT, REMOVED, portId));
}
@@ -271,7 +271,7 @@
public void createSubnet(Subnet subnet) {
checkNotNull(subnet, ERR_NULL_SUBNET);
synchronized (this) {
- if (store.getNetwork(NetworkId.of(subnet.getNetworkId())) == null) {
+ if (store.network(NetworkId.of(subnet.getNetworkId())) == null) {
final String error = ERR_SYNC + subnet.getNetworkId() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
}
@@ -290,7 +290,7 @@
public void updateSubnet(Subnet subnet) {
checkNotNull(subnet, ERR_NULL_SUBNET);
synchronized (this) {
- if (store.getNetwork(NetworkId.of(subnet.getNetworkId())) == null) {
+ if (store.network(NetworkId.of(subnet.getNetworkId())) == null) {
final String error = ERR_SYNC + subnet.getNetworkId() + ERR_NOT_FOUND;
throw new IllegalStateException(error);
}
@@ -304,105 +304,115 @@
checkNotNull(subnetId, ERR_NULL_SUBNET_ID);
// FIXME Neutron removes network anyway even if there's an exception here
synchronized (this) {
- removeVtnNetwork(NetworkId.of(store.getSubnet(subnetId).getNetworkId()));
+ removeServiceNetwork(NetworkId.of(store.subnet(subnetId).getNetworkId()));
store.removeSubnet(subnetId);
log.info(String.format(MSG_SUBNET, REMOVED, subnetId));
}
}
@Override
- public VtnNetwork getVtnNetwork(NetworkId netId) {
- checkNotNull(netId, ERR_NULL_NET_ID);
- return store.getVtnNetwork(netId);
- }
-
- @Override
- public VtnNetwork getVtnNetworkOrDefault(NetworkId netId) {
+ public VtnNetwork vtnNetwork(NetworkId netId) {
checkNotNull(netId, ERR_NULL_NET_ID);
// return default VTN network if the network and subnet exist
- VtnNetwork vtnNet = store.getVtnNetwork(netId);
+ VtnNetwork vtnNet = store.vtnNetwork(netId);
return vtnNet == null ? getDefaultVtnNetwork(netId) : vtnNet;
}
@Override
- public Set<VtnNetwork> getVtnNetworks() {
- return store.getVtnNetworks();
+ public Set<VtnNetwork> vtnNetworks() {
+ // TODO implement
+ return ImmutableSet.of();
}
@Override
- public VtnPort getVtnPort(PortId portId) {
- checkNotNull(portId, ERR_NULL_PORT_ID);
- return store.getVtnPort(portId);
- }
-
- @Override
- public VtnPort getVtnPortOrDefault(PortId portId) {
+ public VtnPort vtnPort(PortId portId) {
checkNotNull(portId, ERR_NULL_PORT_ID);
// return default VTN port if the port exists
- VtnPort vtnPort = store.getVtnPort(portId);
+ VtnPort vtnPort = store.vtnPort(portId);
return vtnPort == null ? getDefaultPort(portId) : vtnPort;
}
@Override
- public VtnPort getVtnPort(String portName) {
- Optional<Port> port = store.getPorts()
+ public VtnPort vtnPort(String portName) {
+ Optional<Port> port = store.ports()
.stream()
.filter(p -> p.getId().contains(portName.substring(3)))
.findFirst();
if (!port.isPresent()) {
return null;
}
- return getVtnPortOrDefault(PortId.of(port.get().getId()));
+ return vtnPort(PortId.of(port.get().getId()));
}
@Override
- public Set<VtnPort> getVtnPorts() {
- return store.getVtnPorts();
+ public Set<VtnPort> vtnPorts() {
+ // TODO implement
+ return ImmutableSet.of();
}
@Override
- public Network getNetwork(NetworkId netId) {
+ public ServiceNetwork serviceNetwork(NetworkId netId) {
checkNotNull(netId, ERR_NULL_NET_ID);
- return store.getNetwork(netId);
+ return store.vtnNetwork(netId);
}
@Override
- public Set<Network> getNetworks() {
- return store.getNetworks();
+ public Set<ServiceNetwork> serviceNetworks() {
+ return new HashSet<>(store.vtnNetworks());
}
@Override
- public Port getPort(PortId portId) {
+ public ServicePort servicePort(PortId portId) {
checkNotNull(portId, ERR_NULL_PORT_ID);
- return store.getPort(portId);
+ return store.vtnPort(portId);
}
@Override
- public Set<Port> getPorts() {
- return store.getPorts();
+ public Set<ServicePort> servicePorts() {
+ return new HashSet<>(store.vtnPorts());
}
@Override
- public Subnet getSubnet(SubnetId subnetId) {
+ public Network network(NetworkId netId) {
+ checkNotNull(netId, ERR_NULL_NET_ID);
+ return store.network(netId);
+ }
+
+ @Override
+ public Set<Network> networks() {
+ return store.networks();
+ }
+
+ @Override
+ public Port port(PortId portId) {
+ checkNotNull(portId, ERR_NULL_PORT_ID);
+ return store.port(portId);
+ }
+
+ @Override
+ public Set<Port> ports() {
+ return store.ports();
+ }
+
+ @Override
+ public Subnet subnet(SubnetId subnetId) {
checkNotNull(subnetId, ERR_NULL_SUBNET_ID);
- return store.getSubnet(subnetId);
+ return store.subnet(subnetId);
}
@Override
- public Set<Subnet> getSubnets() {
- return store.getSubnets();
+ public Set<Subnet> subnets() {
+ return store.subnets();
}
- @Override
- public Instance getInstance(PortId portId) {
- VtnPort vtnPort = getVtnPortOrDefault(portId);
+ private Instance getInstance(PortId portId) {
+ VtnPort vtnPort = vtnPort(portId);
if (vtnPort == null) {
final String error = "Failed to build VTN port for " + portId.id();
throw new IllegalStateException(error);
}
-
Host host = hostService.getHost(HostId.hostId(vtnPort.mac()));
if (host == null) {
return null;
@@ -410,18 +420,8 @@
return Instance.of(host);
}
- @Override
- public Set<Instance> getInstances(NetworkId netId) {
- return Tools.stream(hostService.getHosts())
- .filter(host -> Objects.equals(
- host.annotations().value(NETWORK_ID),
- netId.id()))
- .map(Instance::of)
- .collect(Collectors.toSet());
- }
-
private VtnNetwork getDefaultVtnNetwork(NetworkId netId) {
- Network network = getNetwork(netId);
+ Network network = network(netId);
Subnet subnet = getSubnet(netId);
if (network == null || subnet == null) {
return null;
@@ -430,7 +430,7 @@
}
private VtnPort getDefaultPort(PortId portId) {
- Port port = getPort(portId);
+ Port port = port(portId);
if (port == null) {
return null;
}
@@ -439,7 +439,7 @@
private Subnet getSubnet(NetworkId netId) {
// TODO fix networking-onos to send Network UPDATE when subnet created
- Optional<Subnet> subnet = getSubnets().stream()
+ Optional<Subnet> subnet = subnets().stream()
.filter(s -> Objects.equals(s.getNetworkId(), netId.id()))
.findFirst();
return subnet.orElse(null);
diff --git a/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java b/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
index bb1692c..08e67e9 100644
--- a/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
@@ -166,22 +166,22 @@
@Override
public void createDependency(NetworkId subNetId, NetworkId proNetId, Type type) {
// FIXME this is not safe
- VtnNetwork existing = vtnService.getVtnNetworkOrDefault(subNetId);
+ VtnNetwork existing = vtnService.vtnNetwork(subNetId);
if (existing == null) {
log.warn("Failed to create dependency between {} and {}", subNetId, proNetId);
return;
}
- vtnService.createVtnNetwork(existing);
+ vtnService.createServiceNetwork(existing);
VtnNetwork updated = VtnNetwork.builder(existing)
.addProvider(proNetId, type)
.build();
- vtnService.updateVtnNetwork(updated);
+ vtnService.updateServiceNetwork(updated);
}
@Override
public void removeDependency(NetworkId subNetId, NetworkId proNetId) {
// FIXME this is not safe
- VtnNetwork subNet = vtnService.getVtnNetwork(subNetId);
+ VtnNetwork subNet = vtnService.vtnNetwork(subNetId);
if (subNet == null) {
log.warn("No dependency exists between {} and {}", subNetId, proNetId);
return;
@@ -189,7 +189,7 @@
VtnNetwork updated = VtnNetwork.builder(subNet)
.delProvider(proNetId)
.build();
- vtnService.updateVtnNetwork(updated);
+ vtnService.updateServiceNetwork(updated);
}
@Override
@@ -200,7 +200,7 @@
return;
}
- VtnNetwork vtnNet = vtnService.getVtnNetworkOrDefault(instance.netId());
+ VtnNetwork vtnNet = vtnService.vtnNetwork(instance.netId());
if (vtnNet == null) {
final String error = ERR_NET_FAIL + instance.netId();
throw new IllegalStateException(error);
@@ -221,7 +221,7 @@
return;
}
- VtnNetwork vtnNet = vtnService.getVtnNetworkOrDefault(instance.netId());
+ VtnNetwork vtnNet = vtnService.vtnNetwork(instance.netId());
if (vtnNet == null) {
final String error = ERR_NET_FAIL + instance.netId();
throw new IllegalStateException(error);
@@ -540,7 +540,7 @@
Set<Dependency> dependencies = subscriber.providers().stream()
.map(provider -> Dependency.builder()
.subscriber(subscriber)
- .provider(vtnService.getVtnNetworkOrDefault(provider.id()))
+ .provider(vtnService.vtnNetwork(provider.id()))
.type(provider.type())
.build())
.collect(Collectors.toSet());
diff --git a/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java b/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java
index 3520ba6..a3b41cc 100644
--- a/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java
+++ b/src/main/java/org/opencord/cordvtn/impl/DistributedCordVtnStore.java
@@ -222,13 +222,13 @@
}
@Override
- public VtnNetwork getVtnNetwork(NetworkId netId) {
+ public VtnNetwork vtnNetwork(NetworkId netId) {
Versioned<VtnNetwork> versioned = vtnNetworkStore.get(netId);
return versioned == null ? null : versioned.value();
}
@Override
- public Set<VtnNetwork> getVtnNetworks() {
+ public Set<VtnNetwork> vtnNetworks() {
return vtnNetworkStore.values().stream().map(Versioned::value)
.collect(Collectors.toSet());
}
@@ -257,13 +257,13 @@
}
@Override
- public VtnPort getVtnPort(PortId portId) {
+ public VtnPort vtnPort(PortId portId) {
Versioned<VtnPort> versioned = vtnPortStore.get(portId);
return versioned == null ? null : versioned.value();
}
@Override
- public Set<VtnPort> getVtnPorts() {
+ public Set<VtnPort> vtnPorts() {
return vtnPortStore.values().stream().map(Versioned::value)
.collect(Collectors.toSet());
}
@@ -292,13 +292,13 @@
}
@Override
- public Network getNetwork(NetworkId netId) {
+ public Network network(NetworkId netId) {
Versioned<Network> versioned = networkStore.get(netId);
return versioned == null ? null : versioned.value();
}
@Override
- public Set<Network> getNetworks() {
+ public Set<Network> networks() {
return networkStore.values().stream().map(Versioned::value)
.collect(Collectors.toSet());
}
@@ -327,13 +327,13 @@
}
@Override
- public Port getPort(PortId portId) {
+ public Port port(PortId portId) {
Versioned<Port> versioned = portStore.get(portId);
return versioned == null ? null : versioned.value();
}
@Override
- public Set<Port> getPorts() {
+ public Set<Port> ports() {
return portStore.values().stream().map(Versioned::value)
.collect(Collectors.toSet());
}
@@ -362,19 +362,19 @@
}
@Override
- public Subnet getSubnet(SubnetId subnetId) {
+ public Subnet subnet(SubnetId subnetId) {
Versioned<Subnet> versioned = subnetStore.get(subnetId);
return versioned == null ? null : versioned.value();
}
@Override
- public Set<Subnet> getSubnets() {
+ public Set<Subnet> subnets() {
return subnetStore.values().stream().map(Versioned::value)
.collect(Collectors.toSet());
}
private Set<VtnNetwork> getSubscribers(NetworkId netId) {
- return getVtnNetworks().stream().filter(net -> net.isProvider(netId))
+ return vtnNetworks().stream().filter(net -> net.isProvider(netId))
.collect(Collectors.toSet());
}
@@ -424,7 +424,7 @@
eventExecutor.execute(() -> {
notifyDelegate(new VtnNetworkEvent(
VTN_PORT_UPDATED,
- getVtnNetwork(event.newValue().value().netId()),
+ vtnNetwork(event.newValue().value().netId()),
event.newValue().value()));
});
break;
@@ -433,7 +433,7 @@
eventExecutor.execute(() -> {
notifyDelegate(new VtnNetworkEvent(
VTN_PORT_CREATED,
- getVtnNetwork(event.newValue().value().netId()),
+ vtnNetwork(event.newValue().value().netId()),
event.newValue().value()));
});
break;
@@ -442,7 +442,7 @@
eventExecutor.execute(() -> {
notifyDelegate(new VtnNetworkEvent(
VTN_PORT_REMOVED,
- getVtnNetwork(event.oldValue().value().netId()),
+ vtnNetwork(event.oldValue().value().netId()),
event.oldValue().value()));
});
break;
diff --git a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
index ba35d9b..4671c4d 100644
--- a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
@@ -174,13 +174,13 @@
return;
}
- VtnPort vtnPort = vtnService.getVtnPort(port.annotations().value(PORT_NAME));
+ VtnPort vtnPort = vtnService.vtnPort(port.annotations().value(PORT_NAME));
if (vtnPort == null) {
log.warn(String.format(ERR_VTN_PORT, port));
return;
}
- VtnNetwork vtnNet = vtnService.getVtnNetworkOrDefault(vtnPort.netId());
+ VtnNetwork vtnNet = vtnService.vtnNetwork(vtnPort.netId());
if (vtnNet == null) {
log.warn(String.format(ERR_VTN_NETWORK, vtnPort));
return;
@@ -290,6 +290,19 @@
hostProvider.hostDetected(hostId, hostDesc, false);
}
+ private Instance getInstance(PortId portId) {
+ VtnPort vtnPort = vtnService.vtnPort(portId);
+ if (vtnPort == null) {
+ final String error = "Failed to build VTN port for " + portId.id();
+ throw new IllegalStateException(error);
+ }
+ Host host = hostService.getHost(HostId.hostId(vtnPort.mac()));
+ if (host == null) {
+ return null;
+ }
+ return Instance.of(host);
+ }
+
private class InternalVtnNetworkListener implements VtnNetworkListener {
@Override
@@ -306,7 +319,7 @@
log.debug("Processing service port {}", event.vtnPort());
PortId portId = event.vtnPort().id();
eventExecutor.execute(() -> {
- Instance instance = vtnService.getInstance(portId);
+ Instance instance = getInstance(portId);
if (instance != null) {
addInstance(instance.host().location());
}
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/AbstractInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/AbstractInstanceHandler.java
index b75051f..d76f56a 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/AbstractInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/AbstractInstanceHandler.java
@@ -102,7 +102,7 @@
}
protected VtnNetwork getVtnNetwork(Instance instance) {
- VtnNetwork vtnNet = vtnService.getVtnNetworkOrDefault(instance.netId());
+ VtnNetwork vtnNet = vtnService.vtnNetwork(instance.netId());
if (vtnNet == null) {
final String error = String.format(ERR_VTN_NETWORK, instance);
throw new IllegalStateException(error);
@@ -111,7 +111,7 @@
}
protected VtnPort getVtnPort(Instance instance) {
- VtnPort vtnPort = vtnService.getVtnPortOrDefault(instance.portId());
+ VtnPort vtnPort = vtnService.vtnPort(instance.portId());
if (vtnPort == null) {
final String error = String.format(ERR_VTN_PORT, instance);
throw new IllegalStateException(error);
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
index 27ea199..76cef03 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
@@ -117,7 +117,7 @@
wanIps, true);
} else {
log.info(String.format(MSG_VSG_VM, MSG_DETECTED, instance));
- VtnPort vtnPort = vtnService.getVtnPortOrDefault(instance.portId());
+ VtnPort vtnPort = vtnService.vtnPort(instance.portId());
if (vtnPort == null || !vtnPort.vlanId().isPresent()) {
// service port can be updated after instance is created
return;
@@ -171,7 +171,7 @@
@Override
protected VtnPort getVtnPort(Instance instance) {
- VtnPort vtnPort = vtnService.getVtnPortOrDefault(instance.portId());
+ VtnPort vtnPort = vtnService.vtnPort(instance.portId());
if (vtnPort == null || !vtnPort.vlanId().isPresent()) {
final String error = String.format(ERR_VTN_PORT, instance);
throw new IllegalStateException(error);
diff --git a/src/main/java/org/opencord/cordvtn/rest/NeutronMl2NetworksWebResource.java b/src/main/java/org/opencord/cordvtn/rest/NeutronMl2NetworksWebResource.java
index 81f82ee..f29c12b 100644
--- a/src/main/java/org/opencord/cordvtn/rest/NeutronMl2NetworksWebResource.java
+++ b/src/main/java/org/opencord/cordvtn/rest/NeutronMl2NetworksWebResource.java
@@ -121,7 +121,7 @@
public Response getNetworks() {
log.trace(String.format(MESSAGE, "GET"));
- Set<Network> nets = adminService.getNetworks();
+ Set<Network> nets = adminService.networks();
ArrayNode arrayNodes = mapper().createArrayNode();
nets.stream().forEach(net -> {
arrayNodes.add(writeNetwork(net));
@@ -144,7 +144,7 @@
public Response getNetwork(@PathParam("id") String id) {
log.trace(String.format(MESSAGE, "GET " + id));
- Network net = adminService.getNetwork(NetworkId.of(id));
+ Network net = adminService.network(NetworkId.of(id));
if (net == null) {
return status(NOT_FOUND).build();
}
diff --git a/src/main/java/org/opencord/cordvtn/rest/NeutronMl2PortsWebResource.java b/src/main/java/org/opencord/cordvtn/rest/NeutronMl2PortsWebResource.java
index 32417bc..a784330 100644
--- a/src/main/java/org/opencord/cordvtn/rest/NeutronMl2PortsWebResource.java
+++ b/src/main/java/org/opencord/cordvtn/rest/NeutronMl2PortsWebResource.java
@@ -123,7 +123,7 @@
public Response getPorts() {
log.trace(String.format(MESSAGE, "GET"));
- Set<Port> ports = adminService.getPorts();
+ Set<Port> ports = adminService.ports();
ArrayNode arrayNodes = mapper().createArrayNode();
ports.stream().forEach(port -> {
arrayNodes.add(writePort(port));
@@ -146,7 +146,7 @@
public Response getPort(@PathParam("id") String id) {
log.trace(String.format(MESSAGE, "GET " + id));
- Port port = adminService.getPort(PortId.of(id));
+ Port port = adminService.port(PortId.of(id));
if (port == null) {
return status(NOT_FOUND).build();
}
diff --git a/src/main/java/org/opencord/cordvtn/rest/NeutronMl2SubnetsWebResource.java b/src/main/java/org/opencord/cordvtn/rest/NeutronMl2SubnetsWebResource.java
index 4a57d28..3d50604 100644
--- a/src/main/java/org/opencord/cordvtn/rest/NeutronMl2SubnetsWebResource.java
+++ b/src/main/java/org/opencord/cordvtn/rest/NeutronMl2SubnetsWebResource.java
@@ -123,7 +123,7 @@
public Response getSubnets() {
log.trace(String.format(MESSAGE, "GET"));
- Set<Subnet> subnets = adminService.getSubnets();
+ Set<Subnet> subnets = adminService.subnets();
ArrayNode arrayNodes = mapper().createArrayNode();
subnets.stream().forEach(subnet -> {
arrayNodes.add(writeSubnet(subnet));
@@ -146,7 +146,7 @@
public Response getSubnet(@PathParam("id") String id) {
log.trace(String.format(MESSAGE, "GET " + id));
- Subnet subnet = adminService.getSubnet(SubnetId.of(id));
+ Subnet subnet = adminService.subnet(SubnetId.of(id));
if (subnet == null) {
return status(NOT_FOUND).build();
}
diff --git a/src/main/java/org/opencord/cordvtn/rest/ServiceNetworkWebResource.java b/src/main/java/org/opencord/cordvtn/rest/ServiceNetworkWebResource.java
index a376a55..765a7aa 100644
--- a/src/main/java/org/opencord/cordvtn/rest/ServiceNetworkWebResource.java
+++ b/src/main/java/org/opencord/cordvtn/rest/ServiceNetworkWebResource.java
@@ -40,8 +40,7 @@
import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
@@ -87,7 +86,7 @@
}
final ServiceNetwork snet = codec(ServiceNetwork.class).decode(snetJson, this);
- adminService.createVtnNetwork(snet);
+ adminService.createServiceNetwork(snet);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path(SERVICE_NETWORKS)
@@ -122,7 +121,7 @@
}
final ServiceNetwork snet = codec(ServiceNetwork.class).decode(snetJson, this);
- adminService.updateVtnNetwork(snet);
+ adminService.updateServiceNetwork(snet);
ObjectNode result = this.mapper().createObjectNode();
result.set(SERVICE_NETWORK, codec(ServiceNetwork.class).encode(snet, this));
@@ -143,7 +142,7 @@
public Response getServiceNetworks() {
log.trace(MESSAGE + "GET");
- List<ServiceNetwork> snets = new ArrayList<>(adminService.getVtnNetworks());
+ Set<ServiceNetwork> snets = adminService.serviceNetworks();
return ok(encodeArray(ServiceNetwork.class, SERVICE_NETWORKS, snets)).build();
}
@@ -161,7 +160,7 @@
public Response getServiceNetwork(@PathParam("id") String id) {
log.trace(MESSAGE + "GET " + id);
- ServiceNetwork snet = adminService.getVtnNetwork(NetworkId.of(id));
+ ServiceNetwork snet = adminService.serviceNetwork(NetworkId.of(id));
if (snet == null) {
log.trace("Returned NOT_FOUND");
return status(NOT_FOUND).build();
@@ -186,7 +185,7 @@
public Response deleteServiceNetwork(@PathParam("id") String id) {
log.trace(MESSAGE + "DELETE " + id);
- adminService.removeVtnNetwork(NetworkId.of(id));
+ adminService.removeServiceNetwork(NetworkId.of(id));
return noContent().build();
}
}
diff --git a/src/main/java/org/opencord/cordvtn/rest/ServicePortWebResource.java b/src/main/java/org/opencord/cordvtn/rest/ServicePortWebResource.java
index 4300fb0..67df9a2 100644
--- a/src/main/java/org/opencord/cordvtn/rest/ServicePortWebResource.java
+++ b/src/main/java/org/opencord/cordvtn/rest/ServicePortWebResource.java
@@ -40,8 +40,7 @@
import javax.ws.rs.core.UriInfo;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
@@ -87,7 +86,7 @@
}
final ServicePort sport = codec(ServicePort.class).decode(portJson, this);
- adminService.createVtnPort(sport);
+ adminService.createServicePort(sport);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path(SERVICE_PORTS)
@@ -122,7 +121,7 @@
}
final ServicePort sport = codec(ServicePort.class).decode(sportJson, this);
- adminService.updateVtnPort(sport);
+ adminService.updateServicePort(sport);
ObjectNode result = this.mapper().createObjectNode();
result.set(SERVICE_PORT, codec(ServicePort.class).encode(sport, this));
@@ -143,7 +142,7 @@
public Response getServicePorts() {
log.trace(MESSAGE + "GET");
- List<ServicePort> sports = new ArrayList<>(adminService.getVtnPorts());
+ Set<ServicePort> sports = adminService.servicePorts();
return ok(encodeArray(ServicePort.class, SERVICE_PORTS, sports)).build();
}
@@ -161,7 +160,7 @@
public Response getServicePort(@PathParam("id") String id) {
log.trace(MESSAGE + "GET " + id);
- ServicePort sport = adminService.getVtnPort(PortId.of(id));
+ ServicePort sport = adminService.servicePort(PortId.of(id));
if (sport == null) {
log.trace("Returned NOT_FOUND");
return status(NOT_FOUND).build();
@@ -186,7 +185,7 @@
public Response deleteServicePort(@PathParam("id") String id) {
log.trace(MESSAGE + "DELETE " + id);
- adminService.removeVtnPort(PortId.of(id));
+ adminService.removeServicePort(PortId.of(id));
return noContent().build();
}
}