use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method getSiteDetails.
/**
* Query the site details, such as transition timings, for specific standby site
*
* @param uuid site UUID
* @brief Get site details
* @return SiteActionsTime with detail information
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN, Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/{uuid}/details")
public SiteDetailRestRep getSiteDetails(@PathParam("uuid") String uuid) {
log.info("Begin to get site paused time by uuid {}", uuid);
SiteDetailRestRep standbyDetails = new SiteDetailRestRep();
try {
Site standby = drUtil.getSiteFromLocalVdc(uuid);
standbyDetails.setCreationTime(new Date(standby.getCreationTime()));
Double latency = drUtil.getSiteNetworkState(uuid).getNetworkLatencyInMs();
standbyDetails.setNetworkLatencyInMs(latency);
Date lastSyncTime = drUtil.getLastSyncTime(standby);
if (lastSyncTime != null) {
standbyDetails.setLastSyncTime(lastSyncTime);
}
standbyDetails.setDataSynced(isDataSynced(standby));
ClusterInfo.ClusterState clusterState = coordinator.getControlNodesState(standby.getUuid());
if (clusterState != null) {
standbyDetails.setClusterState(clusterState.toString());
} else {
standbyDetails.setClusterState(ClusterInfo.ClusterState.UNKNOWN.toString());
}
standbyDetails.setSiteState(standby.getState().toString());
} catch (CoordinatorException e) {
log.error("Can't find site {} from ZK", uuid);
throw APIException.badRequests.siteIdNotFound();
} catch (Exception e) {
log.error("Find find site from ZK for UUID {} : {}" + uuid, e);
}
return standbyDetails;
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException 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.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method getTargetInfo.
private <T extends CoordinatorSerializable> T getTargetInfo(String siteId, final Class<T> clazz, String id, String kind) throws CoordinatorException {
T info;
try {
info = clazz.newInstance();
} catch (Exception e) {
log.error("Failed to create instance according class {}, {}", clazz, e);
throw CoordinatorException.fatals.unableToCreateInstanceOfTargetInfo(clazz.getName(), e);
}
final Configuration config = queryConfiguration(siteId, kind, id);
if (config != null && config.getConfig(TARGET_INFO) != null) {
final String infoStr = config.getConfig(TARGET_INFO);
log.debug("getTargetInfo({}): info={}", clazz.getName(), Strings.repr(infoStr));
final T decodeInfo = info.decodeFromString(infoStr);
log.debug("getTargetInfo({}): info={}", clazz.getName(), decodeInfo);
return decodeInfo;
}
return null;
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException in project coprhd-controller by CoprHD.
the class CoordinatorClientImpl method queryRuntimeState.
@Override
public <T extends CoordinatorSerializable> T queryRuntimeState(String key, Class<T> clazz) throws CoordinatorException {
String path = String.format("%s/%s", ZkPath.STATE, key);
try {
byte[] data = _zkConnection.curator().getData().forPath(path);
CoordinatorSerializable state = clazz.newInstance();
return (T) state.decodeFromString(new String(data, "UTF-8"));
} catch (KeeperException.NoNodeException ignore) {
// Ignore exception, don't re-throw
log.debug("Caught exception but ignoring it: " + ignore);
return null;
} catch (Exception e) {
throw CoordinatorException.fatals.unableToFindTheState(key, e);
}
}
use of com.emc.storageos.coordinator.exceptions.CoordinatorException 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