mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Summary: Add vlan configuration to the network inteface definition
Add xml piece for defining vlans Set vlan tag in the libvirt definition for the network inteface
This commit is contained in:
parent
a0ade283b7
commit
3d570c7647
@ -648,6 +648,7 @@ public class LibvirtVMDef {
|
||||
private nicModel _model;
|
||||
private String _virtualPortType;
|
||||
private String _virtualPortInterfaceId;
|
||||
private int _vlanTag = -1;
|
||||
|
||||
public void defBridgeNet(String brName, String targetBrName,
|
||||
String macAddr, nicModel model) {
|
||||
@ -713,7 +714,15 @@ public class LibvirtVMDef {
|
||||
public String getVirtualPortInterfaceId() {
|
||||
return _virtualPortInterfaceId;
|
||||
}
|
||||
|
||||
|
||||
public void setVlanTag(int vlanTag) {
|
||||
_vlanTag = vlanTag;
|
||||
}
|
||||
|
||||
public int getVlanTag() {
|
||||
return _vlanTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder netBuilder = new StringBuilder();
|
||||
@ -739,6 +748,9 @@ public class LibvirtVMDef {
|
||||
}
|
||||
netBuilder.append("</virtualport>\n");
|
||||
}
|
||||
if (_vlanTag != -1) {
|
||||
netBuilder.append("<vlan trunk='no'>\n<tag id='" + _vlanTag + "'/>\n</vlan>");
|
||||
}
|
||||
netBuilder.append("</interface>\n");
|
||||
return netBuilder.toString();
|
||||
}
|
||||
|
||||
@ -84,11 +84,11 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if(trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||
s_logger.debug("creating a vlan dev and bridge for guest traffic per traffic label " + trafficLabel);
|
||||
String brName = createVlanBr(vlanId, _pifs.get(trafficLabel));
|
||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.defBridgeNet(_pifs.get(trafficLabel), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||
} else {
|
||||
String brName = createVlanBr(vlanId, _pifs.get("private"));
|
||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.defBridgeNet(_pifs.get("private"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||
}
|
||||
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
|
||||
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + logicalSwitchUuid);
|
||||
@ -108,11 +108,11 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||
if(trafficLabel != null && !trafficLabel.isEmpty()){
|
||||
s_logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);
|
||||
String brName = createVlanBr(vlanId, _pifs.get(trafficLabel));
|
||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.defBridgeNet(_pifs.get(trafficLabel), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||
} else {
|
||||
String brName = createVlanBr(vlanId, _pifs.get("public"));
|
||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.defBridgeNet(_pifs.get("public"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||
}
|
||||
} else {
|
||||
intf.defBridgeNet(_bridges.get("public"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||
@ -143,28 +143,6 @@ public class OvsVifDriver extends VifDriverBase {
|
||||
|
||||
return brName;
|
||||
}
|
||||
|
||||
private String createVlanBr(String vlanId, String nic)
|
||||
throws InternalErrorException {
|
||||
String brName = setVnetBrName(nic, vlanId);
|
||||
createVnet(vlanId, nic, brName);
|
||||
return brName;
|
||||
}
|
||||
|
||||
private void createVnet(String vnetId, String pif, String brName)
|
||||
throws InternalErrorException {
|
||||
final Script command = new Script(_modifyVlanPath, _timeout, s_logger);
|
||||
command.add("-v", vnetId);
|
||||
command.add("-p", pif);
|
||||
command.add("-b", brName);
|
||||
command.add("-o", "add");
|
||||
|
||||
final String result = command.execute();
|
||||
if (result != null) {
|
||||
throw new InternalErrorException("Failed to create vnet " + vnetId
|
||||
+ ": " + result);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteExitingLinkLocalRoutTable(String linkLocalBr) {
|
||||
Script command = new Script("/bin/bash", _timeout);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user