Search in sources :

Example 1 with NetworkId

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

the class OFSwitchListCommand method doExecute.

@Override
protected void doExecute() {
    OFSwitchService service = get(OFSwitchService.class);
    Set<OFSwitch> ofSwitches;
    if (networkId != NetworkId.NONE.id()) {
        ofSwitches = service.ofSwitches(NetworkId.networkId(networkId));
    } else {
        ofSwitches = service.ofSwitches();
    }
    print(FORMAT, "DPID", "Connected controllers");
    ofSwitches.forEach(ofSwitch -> {
        Set<String> channels = ofSwitch.controllerChannels().stream().map(channel -> channel.remoteAddress().toString()).collect(Collectors.toSet());
        print(FORMAT, ofSwitch.dpid(), channels);
    });
}
Also used : AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) Service(org.apache.karaf.shell.api.action.lifecycle.Service) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) OFSwitchService(org.onosproject.ofagent.api.OFSwitchService) Set(java.util.Set) Argument(org.apache.karaf.shell.api.action.Argument) OFSwitch(org.onosproject.ofagent.api.OFSwitch) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) OFSwitchService(org.onosproject.ofagent.api.OFSwitchService) OFSwitch(org.onosproject.ofagent.api.OFSwitch)

Example 2 with NetworkId

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

the class VirtualDeviceCodec method decode.

@Override
public VirtualDevice decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    DeviceId dId = DeviceId.deviceId(extractMember(ID, json));
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    return new DefaultVirtualDevice(nId, dId);
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Example 3 with NetworkId

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

the class VirtualLinkCodec method decode.

@Override
public VirtualLink decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    JsonCodec<Link> codec = context.codec(Link.class);
    Link link = codec.decode(json, context);
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    return DefaultVirtualLink.builder().networkId(nId).src(link.src()).dst(link.dst()).build();
}
Also used : NetworkId(org.onosproject.incubator.net.virtual.NetworkId) DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Link(org.onosproject.net.Link)

Example 4 with NetworkId

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

the class VirtualPortCodec method decode.

@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
    VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
    Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
    VirtualDevice vDev = vDevs.stream().filter(virtualDevice -> virtualDevice.id().equals(dId)).findFirst().orElse(null);
    nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
    PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
    DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
    PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
    ConnectPoint realizedBy = new ConnectPoint(physDId, physPortNum);
    return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
Also used : DeviceId(org.onosproject.net.DeviceId) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) NetworkId(org.onosproject.incubator.net.virtual.NetworkId) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultVirtualPort(org.onosproject.incubator.net.virtual.DefaultVirtualPort)

Example 5 with NetworkId

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

the class VirtualListenerRegistryManager method process.

@Override
public void process(VirtualEvent event) {
    NetworkId networkId = event.networkId();
    Event originalEvent = (Event) event.subject();
    ListenerRegistry listenerRegistry = listenerMapByNetwork.get(networkId).get(originalEvent.getClass());
    if (listenerRegistry != null) {
        listenerRegistry.process(originalEvent);
        lastStart = listenerRegistry;
    }
}
Also used : ListenerRegistry(org.onosproject.event.ListenerRegistry) Event(org.onosproject.event.Event) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Aggregations

NetworkId (org.onosproject.incubator.net.virtual.NetworkId)50 DeviceId (org.onosproject.net.DeviceId)23 Test (org.junit.Test)21 WebTarget (javax.ws.rs.client.WebTarget)20 Matchers.containsString (org.hamcrest.Matchers.containsString)20 HostResourceTest (org.onosproject.rest.resources.HostResourceTest)20 LinksResourceTest (org.onosproject.rest.resources.LinksResourceTest)20 ResourceTest (org.onosproject.rest.resources.ResourceTest)20 Activate (org.osgi.service.component.annotations.Activate)11 Logger (org.slf4j.Logger)11 LoggerFactory.getLogger (org.slf4j.LoggerFactory.getLogger)11 Set (java.util.Set)10 Component (org.osgi.service.component.annotations.Component)10 Deactivate (org.osgi.service.component.annotations.Deactivate)10 HashSet (java.util.HashSet)9 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)9 ConnectPoint (org.onosproject.net.ConnectPoint)9 PortNumber (org.onosproject.net.PortNumber)9 Reference (org.osgi.service.component.annotations.Reference)9 ReferenceCardinality (org.osgi.service.component.annotations.ReferenceCardinality)9