use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.
the class OpenstackRoutingSnatHandler method routerUpdated.
private void routerUpdated(Router osRouter) {
ExternalGateway exGateway = osRouter.getExternalGatewayInfo();
ExternalPeerRouter externalPeerRouter = osNetworkAdminService.externalPeerRouter(exGateway);
VlanId vlanId = externalPeerRouter == null ? VlanId.NONE : externalPeerRouter.vlanId();
if (exGateway == null) {
deleteUnassociatedExternalPeerRouter();
osRouterService.routerInterfaces(osRouter.getId()).forEach(iface -> setSourceNat(iface, false));
} else {
osNetworkAdminService.deriveExternalPeerRouterMac(exGateway, osRouter, vlanId);
osRouterService.routerInterfaces(osRouter.getId()).forEach(iface -> setSourceNat(iface, exGateway.isEnableSnat()));
}
}
use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.
the class OpenstackRoutingFloatingIpHandler method processGratuitousArpPacket.
private void processGratuitousArpPacket(NetFloatingIP floatingIP, InstancePort instancePort) {
Set<OpenstackNode> gws = ImmutableSet.copyOf(osNodeService.completeNodes(GATEWAY));
Network osNet = osNetworkService.network(instancePort.networkId());
OpenstackNode selectedGw = getGwByInstancePort(gws, instancePort);
ExternalPeerRouter externalPeerRouter = externalPeerRouterForNetwork(osNet, osNetworkService, osRouterAdminService);
if (externalPeerRouter == null) {
log.error("Failed to process GARP packet for floating ip {}, because ", NO_EXT_PEER_ROUTER_MSG);
return;
}
processGarpPacketForFloatingIp(floatingIP, instancePort, externalPeerRouter.vlanId(), selectedGw, packetService);
}
use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.
the class OpenstackRoutingFloatingIpHandler method setFloatingIpRules.
private void setFloatingIpRules(NetFloatingIP floatingIp, InstancePort instPort, OpenstackNode gateway, ExternalPeerRouter peerRouter, boolean install) {
if (instPort == null) {
log.debug("No instance port found");
return;
}
Network osNet = osNetworkService.network(instPort.networkId());
ExternalPeerRouter externalPeerRouter = peerRouter != null ? peerRouter : externalPeerRouterForNetwork(osNet, osNetworkService, osRouterAdminService);
if (externalPeerRouter == null) {
log.warn("External peer router is not ready for now, " + "floating IP rules will be installed/uninstalled " + "when external peer router is available...");
return;
}
if (install) {
preCommitPortService.subscribePreCommit(instPort.portId(), OPENSTACK_PORT_PRE_REMOVE, this.getClass().getName());
log.info("Subscribed the port {} on listening pre-remove event", instPort.portId());
} else {
preCommitPortService.unsubscribePreCommit(instPort.portId(), OPENSTACK_PORT_PRE_REMOVE, instancePortService, this.getClass().getName());
log.info("Unsubscribed the port {} on listening pre-remove event", instPort.portId());
}
updateComputeNodeRules(instPort, osNet, gateway, install);
updateGatewayNodeRules(floatingIp, instPort, osNet, externalPeerRouter, gateway, install);
// TODO: need to refactor setUpstreamRules if possible
setUpstreamRules(floatingIp, osNet, instPort, externalPeerRouter, install);
log.trace("Succeeded to set flow rules for floating ip {}:{} and install: {}", floatingIp.getFloatingIpAddress(), floatingIp.getFixedIpAddress(), install);
}
use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.
the class ExternalPeerRouterCodecTest method testExternalPeerRouterEncode.
/**
* Tests the external peer router encoding.
*/
@Test
public void testExternalPeerRouterEncode() {
ExternalPeerRouter router = DefaultExternalPeerRouter.builder().ipAddress(IpAddress.valueOf("10.10.10.1")).macAddress(MacAddress.valueOf("11:22:33:44:55:66")).vlanId(VlanId.vlanId("1")).build();
ObjectNode routerJson = externalPeerRouterCodec.encode(router, context);
assertThat(routerJson, matchesExternalPeerRouter(router));
}
use of org.onosproject.openstacknetworking.api.ExternalPeerRouter in project onos by opennetworkinglab.
the class DeleteExternalPeerRouterCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNetworkAdminService service = get(OpenstackNetworkAdminService.class);
if (service.externalPeerRouters().stream().noneMatch(router -> router.ipAddress().toString().equals(ipAddress))) {
print(NO_ELEMENT);
return;
}
try {
service.deleteExternalPeerRouter(ipAddress);
} catch (IllegalArgumentException e) {
log.error("Exception occurred because of {}", e);
}
print(FORMAT, "Router IP", "Mac Address", "VLAN ID");
List<ExternalPeerRouter> routers = Lists.newArrayList(service.externalPeerRouters());
for (ExternalPeerRouter router : routers) {
print(FORMAT, router.ipAddress(), router.macAddress().toString(), router.vlanId());
}
}
Aggregations