@Override public void removeVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(src, LINK_POINT_NULL); checkNotNull(dst, LINK_POINT_NULL); store.removeLink(networkId, src, dst); }
@Override public void removeVirtualPort(NetworkId networkId, DeviceId deviceId, PortNumber portNumber) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(deviceId, DEVICE_NULL); checkNotNull(portNumber, "Port number cannot be null"); store.removePort(networkId, deviceId, portNumber); }
@Deactivate public void deactivate() { store.unsetDelegate(delegate); eventDispatcher.removeSink(VirtualNetworkEvent.class); intentService.removeListener(intentListener); log.info("Stopped"); }
@Activate public void activate() { store.setDelegate(delegate); eventDispatcher.addSink(VirtualNetworkEvent.class, listenerRegistry); intentService.addListener(intentListener); log.info("Started"); }
@Override public VirtualPort createVirtualPort( NetworkId networkId, DeviceId deviceId, PortNumber portNumber, Port realizedBy) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(deviceId, DEVICE_NULL); checkNotNull(portNumber, "Port description cannot be null"); return store.addPort(networkId, deviceId, portNumber, realizedBy); }
/** * Maps the virtual connect point to a physical connect point. * * @param networkId network identifier * @param virtualCp virtual connect point * @return physical connect point */ private ConnectPoint mapVirtualToPhysicalPort(NetworkId networkId, ConnectPoint virtualCp) { Set<VirtualPort> ports = store.getPorts(networkId, virtualCp.deviceId()); for (VirtualPort port : ports) { if (port.number().equals(virtualCp.port())) { return new ConnectPoint(port.realizedBy().element().id(), port.realizedBy().number()); } } return null; }
@Override public VirtualHost createVirtualHost( NetworkId networkId, HostId hostId, MacAddress mac, VlanId vlan, HostLocation location, Set<IpAddress> ips) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(hostId, DEVICE_NULL); return store.addHost(networkId, hostId, mac, vlan, location, ips); }
@Override public VirtualLink createVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(src, LINK_POINT_NULL); checkNotNull(dst, LINK_POINT_NULL); ConnectPoint physicalSrc = mapVirtualToPhysicalPort(networkId, src); checkNotNull(physicalSrc, LINK_POINT_NULL); ConnectPoint physicalDst = mapVirtualToPhysicalPort(networkId, dst); checkNotNull(physicalDst, LINK_POINT_NULL); VirtualNetworkProvider provider = getProvider(DefaultVirtualLink.PID); Link.State state = Link.State.INACTIVE; if (provider != null) { boolean traversable = provider.isTraversable(physicalSrc, physicalDst); state = traversable ? Link.State.ACTIVE : Link.State.INACTIVE; } return store.addLink(networkId, src, dst, state, null); }
/** * Returns the virtual network matching the network identifier. * * @param networkId network identifier * @return virtual network */ private VirtualNetwork getVirtualNetwork(NetworkId networkId) { checkNotNull(networkId, NETWORK_NULL); return store.getNetwork(networkId); }
@Override public Set<VirtualNetwork> getVirtualNetworks(TenantId tenantId) { checkNotNull(tenantId, TENANT_NULL); return store.getNetworks(tenantId); }
@Override public void unregisterTenantId(TenantId tenantId) { checkNotNull(tenantId, TENANT_NULL); store.removeTenantId(tenantId); }
@Override public Set<TenantId> getTenantIds() { return store.getTenantIds(); }
@Override public VirtualNetwork createVirtualNetwork(TenantId tenantId) { checkNotNull(tenantId, TENANT_NULL); return store.addNetwork(tenantId); }
@Override public void removeVirtualNetwork(NetworkId networkId) { checkNotNull(networkId, NETWORK_NULL); store.removeNetwork(networkId); }
@Override public VirtualDevice createVirtualDevice(NetworkId networkId, DeviceId deviceId) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(deviceId, DEVICE_NULL); return store.addDevice(networkId, deviceId); }
@Override public Set<VirtualLink> getVirtualLinks(NetworkId networkId) { checkNotNull(networkId, NETWORK_NULL); return store.getLinks(networkId); }
@Override public void removeVirtualDevice(NetworkId networkId, DeviceId deviceId) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(deviceId, DEVICE_NULL); store.removeDevice(networkId, deviceId); }
@Override public Set<VirtualPort> getVirtualPorts(NetworkId networkId, DeviceId deviceId) { checkNotNull(networkId, NETWORK_NULL); return store.getPorts(networkId, deviceId); }
@Override public void removeVirtualHost(NetworkId networkId, HostId hostId) { checkNotNull(networkId, NETWORK_NULL); checkNotNull(hostId, DEVICE_NULL); store.removeHost(networkId, hostId); }