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));
}
}
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);
}
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);
}
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);
}
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;
}
Aggregations