Refactor: make query methods visible in OpenStackNetworkAdminService
Change-Id: I79c9944387da1d93972cc0d79c7d0b7c57b47f21
diff --git a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkAdminService.java b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkAdminService.java
index 86f66a4..fe28d32 100644
--- a/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkAdminService.java
+++ b/apps/openstacknetworking/api/src/main/java/org/onosproject/openstacknetworking/api/OpenstackNetworkAdminService.java
@@ -22,7 +22,7 @@
/**
* Service for administering the inventory of OpenStack network, subnet and port.
*/
-public interface OpenstackNetworkAdminService {
+public interface OpenstackNetworkAdminService extends OpenstackNetworkService {
/**
* Creates a network with the given information.
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java
index a297ca0..f2bb109 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java
@@ -21,7 +21,6 @@
import org.apache.karaf.shell.commands.Command;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
-import org.onosproject.openstacknetworking.api.OpenstackNetworkService;
import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
import org.onosproject.openstacknetworking.api.OpenstackRouterService;
import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
@@ -84,7 +83,6 @@
OpenstackSecurityGroupAdminService osSgAdminService = get(OpenstackSecurityGroupAdminService.class);
OpenstackSecurityGroupService osSgService = get(OpenstackSecurityGroupService.class);
OpenstackNetworkAdminService osNetAdminService = get(OpenstackNetworkAdminService.class);
- OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
OpenstackRouterAdminService osRouterAdminService = get(OpenstackRouterAdminService.class);
OpenstackRouterService osRouterService = get(OpenstackRouterService.class);
@@ -120,7 +118,7 @@
print("\nSynchronizing OpenStack networks");
print(NETWORK_FORMAT, "ID", "Name", "VNI", "Subnets");
osClient.networking().network().list().forEach(osNet -> {
- if (osNetService.network(osNet.getId()) != null) {
+ if (osNetAdminService.network(osNet.getId()) != null) {
osNetAdminService.updateNetwork(osNet);
} else {
osNetAdminService.createNetwork(osNet);
@@ -131,23 +129,23 @@
print("\nSynchronizing OpenStack subnets");
print(SUBNET_FORMAT, "ID", "Network", "CIDR");
osClient.networking().subnet().list().forEach(osSubnet -> {
- if (osNetService.subnet(osSubnet.getId()) != null) {
+ if (osNetAdminService.subnet(osSubnet.getId()) != null) {
osNetAdminService.updateSubnet(osSubnet);
} else {
osNetAdminService.createSubnet(osSubnet);
}
- printSubnet(osSubnet, osNetService);
+ printSubnet(osSubnet, osNetAdminService);
});
print("\nSynchronizing OpenStack ports");
print(PORT_FORMAT, "ID", "Network", "MAC", "Fixed IPs");
osClient.networking().port().list().forEach(osPort -> {
- if (osNetService.port(osPort.getId()) != null) {
+ if (osNetAdminService.port(osPort.getId()) != null) {
osNetAdminService.updatePort(osPort);
} else {
osNetAdminService.createPort(osPort);
}
- printPort(osPort, osNetService);
+ printPort(osPort, osNetAdminService);
});
print("\nSynchronizing OpenStack routers");
@@ -160,13 +158,13 @@
}
// FIXME do we need to manage router interfaces separately?
- osNetService.ports().stream()
+ osNetAdminService.ports().stream()
.filter(osPort -> Objects.equals(osPort.getDeviceId(), osRouter.getId()) &&
Objects.equals(osPort.getDeviceOwner(), DEVICE_OWNER_IFACE))
.forEach(osPort -> addRouterIface(osPort, osRouterService,
osRouterAdminService));
- printRouter(osRouter, osNetService);
+ printRouter(osRouter, osNetAdminService);
});
print("\nSynchronizing OpenStack floating IPs");
@@ -213,7 +211,7 @@
print(strNet);
}
- private void printSubnet(Subnet osSubnet, OpenstackNetworkService osNetService) {
+ private void printSubnet(Subnet osSubnet, OpenstackNetworkAdminService osNetService) {
final String strSubnet = String.format(SUBNET_FORMAT,
osSubnet.getId(),
osNetService.network(osSubnet.getNetworkId()).getName(),
@@ -221,7 +219,7 @@
print(strSubnet);
}
- private void printPort(Port osPort, OpenstackNetworkService osNetService) {
+ private void printPort(Port osPort, OpenstackNetworkAdminService osNetService) {
List<String> fixedIps = osPort.getFixedIps().stream()
.map(IP::getIpAddress)
.collect(Collectors.toList());
@@ -233,7 +231,7 @@
print(strPort);
}
- private void printRouter(Router osRouter, OpenstackNetworkService osNetService) {
+ private void printRouter(Router osRouter, OpenstackNetworkAdminService osNetService) {
List<String> externals = osNetService.ports().stream()
.filter(osPort -> Objects.equals(osPort.getDeviceId(), osRouter.getId()) &&
Objects.equals(osPort.getDeviceOwner(), DEVICE_OWNER_GW))