use of com.cloud.network.Networks.BroadcastDomainType in project cloudstack by apache.
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 (uri != null && type == BroadcastDomainType.Vswitch) {
final String header = uri.toString().substring(Networks.BroadcastDomainType.Vswitch.scheme().length() + "://".length());
if (header.startsWith("vlan")) {
_isOvs = true;
return setupvSwitchNetwork(conn);
} else {
return findOrCreateTunnelNetwork(conn, getOvsTunnelNetworkName(uri.getAuthority()));
}
} 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());
}
use of com.cloud.network.Networks.BroadcastDomainType in project cloudstack by apache.
the class NetworksTest method otherTypesTest.
@Test
public void otherTypesTest() throws URISyntaxException {
String bogeyUri = "lswitch://0";
String uri1 = "lswitch:1";
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.network.Networks.BroadcastDomainType in project cloudstack by apache.
the class NetworksTest method vlanValueTest.
@Test
public void vlanValueTest() throws URISyntaxException {
String uri1 = "vlan://1";
String uri2 = "1";
String vtag = BroadcastDomainType.Vlan.getValueFrom(BroadcastDomainType.fromString(uri1));
Assert.assertEquals("vtag should be \"1\"", "1", vtag);
BroadcastDomainType tiep1 = BroadcastDomainType.getTypeOf(uri1);
Assert.assertEquals("the type of uri1 should be 'Vlan'", BroadcastDomainType.Vlan, tiep1);
BroadcastDomainType tiep2 = BroadcastDomainType.getTypeOf(uri2);
Assert.assertEquals("the type of uri1 should be 'Undecided'", BroadcastDomainType.UnDecided, tiep2);
BroadcastDomainType tiep3 = BroadcastDomainType.getTypeOf(Vlan.UNTAGGED);
Assert.assertEquals("the type of uri1 should be 'vlan'", BroadcastDomainType.Native, tiep3);
}
Aggregations