Search in sources :

Example 1 with ViPRSystemClient

use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method precheckStandbyVersion.

protected void precheckStandbyVersion(SiteAddParam standby) {
    ViPRSystemClient viprSystemClient = createViPRSystemClient(standby.getVip(), standby.getUsername(), standby.getPassword());
    // software version should be matched
    SoftwareVersion currentSoftwareVersion;
    SoftwareVersion standbySoftwareVersion;
    try {
        currentSoftwareVersion = coordinator.getTargetInfo(RepositoryInfo.class).getCurrentVersion();
        standbySoftwareVersion = new SoftwareVersion(viprSystemClient.upgrade().getTargetVersion().getTargetVersion());
    } catch (Exception e) {
        throw APIException.internalServerErrors.addStandbyPrecheckFailed(String.format("Fail to get software version %s", e.getMessage()));
    }
    // otherwise the standby site will automatically upgrade/downgrade to the same version with the active site
    if (!currentSoftwareVersion.equals(standbySoftwareVersion)) {
        throw APIException.internalServerErrors.addStandbyPrecheckFailed(String.format("Standby site version %s does not equal to current version %s", standbySoftwareVersion, currentSoftwareVersion));
    }
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) UnknownHostException(java.net.UnknownHostException)

Example 2 with ViPRSystemClient

use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.

the class ClusterInfo method ipReconfig.

/**
 * Submit cluster IPs reconfiguration requests.
 *
 * @param ipReconfigForm
 */
public static void ipReconfig(final ClusterIpInfoForm ipReconfigForm) {
    ipReconfigForm.validate();
    if (Validation.hasErrors()) {
        params.flash();
        Validation.keep();
        clusterIpInfo(ipReconfigForm);
    }
    final ViPRSystemClient client = BourneUtil.getSysClient();
    final ClusterIpInfo clusterIpInfo = ipReconfigForm.getClusterIpInfo();
    try {
        boolean isAccepted = client.control().reconfigClusterIps(clusterIpInfo, ipReconfigForm.powerOff);
        if (isAccepted) {
            flash.put("info", MessagesUtils.get(SUCCESS_KEY));
        } else {
            flash.error(MessagesUtils.get(ERROR_KEY));
        }
    } catch (Exception e) {
        flash.error(MessagesUtils.get(EXCEPTION_KEY, e.getMessage()));
        Logger.error(e, e.getMessage());
    }
    clusterIpInfo(ipReconfigForm);
}
Also used : ClusterIpInfo(com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo) ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) FlashException(controllers.util.FlashException)

Example 3 with ViPRSystemClient

use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.

the class ClusterInfo method clusterIpInfo.

/**
 * loads cluster ip configuration details
 */
public static void clusterIpInfo(ClusterIpInfoForm ipReconfigForm) {
    if (ipReconfigForm == null) {
        ViPRSystemClient client = BourneUtil.getSysClient();
        ClusterIpInfo clusterIpInfo = client.control().getClusterIpinfo();
        ipReconfigForm = new ClusterIpInfoForm();
        ipReconfigForm.load(clusterIpInfo);
        ClusterNetworkReconfigStatus ipReconfigStatus = client.control().getClusterIpReconfigStatus();
        if (ipReconfigStatus != null && ipReconfigStatus.getStatus() != null) {
            if (ipReconfigStatus.getStatus().equals(ClusterNetworkReconfigStatus.Status.FAILED)) {
                flash.error(MessagesUtils.get(RECONFIGURATION_STATUS_ERROR, ipReconfigStatus.getMessage()));
            } else if (ipReconfigStatus.getStatus().equals(ClusterNetworkReconfigStatus.Status.SUCCEED)) {
                if (ipReconfigStatus.isRecentlyReconfigured()) {
                    flash.put("info", MessagesUtils.get(RECONFIGURATION_STATUS_SUCCESS));
                }
            }
        }
    }
    // NOSONAR
    vip = ipReconfigForm.selectVipforStatusQuery();
    // ("Suppressing Sonar violation of Lazy initialization of static fields should be synchronized for vip. vip only fetches network info. Sync not needed.")
    loadRenderArgs();
    render(ipReconfigForm);
}
Also used : ClusterIpInfo(com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo) ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ClusterNetworkReconfigStatus(com.emc.vipr.model.sys.ipreconfig.ClusterNetworkReconfigStatus)

Example 4 with ViPRSystemClient

use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.

the class ClusterInfo method ipReconfigStatusJson.

/**
 * gets ip reconfigurations status in json format
 */
@FlashException()
public static void ipReconfigStatusJson() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    ClusterNetworkReconfigStatus ipReconfigStatus = client.control().getClusterIpReconfigStatus();
    Gson gson = new Gson();
    String ipReconfigStatusJSON = gson.toJson(ipReconfigStatus);
    renderJSON(ipReconfigStatusJSON);
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) Gson(com.google.gson.Gson) ClusterNetworkReconfigStatus(com.emc.vipr.model.sys.ipreconfig.ClusterNetworkReconfigStatus) FlashException(controllers.util.FlashException)

Example 5 with ViPRSystemClient

use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.

the class PasswordUtil method validatePasswordforUpdate.

/**
 * Validates a password using the ViPR api call during self update.
 *
 * @param plaintext password to validate
 * @return If validation passes, returns an empty string. If validation fails, returns the validation error message.
 */
public static String validatePasswordforUpdate(String oldPassword, String newPassword) {
    ViPRSystemClient client = BourneUtil.getSysClient();
    try {
        oldPassword = decryptedValue(oldPassword);
        newPassword = decryptedValue(newPassword);
        client.password().validateUpdate(oldPassword, newPassword);
    } catch (ServiceErrorException e) {
        if (e.getHttpCode() == 400 && e.getServiceError() != null) {
            return e.getServiceError().getDetailedMessage();
        }
    } catch (Exception e) {
        Logger.error(e, "Error executing api call to validate password");
        return MessagesUtils.get("setup.password.notValid");
    }
    return StringUtils.EMPTY;
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Aggregations

ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)17 RecoveryStatus (com.emc.vipr.model.sys.recovery.RecoveryStatus)4 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)3 NodeHealth (com.emc.vipr.model.sys.healthmonitor.NodeHealth)3 DateTime (org.joda.time.DateTime)3 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)2 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)2 ClusterIpInfo (com.emc.vipr.model.sys.ipreconfig.ClusterIpInfo)2 ClusterNetworkReconfigStatus (com.emc.vipr.model.sys.ipreconfig.ClusterNetworkReconfigStatus)2 RecoveryPrecheckStatus (com.emc.vipr.model.sys.recovery.RecoveryPrecheckStatus)2 Gson (com.google.gson.Gson)2 Restrictions (controllers.deadbolt.Restrictions)2 FlashException (controllers.util.FlashException)2 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)1 LogMessageProcessor (com.emc.vipr.client.system.LogMessageProcessor)1