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