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);
}
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;
}
Aggregations