Search in sources :

Example 11 with ViPRSystemClient

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;
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient)

Example 12 with ViPRSystemClient

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;
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 13 with ViPRSystemClient

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;
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) LogMessageProcessor(com.emc.vipr.client.system.LogMessageProcessor) LogMessage(com.emc.vipr.model.sys.logging.LogMessage) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth)

Example 14 with ViPRSystemClient

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();
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) TargetVersionResponse(com.emc.vipr.model.sys.TargetVersionResponse)

Example 15 with ViPRSystemClient

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();
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) NodesDataTable(models.datatable.NodesDataTable) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth)

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