Search in sources :

Example 1 with DefaultVirtualDevice

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

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

the class DistributedVirtualNetworkStore method addDevice.

@Override
public VirtualDevice addDevice(NetworkId networkId, DeviceId deviceId) {
    checkState(networkExists(networkId), "The network has not been added.");
    Set<DeviceId> deviceIdSet = networkIdDeviceIdSetMap.get(networkId);
    if (deviceIdSet == null) {
        deviceIdSet = new HashSet<>();
    }
    checkState(!deviceIdSet.contains(deviceId), "The device already exists.");
    VirtualDevice virtualDevice = new DefaultVirtualDevice(networkId, deviceId);
    // TODO update both maps in one transaction.
    deviceIdVirtualDeviceMap.put(new VirtualDeviceId(networkId, deviceId), virtualDevice);
    deviceIdSet.add(deviceId);
    networkIdDeviceIdSetMap.put(networkId, deviceIdSet);
    return virtualDevice;
}
Also used : DeviceId(org.onosproject.net.DeviceId) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) DefaultVirtualDevice(org.onosproject.incubator.net.virtual.DefaultVirtualDevice) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice)

Aggregations

DefaultVirtualDevice (org.onosproject.incubator.net.virtual.DefaultVirtualDevice)2 DeviceId (org.onosproject.net.DeviceId)2 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)1 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)1