Search in sources :

Example 1 with TenantId

use of org.onosproject.net.TenantId in project onos by opennetworkinglab.

the class TenantCompleter 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);
    SortedSet<String> strings = delegate.getStrings();
    for (TenantId tenantId : service.getTenantIds()) {
        strings.add(tenantId.id());
    }
    // Now let the completer do the work for figuring out what to offer.
    return delegate.complete(session, commandLine, candidates);
}
Also used : TenantId(org.onosproject.net.TenantId) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)

Example 2 with TenantId

use of org.onosproject.net.TenantId in project onos by opennetworkinglab.

the class TenantListCommand method doExecute.

@Override
protected void doExecute() {
    VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
    List<TenantId> tenants = new ArrayList<>();
    tenants.addAll(service.getTenantIds());
    Collections.sort(tenants, Comparators.TENANT_ID_COMPARATOR);
    tenants.forEach(this::printTenant);
}
Also used : TenantId(org.onosproject.net.TenantId) ArrayList(java.util.ArrayList) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)

Example 3 with TenantId

use of org.onosproject.net.TenantId 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 4 with TenantId

use of org.onosproject.net.TenantId 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 5 with TenantId

use of org.onosproject.net.TenantId in project onos by opennetworkinglab.

the class TenantWebResource method removeTenantId.

/**
 * Removes the specified tenant with the specified tenant identifier.
 *
 * @param tenantId tenant identifier
 * @return 204 NO CONTENT
 */
@DELETE
@Path("{tenantId}")
public Response removeTenantId(@PathParam("tenantId") String tenantId) {
    final TenantId tid = TenantId.tenantId(tenantId);
    final TenantId existingTid = getExistingTenantId(vnetAdminService, tid);
    vnetAdminService.unregisterTenantId(existingTid);
    return Response.noContent().build();
}
Also used : TenantId(org.onosproject.net.TenantId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Aggregations

TenantId (org.onosproject.net.TenantId)13 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)7 VirtualNetworkAdminService (org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)4 ArrayList (java.util.ArrayList)3 Produces (javax.ws.rs.Produces)3 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 UriBuilder (javax.ws.rs.core.UriBuilder)2 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)2 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)2 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)2 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)2 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 Test (org.junit.Test)1 DefaultVirtualDevice (org.onosproject.incubator.net.virtual.DefaultVirtualDevice)1