Skip to content

Commit 2d69a18

Browse files
committed
Summary: Begone pesky tabs
1 parent f09d453 commit 2d69a18

6 files changed

Lines changed: 137 additions & 138 deletions

File tree

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType)
8686
vlanId = broadcastUri.getHost();
8787
}
8888
else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
89-
throw new InternalErrorException("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver");
89+
throw new InternalErrorException("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver");
9090
}
9191
String trafficLabel = nic.getName();
9292
if (nic.getType() == Networks.TrafficType.Guest) {

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ protected String getDefaultScriptsDir() {
364364
private int _dom0MinMem;
365365

366366
protected enum BridgeType {
367-
NATIVE, OPENVSWITCH
367+
NATIVE, OPENVSWITCH
368368
}
369369

370370
protected enum defineOps {
@@ -483,10 +483,10 @@ public boolean configure(String name, Map<String, Object> params)
483483

484484
String bridgeType = (String) params.get("network.bridge.type");
485485
if (bridgeType == null) {
486-
_bridgeType = BridgeType.NATIVE;
486+
_bridgeType = BridgeType.NATIVE;
487487
}
488488
else {
489-
_bridgeType = BridgeType.valueOf(bridgeType.toUpperCase());
489+
_bridgeType = BridgeType.valueOf(bridgeType.toUpperCase());
490490
}
491491

492492
params.put("domr.scripts.dir", domrScriptsDir);
@@ -664,19 +664,18 @@ public boolean configure(String name, Map<String, Object> params)
664664

665665
LibvirtConnection.initialize(_hypervisorURI);
666666
Connect conn = null;
667-
try {
668-
conn = LibvirtConnection.getConnection();
669-
670-
if (_bridgeType == BridgeType.OPENVSWITCH) {
671-
if (conn.getLibVirVersion() < (9 * 1000 + 11)) {
672-
throw new ConfigurationException(
673-
"LibVirt version 0.9.11 required for openvswitch support, but version "
674-
+ conn.getLibVirVersion() + " detected");
675-
}
676-
}
677-
} catch (LibvirtException e) {
678-
throw new CloudRuntimeException(e.getMessage());
679-
}
667+
try {
668+
conn = LibvirtConnection.getConnection();
669+
670+
if (_bridgeType == BridgeType.OPENVSWITCH) {
671+
if (conn.getLibVirVersion() < (9 * 1000 + 11)) {
672+
throw new ConfigurationException("LibVirt version 0.9.11 required for openvswitch support, but version "
673+
+ conn.getLibVirVersion() + " detected");
674+
}
675+
}
676+
} catch (LibvirtException e) {
677+
throw new CloudRuntimeException(e.getMessage());
678+
}
680679

681680
/* Does node support HVM guest? If not, exit */
682681
if (!IsHVMEnabled(conn)) {
@@ -720,14 +719,15 @@ public boolean configure(String name, Map<String, Object> params)
720719
}
721720

722721
switch (_bridgeType) {
723-
case NATIVE:
724-
getPifs();
725-
break;
726722
case OPENVSWITCH:
727-
getOvsPifs();
728-
break;
723+
getOvsPifs();
724+
break;
725+
case NATIVE:
726+
default:
727+
getPifs();
728+
break;
729729
}
730-
730+
731731
if (_pifs.get("private") == null) {
732732
s_logger.debug("Failed to get private nic name");
733733
throw new ConfigurationException("Failed to get private nic name");
@@ -786,31 +786,29 @@ public boolean configure(String name, Map<String, Object> params)
786786
// Load the vif driver
787787
String vifDriverName = (String) params.get("libvirt.vif.driver");
788788
if (vifDriverName == null) {
789-
if (_bridgeType == BridgeType.OPENVSWITCH) {
790-
s_logger.info("No libvirt.vif.driver specififed. Defaults to OvsVifDriver.");
791-
vifDriverName = "com.cloud.hypervisor.kvm.resource.OvsVifDriver";
792-
}
793-
else {
794-
s_logger.info("No libvirt.vif.driver specififed. Defaults to BridgeVifDriver.");
795-
vifDriverName = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver";
796-
}
789+
if (_bridgeType == BridgeType.OPENVSWITCH) {
790+
s_logger.info("No libvirt.vif.driver specififed. Defaults to OvsVifDriver.");
791+
vifDriverName = "com.cloud.hypervisor.kvm.resource.OvsVifDriver";
792+
} else {
793+
s_logger.info("No libvirt.vif.driver specififed. Defaults to BridgeVifDriver.");
794+
vifDriverName = "com.cloud.hypervisor.kvm.resource.BridgeVifDriver";
795+
}
797796
}
798797

799798
params.put("libvirt.computing.resource", (Object) this);
800799

801800
try {
802-
Class<?> clazz = Class.forName(vifDriverName);
803-
_vifDriver = (VifDriver) clazz.newInstance();
804-
_vifDriver.configure(params);
801+
Class<?> clazz = Class.forName(vifDriverName);
802+
_vifDriver = (VifDriver) clazz.newInstance();
803+
_vifDriver.configure(params);
805804
} catch (ClassNotFoundException e) {
806-
throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
805+
throw new ConfigurationException("Unable to find class for libvirt.vif.driver " + e);
807806
} catch (InstantiationException e) {
808-
throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
807+
throw new ConfigurationException("Unable to instantiate class for libvirt.vif.driver " + e);
809808
} catch (Exception e) {
810-
throw new ConfigurationException("Failed to initialize libvirt.vif.driver " + e);
809+
throw new ConfigurationException("Failed to initialize libvirt.vif.driver " + e);
811810
}
812811

813-
814812
return true;
815813
}
816814

@@ -834,23 +832,24 @@ private void getPifs() {
834832
}
835833

836834
private void getOvsPifs() {
837-
String cmdout = Script.runSimpleBashScript("ovs-vsctl list-br | sed '{:q;N;s/\\n/%/g;t q}'");
835+
String cmdout = Script.runSimpleBashScript("ovs-vsctl list-br | sed '{:q;N;s/\\n/%/g;t q}'");
838836
s_logger.debug("cmdout was " + cmdout);
839837
List<String> bridges = Arrays.asList(cmdout.split("%"));
840838
for (String bridge : bridges) {
841839
s_logger.debug("looking for pif for bridge " + bridge);
842-
//String pif = getOvsPif(bridge);
843-
// Not really interested in the pif name at this point for ovs bridges
840+
// String pif = getOvsPif(bridge);
841+
// Not really interested in the pif name at this point for ovs
842+
// bridges
844843
String pif = bridge;
845-
if(_publicBridgeName != null && bridge.equals(_publicBridgeName)){
844+
if (_publicBridgeName != null && bridge.equals(_publicBridgeName)) {
846845
_pifs.put("public", pif);
847846
}
848847
if (_guestBridgeName != null && bridge.equals(_guestBridgeName)) {
849848
_pifs.put("private", pif);
850849
}
851850
_pifs.put(bridge, pif);
852851
}
853-
s_logger.debug("done looking for pifs, no more bridges");
852+
s_logger.debug("done looking for pifs, no more bridges");
854853
}
855854

856855
private String getPif(String bridge) {
@@ -875,10 +874,10 @@ private boolean checkNetwork(String networkName) {
875874
}
876875

877876
if (_bridgeType == BridgeType.OPENVSWITCH) {
878-
return checkOvsNetwork(networkName);
877+
return checkOvsNetwork(networkName);
879878
}
880879
else {
881-
return checkBridgeNetwork(networkName);
880+
return checkBridgeNetwork(networkName);
882881
}
883882
}
884883

@@ -897,11 +896,11 @@ private boolean checkBridgeNetwork(String networkName) {
897896
}
898897

899898
private boolean checkOvsNetwork(String networkName) {
900-
s_logger.debug("Checking if network " + networkName + " exists as openvswitch bridge");
901-
if (networkName == null) {
902-
return true;
903-
}
904-
899+
s_logger.debug("Checking if network " + networkName + " exists as openvswitch bridge");
900+
if (networkName == null) {
901+
return true;
902+
}
903+
905904
Script command = new Script("/bin/sh", _timeout);
906905
command.add("-c");
907906
command.add("ovs-vsctl br-exists " + networkName);

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -700,27 +700,27 @@ public String getMacAddress() {
700700
}
701701

702702
public void setVirtualPortType(String virtualPortType) {
703-
_virtualPortType = virtualPortType;
703+
_virtualPortType = virtualPortType;
704704
}
705-
705+
706706
public String getVirtualPortType() {
707-
return _virtualPortType;
707+
return _virtualPortType;
708708
}
709-
709+
710710
public void setVirtualPortInterfaceId(String virtualPortInterfaceId) {
711-
_virtualPortInterfaceId = virtualPortInterfaceId;
711+
_virtualPortInterfaceId = virtualPortInterfaceId;
712712
}
713-
713+
714714
public String getVirtualPortInterfaceId() {
715-
return _virtualPortInterfaceId;
715+
return _virtualPortInterfaceId;
716716
}
717-
717+
718718
public void setVlanTag(int vlanTag) {
719-
_vlanTag = vlanTag;
719+
_vlanTag = vlanTag;
720720
}
721-
721+
722722
public int getVlanTag() {
723-
return _vlanTag;
723+
return _vlanTag;
724724
}
725725

726726
@Override
@@ -742,14 +742,14 @@ public String toString() {
742742
netBuilder.append("<model type='" + _model + "'/>\n");
743743
}
744744
if (_virtualPortType != null) {
745-
netBuilder.append("<virtualport type='" + _virtualPortType + "'>\n");
746-
if (_virtualPortInterfaceId != null) {
747-
netBuilder.append("<parameters interfaceid='" + _virtualPortInterfaceId + "'/>\n");
748-
}
749-
netBuilder.append("</virtualport>\n");
745+
netBuilder.append("<virtualport type='" + _virtualPortType + "'>\n");
746+
if (_virtualPortInterfaceId != null) {
747+
netBuilder.append("<parameters interfaceid='" + _virtualPortInterfaceId + "'/>\n");
748+
}
749+
netBuilder.append("</virtualport>\n");
750750
}
751751
if (_vlanTag != -1) {
752-
netBuilder.append("<vlan trunk='no'>\n<tag id='" + _vlanTag + "'/>\n</vlan>");
752+
netBuilder.append("<vlan trunk='no'>\n<tag id='" + _vlanTag + "'/>\n</vlan>");
753753
}
754754
netBuilder.append("</interface>\n");
755755
return netBuilder.toString();

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@
3636
import com.cloud.utils.script.Script;
3737

3838
public class OvsVifDriver extends VifDriverBase {
39-
private static final Logger s_logger = Logger
40-
.getLogger(OvsVifDriver.class);
39+
private static final Logger s_logger = Logger.getLogger(OvsVifDriver.class);
4140
private int _timeout;
4241
private String _modifyVlanPath;
4342

44-
@Override
45-
public void configure(Map<String, Object> params) throws ConfigurationException {
46-
super.configure(params);
43+
@Override
44+
public void configure(Map<String, Object> params) throws ConfigurationException {
45+
super.configure(params);
4746

48-
String networkScriptsDir = (String) params.get("network.scripts.dir");
47+
String networkScriptsDir = (String) params.get("network.scripts.dir");
4948
if (networkScriptsDir == null) {
5049
networkScriptsDir = "scripts/vm/network/vnet";
5150
}
@@ -58,12 +57,12 @@ public void configure(Map<String, Object> params) throws ConfigurationException
5857
throw new ConfigurationException("Unable to find modifyvlan.sh");
5958
}
6059

61-
createControlNetwork(_bridges.get("linklocal"));
62-
}
63-
64-
@Override
65-
public InterfaceDef plug(NicTO nic, String guestOsType)
66-
throws InternalErrorException, LibvirtException {
60+
createControlNetwork(_bridges.get("linklocal"));
61+
}
62+
63+
@Override
64+
public InterfaceDef plug(NicTO nic, String guestOsType)
65+
throws InternalErrorException, LibvirtException {
6766
s_logger.debug("plugging nic=" + nic);
6867

6968
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
@@ -76,7 +75,7 @@ public InterfaceDef plug(NicTO nic, String guestOsType)
7675
vlanId = broadcastUri.getHost();
7776
}
7877
else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
79-
logicalSwitchUuid = nic.getBroadcastUri().getSchemeSpecificPart();
78+
logicalSwitchUuid = nic.getBroadcastUri().getSchemeSpecificPart();
8079
}
8180
String trafficLabel = nic.getName();
8281
if (nic.getType() == Networks.TrafficType.Guest) {
@@ -91,11 +90,11 @@ else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
9190
intf.setVlanTag(Integer.parseInt(vlanId));
9291
}
9392
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
94-
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + logicalSwitchUuid);
95-
intf.setVirtualPortInterfaceId(nic.getUuid());
96-
String brName = (trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("private");
93+
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + logicalSwitchUuid);
94+
intf.setVirtualPortInterfaceId(nic.getUuid());
95+
String brName = (trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("private");
9796
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType));
98-
}
97+
}
9998
else {
10099
intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType));
101100
}
@@ -127,11 +126,11 @@ else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
127126
return intf;
128127
}
129128

130-
@Override
131-
public void unplug(InterfaceDef iface) {
132-
// Libvirt apparently takes care of this, see BridgeVifDriver unplug
133-
}
134-
129+
@Override
130+
public void unplug(InterfaceDef iface) {
131+
// Libvirt apparently takes care of this, see BridgeVifDriver unplug
132+
}
133+
135134
private String setVnetBrName(String pifName, String vnetId) {
136135
String brName = "br" + pifName + "-"+ vnetId;
137136
String oldStyleBrName = "cloudVirBr" + vnetId;
@@ -167,14 +166,13 @@ private void deleteExitingLinkLocalRoutTable(String linkLocalBr) {
167166
NetUtils.getLinkLocalCIDR() + " dev " + linkLocalBr + " src " + NetUtils.getLinkLocalGateway());
168167
}
169168
}
170-
169+
171170
private void createControlNetwork(String privBrName) {
172171
deleteExitingLinkLocalRoutTable(privBrName);
173172
if (!isBridgeExists(privBrName)) {
174173
Script.runSimpleBashScript("ovs-vsctl add-br " + privBrName + "; ifconfig " + privBrName + " up; ifconfig " +
175174
privBrName + " 169.254.0.1", _timeout);
176175
}
177-
178176
}
179177

180178
private boolean isBridgeExists(String bridgeName) {

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public class KVMStoragePoolManager {
3838
private final Map<String, StorageAdaptor> _storageMapper = new HashMap<String, StorageAdaptor>();
3939

4040
private StorageAdaptor getStorageAdaptor(StoragePoolType type) {
41-
// type can be null: LibVirtComputingResource:3238
42-
if (type == null) {
43-
return _storageMapper.get("libvirt");
44-
}
41+
// type can be null: LibVirtComputingResource:3238
42+
if (type == null) {
43+
return _storageMapper.get("libvirt");
44+
}
4545
StorageAdaptor adaptor = _storageMapper.get(type.toString());
4646
if (adaptor == null) {
4747
// LibvirtStorageAdaptor is selected by default

0 commit comments

Comments
 (0)