Merge branch '4.11': Fixes #2631 VMware dvs portgroup autogrowth (#2634)

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2018-05-11 22:21:31 +05:30
commit 7ce2c2eaf0
4 changed files with 18 additions and 17 deletions

View File

@ -18,3 +18,5 @@
--; --;
-- Schema cleanup after 4.11.0.0 to 4.11.1.0 upgrade -- Schema cleanup after 4.11.0.0 to 4.11.1.0 upgrade
--; --;
DELETE FROM `cloud`.`configuration` WHERE `name`='vmware.ports.per.dvportgroup';

View File

@ -136,6 +136,8 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class); private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class);
private static final long SECONDS_PER_MINUTE = 60; private static final long SECONDS_PER_MINUTE = 60;
private static final int DEFAULT_PORTS_PER_DV_PORT_GROUP_VSPHERE4_x = 256;
private static final int DEFAULT_PORTS_PER_DV_PORT_GROUP = 8;
private int _timeout; private int _timeout;
@ -194,7 +196,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
private StorageLayer _storage; private StorageLayer _storage;
private final String _privateNetworkVSwitchName = "vSwitch0"; private final String _privateNetworkVSwitchName = "vSwitch0";
private int _portsPerDvPortGroup = 256; private int _portsPerDvPortGroup = DEFAULT_PORTS_PER_DV_PORT_GROUP;
private boolean _fullCloneFlag; private boolean _fullCloneFlag;
private boolean _instanceNameFlag; private boolean _instanceNameFlag;
private String _serviceConsoleName; private String _serviceConsoleName;
@ -279,8 +281,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
_instanceNameFlag = Boolean.parseBoolean(value); _instanceNameFlag = Boolean.parseBoolean(value);
} }
_portsPerDvPortGroup = NumbersUtil.parseInt(_configDao.getValue(Config.VmwarePortsPerDVPortGroup.key()), _portsPerDvPortGroup);
_serviceConsoleName = _configDao.getValue(Config.VmwareServiceConsole.key()); _serviceConsoleName = _configDao.getValue(Config.VmwareServiceConsole.key());
if (_serviceConsoleName == null) { if (_serviceConsoleName == null) {
_serviceConsoleName = "Service Console"; _serviceConsoleName = "Service Console";
@ -394,8 +394,16 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan, null, null); HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false, BroadcastDomainType.Vlan, null, null);
} }
else { else {
int portsPerDvPortGroup = _portsPerDvPortGroup;
AboutInfo about = hostMo.getHostAboutInfo();
if (about != null) {
String version = about.getApiVersion();
if (version != null && (version.equals("4.0") || version.equals("4.1")) && _portsPerDvPortGroup < DEFAULT_PORTS_PER_DV_PORT_GROUP_VSPHERE4_x) {
portsPerDvPortGroup = DEFAULT_PORTS_PER_DV_PORT_GROUP_VSPHERE4_x;
}
}
HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, null, 180000, HypervisorHostHelper.prepareNetwork(vSwitchName, "cloud.private", hostMo, vlanId, null, null, null, 180000,
vsType, _portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan, null, null); vsType, portsPerDvPortGroup, null, false, BroadcastDomainType.Vlan, null, null);
} }
} }

View File

@ -1139,14 +1139,6 @@ public enum Config {
"false", "false",
"Enable/Disable Nexus/Vmware dvSwitch in VMware environment", "Enable/Disable Nexus/Vmware dvSwitch in VMware environment",
null), null),
VmwarePortsPerDVPortGroup(
"Network",
ManagementServer.class,
Integer.class,
"vmware.ports.per.dvportgroup",
"256",
"Default number of ports per Vmware dvPortGroup in VMware environment",
null),
VmwareCreateFullClone( VmwareCreateFullClone(
"Advanced", "Advanced",
ManagementServer.class, ManagementServer.class,

View File

@ -755,9 +755,8 @@ public class HypervisorHostHelper {
dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, pvlanSpec); dvsPortSetting = createVmwareDVPortSettingSpec(shapingPolicy, secPolicy, pvlanSpec);
} }
newDvPortGroupSpec = createDvPortGroupSpec(networkName, dvsPortSetting, numPorts, autoExpandSupported); newDvPortGroupSpec = createDvPortGroupSpec(networkName, dvsPortSetting, autoExpandSupported);
if (portGroupPolicy != null) if (portGroupPolicy != null) {
{
newDvPortGroupSpec.setPolicy(portGroupPolicy); newDvPortGroupSpec.setPolicy(portGroupPolicy);
} }
@ -765,6 +764,7 @@ public class HypervisorHostHelper {
s_logger.info("Distributed Virtual Port group " + networkName + " not found."); s_logger.info("Distributed Virtual Port group " + networkName + " not found.");
// TODO(sateesh): Handle Exceptions // TODO(sateesh): Handle Exceptions
try { try {
newDvPortGroupSpec.setNumPorts(numPorts);
dvSwitchMo.createDVPortGroup(newDvPortGroupSpec); dvSwitchMo.createDVPortGroup(newDvPortGroupSpec);
} catch (Exception e) { } catch (Exception e) {
String msg = "Failed to create distributed virtual port group " + networkName + " on dvSwitch " + physicalNetwork; String msg = "Failed to create distributed virtual port group " + networkName + " on dvSwitch " + physicalNetwork;
@ -994,13 +994,12 @@ public class HypervisorHostHelper {
return true; return true;
} }
public static DVPortgroupConfigSpec createDvPortGroupSpec(String dvPortGroupName, DVPortSetting portSetting, int numPorts, boolean autoExpandSupported) { public static DVPortgroupConfigSpec createDvPortGroupSpec(String dvPortGroupName, DVPortSetting portSetting, boolean autoExpandSupported) {
DVPortgroupConfigSpec spec = new DVPortgroupConfigSpec(); DVPortgroupConfigSpec spec = new DVPortgroupConfigSpec();
spec.setName(dvPortGroupName); spec.setName(dvPortGroupName);
spec.setDefaultPortConfig(portSetting); spec.setDefaultPortConfig(portSetting);
spec.setPortNameFormat("vnic<portIndex>"); spec.setPortNameFormat("vnic<portIndex>");
spec.setType("earlyBinding"); spec.setType("earlyBinding");
spec.setNumPorts(numPorts);
spec.setAutoExpand(autoExpandSupported); spec.setAutoExpand(autoExpandSupported);
return spec; return spec;
} }