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 nicModel _model;
|
||||||
private String _virtualPortType;
|
private String _virtualPortType;
|
||||||
private String _virtualPortInterfaceId;
|
private String _virtualPortInterfaceId;
|
||||||
|
private int _vlanTag = -1;
|
||||||
|
|
||||||
public void defBridgeNet(String brName, String targetBrName,
|
public void defBridgeNet(String brName, String targetBrName,
|
||||||
String macAddr, nicModel model) {
|
String macAddr, nicModel model) {
|
||||||
@ -714,6 +715,14 @@ public class LibvirtVMDef {
|
|||||||
return _virtualPortInterfaceId;
|
return _virtualPortInterfaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setVlanTag(int vlanTag) {
|
||||||
|
_vlanTag = vlanTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getVlanTag() {
|
||||||
|
return _vlanTag;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder netBuilder = new StringBuilder();
|
StringBuilder netBuilder = new StringBuilder();
|
||||||
@ -739,6 +748,9 @@ public class LibvirtVMDef {
|
|||||||
}
|
}
|
||||||
netBuilder.append("</virtualport>\n");
|
netBuilder.append("</virtualport>\n");
|
||||||
}
|
}
|
||||||
|
if (_vlanTag != -1) {
|
||||||
|
netBuilder.append("<vlan trunk='no'>\n<tag id='" + _vlanTag + "'/>\n</vlan>");
|
||||||
|
}
|
||||||
netBuilder.append("</interface>\n");
|
netBuilder.append("</interface>\n");
|
||||||
return netBuilder.toString();
|
return netBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,11 +84,11 @@ public class OvsVifDriver extends VifDriverBase {
|
|||||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||||
if(trafficLabel != null && !trafficLabel.isEmpty()) {
|
if(trafficLabel != null && !trafficLabel.isEmpty()) {
|
||||||
s_logger.debug("creating a vlan dev and bridge for guest traffic per traffic label " + trafficLabel);
|
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(_pifs.get(trafficLabel), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||||
} else {
|
} else {
|
||||||
String brName = createVlanBr(vlanId, _pifs.get("private"));
|
intf.defBridgeNet(_pifs.get("private"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||||
}
|
}
|
||||||
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
|
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
|
||||||
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + logicalSwitchUuid);
|
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + logicalSwitchUuid);
|
||||||
@ -108,11 +108,11 @@ public class OvsVifDriver extends VifDriverBase {
|
|||||||
&& !vlanId.equalsIgnoreCase("untagged")) {
|
&& !vlanId.equalsIgnoreCase("untagged")) {
|
||||||
if(trafficLabel != null && !trafficLabel.isEmpty()){
|
if(trafficLabel != null && !trafficLabel.isEmpty()){
|
||||||
s_logger.debug("creating a vlan dev and bridge for public traffic per traffic label " + trafficLabel);
|
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(_pifs.get(trafficLabel), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||||
} else {
|
} else {
|
||||||
String brName = createVlanBr(vlanId, _pifs.get("public"));
|
intf.defBridgeNet(_pifs.get("public"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
|
intf.setVlanTag(Integer.parseInt(vlanId));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
intf.defBridgeNet(_bridges.get("public"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
intf.defBridgeNet(_bridges.get("public"), null, nic.getMac(), getGuestNicModel(guestOsType));
|
||||||
@ -144,28 +144,6 @@ public class OvsVifDriver extends VifDriverBase {
|
|||||||
return brName;
|
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) {
|
private void deleteExitingLinkLocalRoutTable(String linkLocalBr) {
|
||||||
Script command = new Script("/bin/bash", _timeout);
|
Script command = new Script("/bin/bash", _timeout);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user