use of com.emc.storageos.model.property.PropertyInfo 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.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.
the class ImageServerConf method init.
public void init() {
PropertyInfo p = coordinator.getPropertyInfo();
setImageServerIp(p.getProperty("image_server_address"));
setImageServerUser(p.getProperty("image_server_username"));
setTftpbootDir(p.getProperty("image_server_tftpboot_directory"));
setImageServerSecondIp(p.getProperty("image_server_os_network_ip"));
setImageServerHttpPort(p.getProperty("image_server_http_port"));
setImageDir(p.getProperty("image_server_image_directory"));
String encryptedPassword = p.getProperty("image_server_encpassword");
try {
setImageServerPassword(encryptionProvider.decrypt(Base64.decodeBase64(encryptedPassword)));
} catch (Exception e) {
log.warn("Can't decrypt image server password, it has to be re-saved");
return;
}
// make sure all required fields are set
if (!StringUtils.isBlank(imageServerIp) && !StringUtils.isBlank(imageServerUser) && !StringUtils.isBlank(tftpbootDir) && !StringUtils.isBlank(imageServerSecondIp) && !StringUtils.isBlank(imageServerHttpPort) && !StringUtils.isBlank(imageServerPassword)) {
log.info("ImageServerConf appears valid");
valid = true;
}
try {
setSshPort(Integer.valueOf(p.getProperty("image_server_ssh_port")));
setImageImportTimeoutMs(1000 * Integer.valueOf(p.getProperty("image_server_image_import_timeout")));
setJobPollingIntervalMs(1000 * Integer.valueOf(p.getProperty("image_server_job_polling_interval")));
setOsInstallTimeoutMs(1000 * Integer.valueOf(p.getProperty("image_server_os_install_timeout")));
setSshTimeoutMs(1000 * Integer.valueOf(p.getProperty("image_server_ssh_timeout")));
} catch (NumberFormatException e) {
// ignoring this, the default values will be used
log.warn("NumberFormatException when parsing image server values: " + e.getMessage());
}
}
use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.
the class StorageOSLocalAuthenticationHandler method verifyUserPassword.
/**
* Verify that the user's password matches with the hashed and salted value stored.
* Return false if user is not found.
*
* @param username the user
* @param clearTextPassword the clear text password
* @return true if user's password matches, otherwise false.
*/
public boolean verifyUserPassword(final String username, final String clearTextPassword) {
if (clearTextPassword == null || clearTextPassword.isEmpty()) {
_log.error("Login with blank password is not allowed");
return false;
}
String encpassword = null;
PropertyInfo props = null;
try {
props = _coordinatorClient.getPropertyInfo();
} catch (CoordinatorException e) {
_log.error("Access local user properties failed", e);
return false;
}
if (props == null) {
_log.error("Access local user properties failed");
return false;
}
encpassword = props.getProperty("system_" + username + "_encpassword");
if (StringUtils.isBlank(encpassword)) {
_log.error("No password set for user {} ", username);
return false;
}
// A hashed value will start with the SHA-512 identifier ($6$)
if (StringUtils.startsWith(encpassword, CRYPT_SHA_512)) {
// Hash the clear text password and compare against the stored value
String hashedValue = Crypt.crypt(clearTextPassword, encpassword);
return encpassword.equals(hashedValue);
} else {
// Encrypt the clear text password and compare against the stored value
String encryptedValue = encrypt(clearTextPassword);
return encpassword.equals(encryptedValue);
}
}
use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.
the class DisasterRecoveryServiceTest method testPauseStandby.
@Test
public void testPauseStandby() {
try {
drService.pauseStandby(primarySite.getUuid());
} catch (APIException e) {
assertEquals(e.getServiceCode(), ServiceCode.API_BAD_REQUEST);
}
try {
drService.pauseStandby(NONEXISTENT_ID);
} catch (APIException e) {
assertEquals(e.getServiceCode(), ServiceCode.API_PARAMETER_INVALID);
}
doNothing().when(coordinator).persistServiceConfiguration(any(Configuration.class));
doReturn(null).when(coordinator).getTargetInfo(any(String.class), eq(SiteInfo.class));
doNothing().when(coordinator).setTargetInfo(any(String.class), any(SiteInfo.class));
doReturn(new PropertyInfo()).when(coordinator).getPropertyInfo();
try {
DbClientContext mockDBClientContext = mock(DbClientContext.class);
doNothing().when(mockDBClientContext).removeDcFromStrategyOptions(any(String.class));
doReturn(mockDBClientContext).when(dbClientMock).getLocalContext();
doReturn(mockDBClientContext).when(dbClientMock).getGeoContext();
drService.pauseStandby(standbySite2.getUuid());
} catch (Exception e) {
fail();
}
}
use of com.emc.storageos.model.property.PropertyInfo in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method getPropertyInfo.
/**
* Get property
*
* This method gets target properties from coordinator service as a string
* and merges it with the defaults and the ovf properties
* Syssvc is responsible for publishing the target property information into coordinator
*
* @return property object
* @throws CoordinatorException
*/
@Override
public PropertyInfo getPropertyInfo() throws CoordinatorException {
PropertyInfo info = new PropertyInfo();
Map<String, String> defaults = new HashMap<String, String>((Map) defaultProperties);
final Configuration config = queryConfiguration(TARGET_PROPERTY, TARGET_PROPERTY_ID);
if (null == config || null == config.getConfig(TARGET_INFO)) {
log.debug("getPropertyInfo(): no properties saved in coordinator returning defaults");
info.setProperties(defaults);
} else {
final String infoStr = config.getConfig(TARGET_INFO);
try {
log.debug("getPropertyInfo(): properties saved in coordinator=" + Strings.repr(infoStr));
info.setProperties(mergeProps(defaults, decodeFromString(infoStr).getProperties()));
} catch (final Exception e) {
throw CoordinatorException.fatals.unableToDecodeDataFromCoordinator(e);
}
}
// add site specific properties
PropertyInfoExt siteScopePropInfo = getTargetInfo(getSiteId(), PropertyInfoExt.class);
if (siteScopePropInfo != null) {
info.getProperties().putAll(siteScopePropInfo.getProperties());
}
// add the ovf properties
info.getProperties().putAll((Map) ovfProperties);
return info;
}
Aggregations