CLOUDSTACK-651: Removed 7 nics limitation for VR on XenServer

# of nics can be configured using global param xen.nics.max. Param defaults to 7
Added new param to upgrade schema.
This commit is contained in:
Kishan Kavala 2013-02-18 20:29:19 +05:30
parent a4ed061dbf
commit cc2a3c5498
5 changed files with 23 additions and 29 deletions

View File

@ -315,6 +315,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
params.put("wait", Integer.toString(_wait));
details.put("wait", Integer.toString(_wait));
params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
params.put(Config.XenMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenMaxNics.toString()));
params.put(Config.InstanceName.toString().toLowerCase(), _instance);
details.put(Config.InstanceName.toString().toLowerCase(), _instance);
try {

View File

@ -331,6 +331,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
protected boolean _isOvs = false;
protected List<VIF> _tmpDom0Vif = new ArrayList<VIF>();
protected XenServerStorageResource storageResource;
protected int _maxNics = 7;
public enum SRType {
NFS, LVM, ISCSI, ISO, LVMOISCSI, LVMOHBA, EXT, FILE;
@ -3842,22 +3843,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
throw new CloudRuntimeException("Could not find an available slot in VM with name to attach a new disk.");
}
protected String getUnusedVIFNum(Connection conn, VM vm) {
String vmName = "";
try {
vmName = vm.getNameLabel(conn);
Set<String> allowedVIFDevices = vm.getAllowedVIFDevices(conn);
if (allowedVIFDevices.size() > 0) {
return allowedVIFDevices.iterator().next();
}
} catch (Exception e) {
String msg = "getUnusedVIFNum failed due to " + e.toString();
s_logger.warn(msg, e);
}
throw new CloudRuntimeException("Could not find available VIF slot in VM with name: " + vmName + " to plug a VIF");
}
protected String callHostPlugin(Connection conn, String plugin, String cmd, String... params) {
Map<String, String> args = new HashMap<String, String>();
String msg;
@ -3990,21 +3975,25 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
protected String getLowestAvailableVIFDeviceNum(Connection conn, VM vm) {
try {
Set<String> availableDeviceNums = vm.getAllowedVIFDevices(conn);
Iterator<String> deviceNumsIterator = availableDeviceNums.iterator();
List<Integer> sortedDeviceNums = new ArrayList<Integer>();
while (deviceNumsIterator.hasNext()) {
try {
sortedDeviceNums.add(Integer.valueOf(deviceNumsIterator.next()));
List<Integer> usedDeviceNums = new ArrayList<Integer>();
Set<VIF> vifs = vm.getVIFs(conn);
Iterator<VIF> vifIter = vifs.iterator();
while(vifIter.hasNext()){
VIF vif = vifIter.next();
try{
usedDeviceNums.add(Integer.valueOf(vif.getDevice(conn)));
} catch (NumberFormatException e) {
s_logger.debug("Obtained an invalid value for an available VIF device number for VM: " + vm.getNameLabel(conn));
s_logger.debug("Obtained an invalid value for an allocated VIF device number for VM: " + vm.getNameLabel(conn));
return null;
}
}
Collections.sort(sortedDeviceNums);
return String.valueOf(sortedDeviceNums.get(0));
for(Integer i=0; i< _maxNics; i++){
if(!usedDeviceNums.contains(i)){
s_logger.debug("Lowest available Vif device number: "+i+" for VM: " + vm.getNameLabel(conn));
return i.toString();
}
}
} catch (XmlRpcException e) {
String msg = "Caught XmlRpcException: " + e.getMessage();
s_logger.warn(msg, e);
@ -5655,6 +5644,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
value = (String) params.get("migratewait");
_migratewait = NumbersUtil.parseInt(value, 3600);
_maxNics = NumbersUtil.parseInt((String) params.get("xen.nics.max"), 7);
if (_pod == null) {
throw new ConfigurationException("Unable to get the pod");
}
@ -7765,7 +7756,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
s_logger.warn(msg);
return new PlugNicAnswer(cmd, false, msg);
}
String deviceId = getUnusedVIFNum(conn, vm);
String deviceId = getLowestAvailableVIFDeviceNum(conn, vm);
nic.setDeviceId(Integer.parseInt(deviceId));
vif = createVif(conn, vmName, vm, nic);
vif.plug(conn);

View File

@ -247,7 +247,7 @@ public enum Config {
XenBondStorageNic("Advanced", ManagementServer.class, String.class, "xen.bond.storage.nics", null, "Attempt to bond the two networks if found", null),
XenHeartBeatInterval("Advanced", ManagementServer.class, Integer.class, "xen.heartbeat.interval", "60", "heartbeat to use when implementing XenServer Self Fencing", null),
XenGuestNetwork("Hidden", ManagementServer.class, String.class, "xen.guest.network.device", null, "Specify for guest network name label", null),
XenMaxNics("Advanced", AgentManager.class, Integer.class, "xen.nics.max", "7", "Maximum allowed nics for Vms created on Xen", null),
// VMware
VmwarePrivateNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.private.vswitch", null, "Specify the vSwitch on host for private network", null),
VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null),
@ -360,7 +360,7 @@ public enum Config {
VpcMaxNetworks("Advanced", ManagementServer.class, Integer.class, "vpc.max.networks", "3", "Maximum number of networks per vpc", null),
DetailBatchQuerySize("Advanced", ManagementServer.class, Integer.class, "detail.batch.query.size", "2000", "Default entity detail batch query size for listing", null),
ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost",
null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null),
null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null),
NetworkIPv6SearchRetryMax("Network", ManagementServer.class, Integer.class, "network.ipv6.search.retry.max", "10000", "The maximum number of retrying times to search for an available IPv6 address in the table", null),
ExternalBaremetalSystemUrl("Advanced", ManagementServer.class, String.class, "external.baremetal.system.url", null, "url of external baremetal system that CloudStack will talk to", null),

View File

@ -128,6 +128,7 @@ public abstract class DiscovererBase extends AdapterBase implements Discoverer {
params.put("secondary.storage.vm", "false");
params.put("max.template.iso.size", _configDao.getValue(Config.MaxTemplateAndIsoSize.toString()));
params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString()));
params.put(Config.XenMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenMaxNics.toString()));
return params;
}

View File

@ -23,3 +23,4 @@ ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `max_hosts_per_cluster`
UPDATE `cloud`.`hypervisor_capabilities` SET `max_hosts_per_cluster`=32 WHERE `hypervisor_type`='VMware';
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '5.1', 128, 0, 32);
DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max';
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen');