Search in sources :

Example 6 with BroadcastDomainType

use of com.cloud.model.enumeration.BroadcastDomainType in project cosmic by MissionCriticalCloud.

the class NetworksTest method vlanValueTest.

@Test
public void vlanValueTest() throws URISyntaxException {
    final String uri1 = "vlan://1";
    final String uri2 = "1";
    final String vtag = BroadcastDomainType.Vlan.getValueFrom(BroadcastDomainType.fromString(uri1));
    Assert.assertEquals("vtag should be \"1\"", "1", vtag);
    final BroadcastDomainType tiep1 = BroadcastDomainType.getTypeOf(uri1);
    Assert.assertEquals("the type of uri1 should be 'Vlan'", BroadcastDomainType.Vlan, tiep1);
    final BroadcastDomainType tiep2 = BroadcastDomainType.getTypeOf(uri2);
    Assert.assertEquals("the type of uri1 should be 'Undecided'", BroadcastDomainType.UnDecided, tiep2);
    final BroadcastDomainType tiep3 = BroadcastDomainType.getTypeOf(Vlan.UNTAGGED);
    Assert.assertEquals("the type of uri1 should be 'vlan'", BroadcastDomainType.Native, tiep3);
}
Also used : BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) Test(org.junit.Test)

Example 7 with BroadcastDomainType

use of com.cloud.model.enumeration.BroadcastDomainType in project cosmic by MissionCriticalCloud.

the class NetworksTest method otherTypesTest.

@Test
public void otherTypesTest() throws URISyntaxException {
    final String bogeyUri = "lswitch://0";
    final String uri1 = "lswitch:1";
    final String uri2 = "mido://2";
    BroadcastDomainType type = BroadcastDomainType.getTypeOf(bogeyUri);
    String id = BroadcastDomainType.getValue(bogeyUri);
    Assert.assertEquals("uri0 should be of broadcasttype vlan", BroadcastDomainType.Lswitch, type);
    Assert.assertEquals("id0 should be \"//0\"", "//0", id);
    type = BroadcastDomainType.getTypeOf(uri1);
    id = BroadcastDomainType.getValue(uri1);
    Assert.assertEquals("uri1 should be of broadcasttype vlan", BroadcastDomainType.Lswitch, type);
    Assert.assertEquals("id1 should be \"1\"", "1", id);
    type = BroadcastDomainType.getTypeOf(uri2);
    id = BroadcastDomainType.getValue(uri2);
    Assert.assertEquals("uri2 should be of broadcasttype vlan", BroadcastDomainType.Mido, type);
    Assert.assertEquals("id2 should be \"2\"", "2", id);
}
Also used : BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) Test(org.junit.Test)

Example 8 with BroadcastDomainType

use of com.cloud.model.enumeration.BroadcastDomainType in project cosmic by MissionCriticalCloud.

the class NetworksTest method emptyBroadcastDomainTypeTest.

@Test
public void emptyBroadcastDomainTypeTest() throws URISyntaxException {
    final BroadcastDomainType type = BroadcastDomainType.getTypeOf("");
    Assert.assertEquals("an empty uri should mean a broadcasttype of undecided", BroadcastDomainType.UnDecided, type);
}
Also used : BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) Test(org.junit.Test)

Example 9 with BroadcastDomainType

use of com.cloud.model.enumeration.BroadcastDomainType in project cosmic by MissionCriticalCloud.

the class NetworksTest method invalidTypesTest.

@Test
public void invalidTypesTest() throws URISyntaxException {
    final String uri1 = "https://1";
    final String uri2 = "bla:0";
    final BroadcastDomainType type = BroadcastDomainType.getTypeOf(uri1);
    try {
        /* URI result = */
        BroadcastDomainType.fromString(uri1);
    } catch (final CloudRuntimeException e) {
        Assert.assertEquals("unexpected parameter exception", "string 'https://1' has an unknown BroadcastDomainType.", e.getMessage());
    }
    try {
        /* URI result = */
        BroadcastDomainType.fromString(uri2);
    } catch (final CloudRuntimeException e) {
        Assert.assertEquals("unexpected parameter exception", "string 'bla:0' has an unknown BroadcastDomainType.", e.getMessage());
    }
}
Also used : BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) Test(org.junit.Test)

Example 10 with BroadcastDomainType

use of com.cloud.model.enumeration.BroadcastDomainType in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method getNetwork.

public Network getNetwork(final Connection conn, final NicTO nic) throws XenAPIException, XmlRpcException {
    final String name = nic.getName();
    final XsLocalNetwork network = getNativeNetworkForTraffic(conn, nic.getType(), name);
    if (network == null) {
        s_logger.error("Network is not configured on the backend for nic " + nic.toString());
        throw new CloudRuntimeException("Network for the backend is not configured correctly for network broadcast domain: " + nic.getBroadcastUri());
    }
    final URI uri = nic.getBroadcastUri();
    final BroadcastDomainType type = nic.getBroadcastType();
    if (uri != null && uri.toString().contains("untagged")) {
        return network.getNetwork();
    } else if (uri != null && type == BroadcastDomainType.Vlan) {
        assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Vlan;
        final long vlan = Long.parseLong(BroadcastDomainType.getValue(uri));
        return enableVlanNetwork(conn, vlan, network);
    } else if (type == BroadcastDomainType.Native || type == BroadcastDomainType.LinkLocal || type == BroadcastDomainType.Vsp) {
        return network.getNetwork();
    } else if (type == BroadcastDomainType.Storage) {
        if (uri == null) {
            return network.getNetwork();
        } else {
            final long vlan = Long.parseLong(BroadcastDomainType.getValue(uri));
            return enableVlanNetwork(conn, vlan, network);
        }
    } else if (type == BroadcastDomainType.Lswitch) {
        // Nicira Logical Switch
        return network.getNetwork();
    } else if (uri != null && type == BroadcastDomainType.Pvlan) {
        assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Pvlan;
        // should we consider moving this NetUtils method to
        // BroadcastDomainType?
        final long vlan = Long.parseLong(NetUtils.getPrimaryPvlanFromUri(uri));
        return enableVlanNetwork(conn, vlan, network);
    }
    throw new CloudRuntimeException("Unable to support this type of network broadcast domain: " + nic.getBroadcastUri());
}
Also used : BroadcastDomainType(com.cloud.model.enumeration.BroadcastDomainType) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) URI(java.net.URI)

Aggregations

BroadcastDomainType (com.cloud.model.enumeration.BroadcastDomainType)11 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)5 Test (org.junit.Test)5 DataCenterVO (com.cloud.dc.DataCenterVO)3 Account (com.cloud.legacymodel.user.Account)3 NetworkVO (com.cloud.network.dao.NetworkVO)3 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)3 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 URI (java.net.URI)2 DataCenterDeployment (com.cloud.deploy.DataCenterDeployment)1 HostVO (com.cloud.host.HostVO)1 CreateLogicalRouterAnswer (com.cloud.legacymodel.communication.answer.CreateLogicalRouterAnswer)1 CreateLogicalRouterCommand (com.cloud.legacymodel.communication.command.CreateLogicalRouterCommand)1 DataCenter (com.cloud.legacymodel.dc.DataCenter)1 ConcurrentOperationException (com.cloud.legacymodel.exceptions.ConcurrentOperationException)1 InsufficientAddressCapacityException (com.cloud.legacymodel.exceptions.InsufficientAddressCapacityException)1 InsufficientCapacityException (com.cloud.legacymodel.exceptions.InsufficientCapacityException)1 PermissionDeniedException (com.cloud.legacymodel.exceptions.PermissionDeniedException)1 ResourceAllocationException (com.cloud.legacymodel.exceptions.ResourceAllocationException)1