Search in sources :

Example 6 with CoordinatorClientException

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);
    }
}
Also used : Calendar(java.util.Calendar) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate)

Example 7 with CoordinatorClientException

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);
    }
}
Also used : APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) PropertyInfoUpdate(com.emc.storageos.model.property.PropertyInfoUpdate)

Example 8 with CoordinatorClientException

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");
        }
    }
}
Also used : RepositoryInfo(com.emc.storageos.coordinator.client.model.RepositoryInfo) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException) Test(org.junit.Test)

Example 9 with CoordinatorClientException

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");
    }
}
Also used : ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 10 with CoordinatorClientException

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");
    }
}
Also used : ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SyssvcException(com.emc.storageos.systemservices.exceptions.SyssvcException) InvalidLockOwnerException(com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException) IOException(java.io.IOException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Aggregations

CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)12 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)10 IOException (java.io.IOException)6 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)5 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)5 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)5 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)4 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)2 PropertyInfoUpdate (com.emc.storageos.model.property.PropertyInfoUpdate)2 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)1 CoordinatorClassInfo (com.emc.storageos.coordinator.client.model.CoordinatorClassInfo)1 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)1 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)1 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)1 PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 UpgradeVoter (com.emc.storageos.security.upgradevoter.UpgradeVoter)1