Search in sources :

Example 1 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    // Delegate string completer
    StringsCompleter delegate = new StringsCompleter();
    // Fetch our service and feed it's offerings to the string completer
    VirtualNetworkAdminService service = AbstractShellCommand.get(VirtualNetworkAdminService.class);
    List<VirtualNetwork> virtualNetworks = new ArrayList<>();
    Set<TenantId> tenantSet = service.getTenantIds();
    tenantSet.forEach(tenantId -> virtualNetworks.addAll(service.getVirtualNetworks(tenantId)));
    Collections.sort(virtualNetworks, Comparators.VIRTUAL_NETWORK_COMPARATOR);
    SortedSet<String> strings = delegate.getStrings();
    virtualNetworks.forEach(virtualNetwork -> strings.add(virtualNetwork.id().toString()));
    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) ArrayList(java.util.ArrayList) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)

Example 2 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkListCommand method getSortedVirtualNetworks.

/**
 * Returns the list of virtual networks sorted using the tenant identifier.
 *
 * @return sorted virtual network list
 */
private List<VirtualNetwork> getSortedVirtualNetworks() {
    VirtualNetworkService service = get(VirtualNetworkService.class);
    VirtualNetworkAdminService adminService = get(VirtualNetworkAdminService.class);
    List<VirtualNetwork> virtualNetworks = new ArrayList<>();
    Set<TenantId> tenantSet = adminService.getTenantIds();
    tenantSet.forEach(tenantId -> virtualNetworks.addAll(service.getVirtualNetworks(tenantId)));
    Collections.sort(virtualNetworks, Comparators.VIRTUAL_NETWORK_COMPARATOR);
    return virtualNetworks;
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) ArrayList(java.util.ArrayList) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)

Example 3 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkManager method create.

/**
 * Create a new vnet service instance.
 *
 * @param serviceKey service key
 * @return vnet service
 */
private VnetService create(ServiceKey serviceKey) {
    VirtualNetwork network = getVirtualNetwork(serviceKey.networkId());
    checkNotNull(network, NETWORK_NULL);
    VnetService service;
    if (serviceKey.serviceClass.equals(DeviceService.class)) {
        service = new VirtualNetworkDeviceManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(LinkService.class)) {
        service = new VirtualNetworkLinkManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(TopologyService.class)) {
        service = new VirtualNetworkTopologyManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(IntentService.class)) {
        service = new VirtualNetworkIntentManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(HostService.class)) {
        service = new VirtualNetworkHostManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(PathService.class)) {
        service = new VirtualNetworkPathManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(FlowRuleService.class)) {
        service = new VirtualNetworkFlowRuleManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(PacketService.class)) {
        service = new VirtualNetworkPacketManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(GroupService.class)) {
        service = new VirtualNetworkGroupManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(MeterService.class)) {
        service = new VirtualNetworkMeterManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(FlowObjectiveService.class)) {
        service = new VirtualNetworkFlowObjectiveManager(this, network.id());
    } else if (serviceKey.serviceClass.equals(MastershipService.class) || serviceKey.serviceClass.equals(MastershipAdminService.class) || serviceKey.serviceClass.equals(MastershipTermService.class)) {
        service = new VirtualNetworkMastershipManager(this, network.id());
    } else {
        return null;
    }
    networkServices.put(serviceKey, service);
    return service;
}
Also used : IntentService(org.onosproject.net.intent.IntentService) PacketService(org.onosproject.net.packet.PacketService) MastershipAdminService(org.onosproject.mastership.MastershipAdminService) VnetService(org.onosproject.incubator.net.virtual.VnetService) MastershipService(org.onosproject.mastership.MastershipService) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) PathService(org.onosproject.net.topology.PathService) LinkService(org.onosproject.net.link.LinkService) MeterService(org.onosproject.net.meter.MeterService)

Example 4 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class DistributedVirtualNetworkStore method removeNetwork.

@Override
public void removeNetwork(NetworkId networkId) {
    // Make sure that the virtual network exists before attempting to remove it.
    checkState(networkExists(networkId), "The network does not exist.");
    // Remove all the devices of this network
    Set<VirtualDevice> deviceSet = getDevices(networkId);
    if (deviceSet != null) {
        deviceSet.forEach(virtualDevice -> removeDevice(networkId, virtualDevice.id()));
    }
    // TODO update both maps in one transaction.
    VirtualNetwork virtualNetwork = networkIdVirtualNetworkMap.remove(networkId);
    if (virtualNetwork == null) {
        return;
    }
    TenantId tenantId = virtualNetwork.tenantId();
    Set<NetworkId> networkIdSet = new HashSet<>();
    tenantIdNetworkIdSetMap.get(tenantId).forEach(networkId1 -> {
        if (networkId1.id().equals(networkId.id())) {
            networkIdSet.add(networkId1);
        }
    });
    tenantIdNetworkIdSetMap.compute(virtualNetwork.tenantId(), (id, existingNetworkIds) -> {
        if (existingNetworkIds == null || existingNetworkIds.isEmpty()) {
            return new HashSet<>();
        } else {
            return new HashSet<>(Sets.difference(existingNetworkIds, networkIdSet));
        }
    });
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TenantId(org.onosproject.net.TenantId) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) HashSet(java.util.HashSet)

Example 5 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class DistributedVirtualNetworkStore method addNetwork.

@Override
public VirtualNetwork addNetwork(TenantId tenantId) {
    checkState(tenantIdSet.contains(tenantId), "The tenant has not been registered. " + tenantId.id());
    VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(genNetworkId(), tenantId);
    // TODO update both maps in one transaction.
    networkIdVirtualNetworkMap.put(virtualNetwork.id(), virtualNetwork);
    Set<NetworkId> networkIdSet = tenantIdNetworkIdSetMap.get(tenantId);
    if (networkIdSet == null) {
        networkIdSet = new HashSet<>();
    }
    networkIdSet.add(virtualNetwork.id());
    tenantIdNetworkIdSetMap.put(tenantId, networkIdSet);
    return virtualNetwork;
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Aggregations

VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)98 Test (org.junit.Test)82 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)38 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)24 ConnectPoint (org.onosproject.net.ConnectPoint)24 TopologyService (org.onosproject.net.topology.TopologyService)24 Topology (org.onosproject.net.topology.Topology)23 DeviceService (org.onosproject.net.device.DeviceService)15 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 DisjointPath (org.onosproject.net.DisjointPath)11 LinkService (org.onosproject.net.link.LinkService)10 ArrayList (java.util.ArrayList)8 HostService (org.onosproject.net.host.HostService)8 TenantId (org.onosproject.net.TenantId)7 Path (org.onosproject.net.Path)6 PathService (org.onosproject.net.topology.PathService)5 TopologyCluster (org.onosproject.net.topology.TopologyCluster)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)4 Link (org.onosproject.net.Link)4