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/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());
}