use of com.vmware.vim25.ClusterDrsConfigInfo in project coprhd-controller by CoprHD.
the class VcenterClusterConfigurerPropertyInfoImpl method configure.
public ClusterConfigSpecEx configure(Object input) throws Exception {
PropertyInfo propertyInfo = (PropertyInfo) input;
VcenterClusterSettingsConverter converter = VcenterClusterSettingsConverter.getInstance();
ClusterConfigSpecEx clusterConfigSpecEx = new ClusterConfigSpecEx();
clusterConfigSpecEx.setDrsConfig(new ClusterDrsConfigInfo());
// Enable DRS
clusterConfigSpecEx.getDrsConfig().setEnabled(true);
clusterConfigSpecEx.getDrsConfig().setDefaultVmBehavior(converter.convertToDrsBehavior(propertyInfo.getProperty("vcenter_drs_automationLevel")));
/**
* VMWare DRS
*/
if (Boolean.parseBoolean(propertyInfo.getProperty("vcenter_drs_enabled"))) {
_log.info("Set VMWare DRS options for cluster");
clusterConfigSpecEx.setDrsConfig(new ClusterDrsConfigInfo());
// Enable DRS
clusterConfigSpecEx.getDrsConfig().setEnabled(true);
_log.info("Set Automation level options for cluster");
clusterConfigSpecEx.getDrsConfig().setDefaultVmBehavior(// Automation level
converter.convertToDrsBehavior(propertyInfo.getProperty("vcenter_drs_automationLevel")));
clusterConfigSpecEx.getDrsConfig().setVmotionRate(// Migration
converter.validateThresholdRange(Integer.parseInt(propertyInfo.getProperty("vcenter_drs_migrationThreshold"))));
// threshold
// - 1
// is
// Aggressive
// in
// vCenter
// Power management - DRS must be enabled
clusterConfigSpecEx.setDpmConfig(new ClusterDpmConfigInfo());
// Enable
clusterConfigSpecEx.getDpmConfig().setEnabled(Boolean.parseBoolean(propertyInfo.getProperty("vcenter_drs_dpm_enabled")));
// enabled
if (Boolean.parseBoolean(propertyInfo.getProperty("vcenter_drs_dpm_enabled"))) {
_log.info("Set DPM options for cluster");
clusterConfigSpecEx.getDpmConfig().setDefaultDpmBehavior(// Power Management
converter.convertToDpmBehavior(propertyInfo.getProperty("vcenter_drs_dpm_powerManagement")));
clusterConfigSpecEx.getDpmConfig().setHostPowerActionRate(// DPM
(converter.validateThresholdRange(Integer.parseInt(propertyInfo.getProperty("vcenter_drs_dpm_dpmThreshold")))));
// Threshold
// -
// 1
// is
// Aggressive
// in
// vCenter
}
}
/**
* VMWare HA
*/
if (Boolean.parseBoolean(propertyInfo.getProperty("vcenter_das_enabled"))) {
_log.info("Set VMWare HA options for cluster");
clusterConfigSpecEx.setDasConfig(new ClusterDasConfigInfo());
clusterConfigSpecEx.getDasConfig().setEnabled(true);
clusterConfigSpecEx.getDasConfig().setHostMonitoring(converter.convertToClusterDasConfigInfoServiceState(Boolean.parseBoolean(propertyInfo.getProperty("vcenter_das_hostMonitoring_enabled"))).toString());
// Monitoring
// Status
_log.info("Set Admission Control Policy options for cluster");
// Work around API quirk - A non-null ACP must be set regardless if ACP is enabled so if disabled just assign some value. Value
// doesnt matter and will not be used but it cannot be null!
Boolean enableAdmissionControl = Boolean.parseBoolean(propertyInfo.getProperty("vcenter_das_admissionControl_enabled"));
String acpName = enableAdmissionControl ? propertyInfo.getProperty("vcenter_das_admissionControlPolicy_policy") : "resourcePercentage";
Integer acpHostFailoverLevel = enableAdmissionControl ? Integer.parseInt(propertyInfo.getProperty("vcenter_das_admissionControlPolicy_hostFailureLevel_failoverLevel")) : 1;
Integer acpCpuFailoverPercent = enableAdmissionControl ? Integer.parseInt(propertyInfo.getProperty("vcenter_das_admissionControlPolicy_resourcePercentage_cpuPercentage")) : 50;
Integer acpMemoryFailoverPercent = enableAdmissionControl ? Integer.parseInt(propertyInfo.getProperty("vcenter_das_admissionControlPolicy_resourcePercentage_memoryPercentage")) : 50;
// Admission Control
clusterConfigSpecEx.getDasConfig().setAdmissionControlEnabled(enableAdmissionControl);
ClusterDasAdmissionControlPolicy clusterDasAdmissionControlPolicy = converter.convertAdmissionControlPolicyToClusterDasAdmissionControlPolicy(acpName, acpHostFailoverLevel, acpCpuFailoverPercent, acpMemoryFailoverPercent);
clusterConfigSpecEx.getDasConfig().setAdmissionControlPolicy(clusterDasAdmissionControlPolicy);
/**
* Virtual Machine Options
*/
_log.info("Set Virtual Machine options for cluster");
clusterConfigSpecEx.getDasConfig().setDefaultVmSettings(new ClusterDasVmSettings());
clusterConfigSpecEx.getDasConfig().getDefaultVmSettings().setRestartPriority(converter.convertToClusterDasVmSettingsRestartPriority(propertyInfo.getProperty("vcenter_das_vmSettings_restartPriority")).toString());
clusterConfigSpecEx.getDasConfig().getDefaultVmSettings().setIsolationResponse(converter.convertToClusterDasVmSettingsIsolationResponse(propertyInfo.getProperty("vcenter_das_vmSettings_isolationResponse")).toString());
// Response
clusterConfigSpecEx.getDasConfig().setVmMonitoring(converter.convertToClusterDasConfigInfoVmMonitoringState(propertyInfo.getProperty("vcenter_das_vmSettings_vmMonitoring_monitoring")).toString());
// VM
clusterConfigSpecEx.getDasConfig().getDefaultVmSettings().setVmToolsMonitoringSettings(new ClusterVmToolsMonitoringSettings());
// Monitoring
// -
// Default
// Cluster
// Settings
// -
// Monitoring
// sensitivity
// is
// composed
// of
// several
// options
// (simplified
// in
// UI)
converter.convertVmMonitoringSensitivityToFinerGrainedSettings(propertyInfo.getProperty("vcenter_das_vmSettings_vmMonitoring_sensitivity"), clusterConfigSpecEx.getDasConfig().getDefaultVmSettings().getVmToolsMonitoringSettings());
}
/**
* VMWare EVC
*/
// TODO figure out EVC API
_log.info("EVC defaulted to always disabled");
/**
* VM Swapfile location
*/
_log.info("Set VM Swapfile location options for cluster");
ComputeResourceConfigSpec computeResourceConfigSpec = (ComputeResourceConfigSpec) clusterConfigSpecEx;
computeResourceConfigSpec.setVmSwapPlacement(converter.convertToVirtualMachineConfigInfoSwapPlacementType(propertyInfo.getProperty("vcenter_swapfile_policy")).toString());
return clusterConfigSpecEx;
}
use of com.vmware.vim25.ClusterDrsConfigInfo in project photon-model by vmware.
the class ComputeResourceOverlay method isDrsEnabled.
public boolean isDrsEnabled() {
ClusterConfigInfoEx info = getClusterConfigInfoEx();
Boolean isDrsEnabled = false;
if (null != info) {
ClusterDrsConfigInfo drsConfig = info.getDrsConfig();
isDrsEnabled = drsConfig == null || drsConfig.isEnabled();
}
return isDrsEnabled;
}
Aggregations