Search in sources :

Example 1 with DefaultVirtualNetwork

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;
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Example 2 with DefaultVirtualNetwork

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);
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) Test(org.junit.Test)

Example 3 with DefaultVirtualNetwork

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);
}
Also used : TenantId(org.onosproject.net.TenantId) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) NetworkId(org.onosproject.incubator.net.virtual.NetworkId)

Example 4 with DefaultVirtualNetwork

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);
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) Test(org.junit.Test)

Aggregations

DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)4 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)3 Test (org.junit.Test)2 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)2 TenantId (org.onosproject.net.TenantId)1