use of org.onosproject.incubator.net.virtual.DefaultVirtualNetwork in project onos by opennetworkinglab.
the class DistributedVirtualNetworkStore method addNetwork.
@Override
public VirtualNetwork addNetwork(TenantId tenantId) {
checkState(tenantIdSet.contains(tenantId), "The tenant has not been registered. " + tenantId.id());
VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(genNetworkId(), tenantId);
// TODO update both maps in one transaction.
networkIdVirtualNetworkMap.put(virtualNetwork.id(), virtualNetwork);
Set<NetworkId> networkIdSet = tenantIdNetworkIdSetMap.get(tenantId);
if (networkIdSet == null) {
networkIdSet = new HashSet<>();
}
networkIdSet.add(virtualNetwork.id());
tenantIdNetworkIdSetMap.put(tenantId, networkIdSet);
return virtualNetwork;
}
use of org.onosproject.incubator.net.virtual.DefaultVirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkManagerTest method testCreateVirtualDeviceWithNoNetwork.
/**
* Tests adding a virtual device where no virtual network exists.
*/
@Test(expected = IllegalStateException.class)
public void testCreateVirtualDeviceWithNoNetwork() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(NetworkId.NONE, TenantId.tenantId(tenantIdValue1));
manager.createVirtualDevice(virtualNetwork.id(), DID1);
}
use of org.onosproject.incubator.net.virtual.DefaultVirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkCodec method decode.
@Override
public VirtualNetwork decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
TenantId tId = TenantId.tenantId(extractMember(TENANT_ID, json));
return new DefaultVirtualNetwork(nId, tId);
}
use of org.onosproject.incubator.net.virtual.DefaultVirtualNetwork in project onos by opennetworkinglab.
the class VirtualNetworkManagerTest method testCreateVirtualHostWithNoNetwork.
/**
* Tests adding a virtual host where no virtual network exists.
*/
@Test(expected = IllegalStateException.class)
public void testCreateVirtualHostWithNoNetwork() {
manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(NetworkId.NONE, TenantId.tenantId(tenantIdValue1));
manager.createVirtualHost(virtualNetwork.id(), HID1, null, null, null, null);
}
Aggregations