use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.
the class LocalPasswordHandler method updateUserPasswordProperty.
/**
* when updating localuser's encpassword property, this method should be call instead of
* updateProperty method.
*
* it will update encpassword property, it also update user's expiry_date property and
* user's password history.
*
* expiry_date system properties is for generate /etc/shadow file to block ssh login after
* user's password expired.
*
* @param username
* @param value
* @throws CoordinatorClientException
* @throws LocalRepositoryException
*/
private void updateUserPasswordProperty(String username, String value, boolean bReset) throws CoordinatorClientException, LocalRepositoryException {
String encpasswordProperty = String.format(SYSTEM_ENCPASSWORD_FORMAT, username);
PropertyInfoUpdate props = new PropertyInfoUpdate();
props.addProperty(encpasswordProperty, value);
Calendar newExpireTime = getExpireTimeFromNow();
if (username.equals("root") || username.equals("svcuser")) {
// add expiry_date system property
String configExpireDays = getPasswordUtils().getConfigProperty(Constants.PASSWORD_EXPIRE_DAYS);
int intConfigExpireDays = NumberUtils.toInt(configExpireDays);
int daysAfterEpoch = 0;
if (intConfigExpireDays != 0) {
daysAfterEpoch = PasswordUtils.getDaysAfterEpoch(newExpireTime);
}
String expirydaysProperty = String.format(Constants.SYSTEM_PASSWORD_EXPIRY_FORMAT, username);
_log.info("updating " + expirydaysProperty + " to " + daysAfterEpoch);
props.addProperty(expirydaysProperty, String.valueOf(daysAfterEpoch));
}
try {
_cfg.setProperties(props);
if (username.equals("proxyuser")) {
value = _passwordUtils.getEncryptedString(value);
}
_passwordUtils.updatePasswordHistory(username, value, newExpireTime, bReset);
} catch (Exception e) {
throw APIException.internalServerErrors.updateObjectError("properties", e);
}
}
use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.
the class LocalPasswordHandler method updateProperty.
public void updateProperty(String key, String value) throws CoordinatorClientException, LocalRepositoryException {
PropertyInfoUpdate props = new PropertyInfoUpdate();
props.addProperty(key, value);
_log.info("Calling ConfigService to update property: ", key);
try {
_cfg.setProperties(props);
} catch (Exception e) {
throw APIException.internalServerErrors.updateObjectError("properties", e);
}
}
use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.
the class UpgradeCoordinatorClientTest method testNodeIdentifier.
@Test
public void testNodeIdentifier() {
List<String> nodelist = _coordinator.getAllNodes();
System.out.println("Number of Nodes found " + nodelist.size());
Iterator<String> nodeIter = nodelist.iterator();
while (nodeIter.hasNext()) {
String currentnode = nodeIter.next();
System.out.println("Node ID " + currentnode);
try {
RepositoryInfo info = _coordinator.getRepositoryInfo(currentnode);
} catch (CoordinatorClientException e) {
System.out.println("Version List is null");
}
}
}
use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method setTargetInfo.
/**
* Set target info shared by all nodes.
*
* @param info info, String id, String kind
* @throws CoordinatorClientException
*/
public void setTargetInfo(final CoordinatorSerializable info, String id, String kind) throws CoordinatorClientException {
if (info == null) {
return;
}
if (getTargetInfoLock()) {
try {
// check we are in stable state & version exists in available
if (!isClusterUpgradable()) {
throw APIException.serviceUnavailable.clusterStateNotStable();
}
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(id);
cfg.setKind(kind);
cfg.setConfig(TARGET_INFO, info.encodeAsString());
_coordinator.persistServiceConfiguration(cfg);
} catch (Exception e) {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. " + e.getMessage());
} finally {
releaseTargetVersionLock();
}
} else {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to set target state. Unable to obtain target lock");
}
}
use of com.emc.storageos.systemservices.exceptions.CoordinatorClientException in project coprhd-controller by CoprHD.
the class CoordinatorClientExt method removeTargetInfo.
/**
* Remove target info shared by all nodes.
*
* @param info info, String id, String kind
* @throws CoordinatorClientException
*/
public void removeTargetInfo(final CoordinatorSerializable info, String id, String kind) throws CoordinatorClientException {
if (info == null) {
return;
}
if (getTargetInfoLock()) {
try {
// check we are in stable state & version exists in available
if (!isClusterUpgradable()) {
throw APIException.serviceUnavailable.clusterStateNotStable();
}
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(id);
cfg.setKind(kind);
cfg.setConfig(TARGET_INFO, info.encodeAsString());
_coordinator.removeServiceConfiguration(cfg);
_log.info("Target info removed: {}", info);
} catch (Exception e) {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. " + e.getMessage());
} finally {
releaseTargetVersionLock();
}
} else {
throw SyssvcException.syssvcExceptions.coordinatorClientError("Failed to remove target info. Unable to obtain target lock");
}
}
Aggregations