Search in sources :

Example 6 with ViPRSystemClient

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

the class PasswordUtil method getPasswordValidPromptRules.

public static String getPasswordValidPromptRules(String[][] PASSWORD_VALID_PROMPT) {
    // NOSONAR
    // ("Suppressing Sonar violation of Field name should comply with naming convention")
    ViPRSystemClient client = BourneUtil.getSysClient();
    List<String> promptRules = new ArrayList<String>();
    StringBuilder promptString = new StringBuilder();
    Map<String, String> properties = client.config().getProperties().getProperties();
    for (int i = 0; i < PASSWORD_VALID_PROMPT.length; i++) {
        String key = PASSWORD_VALID_PROMPT[i][0];
        String value = properties.get(key);
        if (NumberUtils.toInt(value) != 0) {
            promptRules.add(MessageFormat.format(PASSWORD_VALID_PROMPT[i][1], value));
        }
    }
    promptString.append("<p>Password Validation Rules:</p>");
    promptString.append("<ul>");
    for (String item : promptRules) {
        promptString.append("<li>").append(item).append("</li>");
    }
    promptString.append("</ul>");
    return promptString.toString();
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ArrayList(java.util.ArrayList)

Example 7 with ViPRSystemClient

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

the class SystemHealth method nodeRecoveryVapp.

public static void nodeRecoveryVapp() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    if (recoveryStatus.getStartTime() != null) {
        DateTime startTime = new DateTime(recoveryStatus.getStartTime().getTime());
        renderArgs.put("startTime", startTime);
    }
    if (recoveryStatus.getEndTime() != null) {
        DateTime endTime = new DateTime(recoveryStatus.getEndTime().getTime());
        renderArgs.put("endTime", endTime);
    }
    RecoveryPrecheckStatus recoveryPrecheckStatus = client.control().getRecoveryPrecheckStatus();
    String precheckMsg = "";
    switch(recoveryPrecheckStatus.getStatus()) {
        case RECOVERY_NEEDED:
            precheckMsg = Messages.get("nodeRecovery.precheck.success", recoveryPrecheckStatus.getRecoverables().toString());
            break;
        case ALL_GOOD:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.allgood");
            break;
        case VAPP_IN_DR_OR_GEO:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.drorgeo");
            break;
        case NODE_UNREACHABLE:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.unreachable");
            break;
        case CORRUPTED_NODE_COUNT_MORE_THAN_QUORUM:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.quorum");
            break;
        case CORRUPTED_NODE_FOR_OTHER_REASON:
            precheckMsg = Messages.get("nodeRecovery.precheck.fail.other");
            break;
    }
    renderArgs.put("precheckMsg", precheckMsg);
    renderArgs.put("precheckStatus", recoveryPrecheckStatus.getStatus().name());
    String recoveringMsg = Messages.get("nodeRecovery.recovering.status", recoveryPrecheckStatus.getRecoverables().toString());
    renderArgs.put("recoveringMsg", recoveringMsg);
    ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
    render(recoveryStatus, clusterInfo);
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RecoveryPrecheckStatus(com.emc.vipr.model.sys.recovery.RecoveryPrecheckStatus) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) DateTime(org.joda.time.DateTime)

Example 8 with ViPRSystemClient

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

the class SystemHealth method getRecoveryStatus.

@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void getRecoveryStatus() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    JsonElement jsonElement = new Gson().toJsonTree(recoveryStatus);
    JsonObject jsonObj = jsonElement.getAsJsonObject();
    if (recoveryStatus.getStartTime() != null) {
        DateTime startTime = new DateTime(recoveryStatus.getStartTime().getTime());
        jsonObj.addProperty("startTime", startTime.toString());
    }
    if (recoveryStatus.getEndTime() != null) {
        DateTime endTime = new DateTime(recoveryStatus.getEndTime().getTime());
        jsonObj.addProperty("endTime", endTime.toString());
    }
    renderJSON(jsonObj.toString());
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) JsonElement(com.google.gson.JsonElement) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) DateTime(org.joda.time.DateTime) Restrictions(controllers.deadbolt.Restrictions)

Example 9 with ViPRSystemClient

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

the class SystemHealth method nodeRecovery.

public static void nodeRecovery() {
    ViPRSystemClient client = BourneUtil.getSysClient();
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    if (recoveryStatus.getStartTime() != null) {
        DateTime startTime = new DateTime(recoveryStatus.getStartTime().getTime());
        renderArgs.put("startTime", startTime);
    }
    if (recoveryStatus.getEndTime() != null) {
        DateTime endTime = new DateTime(recoveryStatus.getEndTime().getTime());
        renderArgs.put("endTime", endTime);
    }
    ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
    render(recoveryStatus, clusterInfo);
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) RecoveryStatus(com.emc.vipr.model.sys.recovery.RecoveryStatus) DateTime(org.joda.time.DateTime)

Example 10 with ViPRSystemClient

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

the class LocalUserMode method setupLocalUserModeBaseClass.

@BeforeClass
public static synchronized void setupLocalUserModeBaseClass() throws Exception {
    // get the Bourne IP from parameter
    String param_IP = System.getProperty("APP_HOST_NAMES");
    if (param_IP != null) {
        controllerNodeEndpoint = param_IP;
    } else {
        Properties properties = new Properties();
        properties.load(ClassLoader.class.getResourceAsStream("/test-env.conf"));
        controllerNodeEndpoint = properties.getProperty("APP_HOST_NAMES");
    }
    logger.info("Controller node endpoint: " + controllerNodeEndpoint);
    systemClient = new ViPRSystemClient(controllerNodeEndpoint, true).withLogin("root", rootPassword);
    coreClient = new ViPRCoreClient(controllerNodeEndpoint, true).withLogin("root", rootPassword);
    waitForClusterStable();
    PropertyInfoRestRep propertyInfoRestRep = systemClient.config().getProperties();
    String viprDataIps = propertyInfoRestRep.getProperty("system_datanode_ipaddrs");
    if (viprDataIps != null) {
        dataNodeEndpoint = viprDataIps.split(",")[0];
    }
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) Properties(java.util.Properties) BeforeClass(org.junit.BeforeClass)

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