use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.
the class BourneUtil method getSysClient.
public static ViPRSystemClient getSysClient() {
String authToken = Security.getAuthToken();
String key = String.format("ViPRSystemClient.%s", authToken);
ViPRSystemClient client = getRequestArg(key);
if (client == null) {
Logger.debug("Creating new ViPRSystemClient");
client = new ViPRSystemClient(getSysConfig()).withAuthToken(authToken);
setRequestArg(key, client);
} else {
Logger.debug("Returning cached ViPRSystemClient");
}
return client;
}
use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.
the class PasswordUtil method validatePassword.
/**
* Validates a password using the ViPR api call.
*
* @param plaintext password to validate
* @return If validation passes, returns an empty string. If validation fails, returns the validation error message.
*/
public static String validatePassword(String value) {
ViPRSystemClient client = BourneUtil.getSysClient();
try {
String decrypted = decryptedValue(value);
client.password().validate(decrypted);
} 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;
}
use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.
the class TaskUtils method getTaskLogs.
public static List<LogMessage> getTaskLogs(TaskResourceRep task) {
if (task == null) {
return null;
}
ViPRSystemClient systemClient = BourneUtil.getSysClient();
List<String> nodeIds = Lists.newArrayList();
List<NodeHealth> nodeHealthList = systemClient.health().getHealth().getNodeHealthList();
if (nodeHealthList != null) {
for (NodeHealth nodeHealth : nodeHealthList) {
if (nodeHealth != null) {
nodeIds.add(nodeHealth.getNodeId());
}
}
}
String start = null;
if (task.getStartTime() != null) {
start = Long.toString(task.getStartTime().getTimeInMillis());
}
String end = null;
if (task.getEndTime() != null) {
end = Long.toString(task.getEndTime().getTimeInMillis());
}
String regex = "(?i).*" + task.getOpId() + ".*";
final List<LogMessage> logMessages = Lists.newArrayList();
LogMessageProcessor processor = new LogMessageProcessor() {
@Override
public void processItem(LogMessage logMessage) throws Exception {
logMessages.add(logMessage);
}
};
systemClient.logs().getAsItems(processor, nodeIds, null, LOG_NAMES, LOG_SEVERITY, start, end, regex, LOGS_MAX_COUNT);
return logMessages;
}
use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.
the class DisasterRecoveryServiceTest method mockViPRSystemClient.
protected ViPRSystemClient mockViPRSystemClient(final String version) {
class MockViPRSystemClient extends ViPRSystemClient {
// .upgrade().getTargetVersion().getTargetVersion()
@Override
public com.emc.vipr.client.system.Upgrade upgrade() {
com.emc.vipr.client.system.Upgrade upgrade = mock(com.emc.vipr.client.system.Upgrade.class);
TargetVersionResponse targetVersionResponse = new TargetVersionResponse(version);
doReturn(targetVersionResponse).when(upgrade).getTargetVersion();
return upgrade;
}
}
return new MockViPRSystemClient();
}
use of com.emc.vipr.client.ViPRSystemClient in project coprhd-controller by CoprHD.
the class SystemHealth method systemHealth.
public static void systemHealth() {
final ViPRSystemClient client = BourneUtil.getSysClient();
List<NodeHealth> nodeHealthList = MonitorUtils.getNodeHealth(client);
Map<String, Integer> statusCount = Maps.newHashMap();
// Initialize Map so with a "Good" status to have 0 services so when we display, if no other service is "Good" it will still display
// that in UI.
statusCount.put(Status.GOOD.toString(), 0);
for (NodeHealth nodeHealth : nodeHealthList) {
Integer count = statusCount.get(nodeHealth.getStatus());
statusCount.put(nodeHealth.getStatus(), (count == null) ? 1 : ++count);
}
renderArgs.put("allServices", getAllServiceNames(nodeHealthList));
angularRenderArgs().put("clusterInfo", AdminDashboardUtils.getClusterInfo());
renderArgs.put("dataTable", new NodesDataTable());
angularRenderArgs().put("nodeCount", nodeHealthList.size());
angularRenderArgs().put("statusCount", statusCount);
render();
}
Aggregations