Search in sources :

Example 1 with VirtualNetworkAdminService

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

the class VirtualNetworkCreateCommand method doExecute.

@Override
protected void doExecute() {
    VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
    service.createVirtualNetwork(TenantId.tenantId(id));
    print("Virtual network successfully created.");
}
Also used : VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)

Example 2 with VirtualNetworkAdminService

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

the class VirtualHostCreateCommand method doExecute.

@Override
protected void doExecute() {
    VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
    Set<IpAddress> hostIps = new HashSet<>();
    if (hostIpStrings != null) {
        Arrays.stream(hostIpStrings).forEach(s -> hostIps.add(IpAddress.valueOf(s)));
    }
    HostLocation hostLocation = new HostLocation(DeviceId.deviceId(hostLocationDeviceId), PortNumber.portNumber(hostLocationPortNumber), System.currentTimeMillis());
    MacAddress macAddress = MacAddress.valueOf(mac);
    VlanId vlanId = VlanId.vlanId(vlan);
    service.createVirtualHost(NetworkId.networkId(networkId), HostId.hostId(macAddress, vlanId), macAddress, vlanId, hostLocation, hostIps);
    print("Virtual host successfully created.");
}
Also used : HostLocation(org.onosproject.net.HostLocation) IpAddress(org.onlab.packet.IpAddress) MacAddress(org.onlab.packet.MacAddress) VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService) VlanId(org.onlab.packet.VlanId) HashSet(java.util.HashSet)

Example 3 with VirtualNetworkAdminService

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

the class VirtualLinkRemoveCommand method doExecute.

@Override
protected void doExecute() {
    VirtualNetworkAdminService service = get(VirtualNetworkAdminService.class);
    ConnectPoint src = new ConnectPoint(DeviceId.deviceId(srcDeviceId), PortNumber.portNumber(srcPortNum));
    ConnectPoint dst = new ConnectPoint(DeviceId.deviceId(dstDeviceId), PortNumber.portNumber(dstPortNum));
    service.removeVirtualLink(NetworkId.networkId(networkId), src, dst);
    if (bidirectional) {
        service.removeVirtualLink(NetworkId.networkId(networkId), dst, src);
    }
    print("Virtual link successfully removed.");
}
Also used : VirtualNetworkAdminService(org.onosproject.incubator.net.virtual.VirtualNetworkAdminService) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 4 with VirtualNetworkAdminService

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

use of org.onosproject.incubator.net.virtual.VirtualNetworkAdminService 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)

Aggregations

VirtualNetworkAdminService (org.onosproject.incubator.net.virtual.VirtualNetworkAdminService)18 ConnectPoint (org.onosproject.net.ConnectPoint)4 TenantId (org.onosproject.net.TenantId)4 ArrayList (java.util.ArrayList)3 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)2 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)2 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)2 DeviceService (org.onosproject.net.device.DeviceService)2 HashSet (java.util.HashSet)1 IpAddress (org.onlab.packet.IpAddress)1 MacAddress (org.onlab.packet.MacAddress)1 VlanId (org.onlab.packet.VlanId)1 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)1 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)1 HostLocation (org.onosproject.net.HostLocation)1