Search in sources :

Example 16 with ClusterInfo

use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.

the class UpgradeService method wakeupManager.

/**
 * *Internal API, used only between nodes*
 * <p>
 * Wake up node
 *
 * @return Cluster state information.
 */
@POST
@Path("internal/wakeup/")
public Response wakeupManager(@QueryParam("type") String managerType) {
    if (managerType == null) {
        managerType = "all";
    }
    switch(managerType) {
        case "upgrade":
            _upgradeManager.wakeup();
            break;
        case "secrets":
            _secretsManager.wakeup();
            break;
        case "property":
            _propertyManager.wakeup();
            break;
        case "vdc":
            _vdcManager.wakeup();
            break;
        default:
            _upgradeManager.wakeup();
            _secretsManager.wakeup();
            _propertyManager.wakeup();
            _vdcManager.wakeup();
    }
    ClusterInfo clusterInfo = _coordinator.getClusterInfo();
    if (clusterInfo == null) {
        throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster info");
    }
    _log.debug("Successfully woke up {} manager(s)", managerType);
    return toClusterResponse(clusterInfo);
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 17 with ClusterInfo

use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.

the class ConfigService method updatePropertiesCommon.

/**
 * Common method called by setProps and resetProps
 * Callers should prepare valid updateProps and deleteProps,
 * by verifying against validateAndUpdateProperties
 * before call this method
 *
 * @param updateProps update properties' keys and values
 * @param deleteKeys delete properties' keys
 * @throws Exception
 * @throws CoordinatorClientException
 */
private Response updatePropertiesCommon(PropertyInfoRestRep updateProps, List<String> deleteKeys) throws Exception {
    // validate
    if (!_coordinator.isClusterUpgradable()) {
        throw APIException.serviceUnavailable.clusterStateNotStable();
    }
    StringBuilder propChanges = new StringBuilder();
    // get current property set
    PropertyInfoRestRep oldProps = new PropertyInfoRestRep();
    oldProps.addProperties(getTargetPropsCommon().getAllProperties());
    boolean doSetTarget = false;
    PropertyInfoRestRep currentProps = _coordinator.getTargetProperties();
    // remove properties
    if (deleteKeys != null && !deleteKeys.isEmpty()) {
        doSetTarget = true;
        for (String key : deleteKeys) {
            currentProps.removeProperty(key);
            propChanges.append(key);
            propChanges.append(" deleted");
        }
        currentProps.removeProperties(deleteKeys);
    }
    // update properties, increment config_version
    if (updateProps != null && !updateProps.isEmpty()) {
        doSetTarget = true;
        currentProps.addProperties(updateProps.getAllProperties());
        String configVersion = System.currentTimeMillis() + "";
        currentProps.addProperty(PropertyInfoRestRep.CONFIG_VERSION, configVersion);
        if (propChanges.length() > 0) {
            propChanges.append(",");
        }
        propChanges.append(PropertyInfoRestRep.CONFIG_VERSION);
        propChanges.append("=");
        propChanges.append(configVersion);
    }
    if (doSetTarget) {
        // perform before handlers
        _propertyHandlers.before(oldProps, currentProps);
        _coordinator.setTargetProperties(currentProps.getAllProperties());
        for (Map.Entry<String, String> entry : updateProps.getAllProperties().entrySet()) {
            if (propChanges.length() > 0) {
                propChanges.append(",");
            }
            propChanges.append(entry.getKey());
            propChanges.append("=");
            // Hide encrypted string in audit log
            if (PropertyInfoExt.isEncryptedProperty(entry.getKey())) {
                propChanges.append(HIDDEN_TEXT_MASK);
            } else {
                propChanges.append(entry.getValue());
            }
        }
        auditConfig(OperationTypeEnum.UPDATE_SYSTEM_PROPERTY, AuditLogManager.AUDITLOG_SUCCESS, null, propChanges.toString());
        // perform after handlers
        _propertyHandlers.after(oldProps, currentProps);
    }
    ClusterInfo clusterInfo = _coordinator.getClusterInfo();
    if (clusterInfo == null) {
        throw APIException.internalServerErrors.targetIsNullOrEmpty("Cluster information");
    }
    return toClusterResponse(clusterInfo);
}
Also used : PropertyInfoRestRep(com.emc.storageos.model.property.PropertyInfoRestRep) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 18 with ClusterInfo

use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.

the class SystemHealth method logs.

public static void logs() {
    List<NodeHealth> nodeHealthList = MonitorUtils.getNodeHealth();
    ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
    renderArgs.put("severities", SEVERITIES);
    if (DisasterRecoveryUtils.isActiveSite()) {
        renderArgs.put("orderTypes", ORDER_TYPES);
    }
    Set<String> controlServiceNames = getControlServiceNames(nodeHealthList, clusterInfo);
    renderArgs.put("controlServices", controlServiceNames);
    Set<String> allServiceNames = getAllServiceNames(nodeHealthList);
    renderArgs.put("allServices", allServiceNames);
    List<NodeHealth> controlNodes = getControlNodes(nodeHealthList, clusterInfo);
    renderArgs.put("controlNodes", controlNodes);
    DateTime defaultStartTime = new DateTime().minusMinutes(15);
    // Remove some logs from the default list
    Set<String> defaultServiceNames = Sets.newHashSet(allServiceNames);
    defaultServiceNames.remove(SystemLogUtils.MESSAGES_LOG);
    defaultServiceNames.remove(SystemLogUtils.NGINX_ACCESS_LOG);
    defaultServiceNames.remove(SystemLogUtils.NGINX_ERROR_LOG);
    renderArgs.put("allDiagnosticOptions", getDiagnosticOptions());
    renderArgs.put("defaultDiagnosticOptions", getDefaultDiagnosticOptions().values());
    loadSystemLogArgument(PARAM_NODE_ID, null);
    loadSystemLogArgument(PARAM_SERVICE, defaultServiceNames, String[].class);
    loadSystemLogArgument(PARAM_SEVERITY, DEFAULT_SEVERITY);
    loadSystemLogArgument(PARAM_SEARCH_MESSAGE, null);
    loadSystemLogArgument(PARAM_START_TIME, defaultStartTime.getMillis(), Long.class);
    Common.copyRenderArgsToAngular();
    render();
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) DateTime(org.joda.time.DateTime) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth)

Example 19 with ClusterInfo

use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.

the class SystemHealth method minorityNodeRecovery.

@Restrictions({ @Restrict("SYSTEM_ADMIN"), @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void minorityNodeRecovery() {
    new MinorityNodeRecoveryJob(getSysClient()).in(3);
    ViPRSystemClient client = BourneUtil.getSysClient();
    List<NodeHealth> nodeHealthList = MonitorUtils.getNodeHealth();
    ClusterInfo clusterInfo = AdminDashboardUtils.getClusterInfo();
    if (PlatformUtils.isVMwareVapp()) {
        RecoveryPrecheckStatus recoveryPrecheckStatus = client.control().getRecoveryPrecheckStatus();
        String recoveringMsg = Messages.get("nodeRecovery.recovering.status", recoveryPrecheckStatus.getRecoverables().toString());
        renderArgs.put("recoveringMsg", recoveringMsg);
    }
    RecoveryStatus recoveryStatus = client.control().getRecoveryStatus();
    renderArgs.put("nodeHealthList", nodeHealthList);
    renderArgs.put("clusterInfo", clusterInfo);
    renderArgs.put("recoveryStatus", recoveryStatus);
    if (PlatformUtils.isVMwareVapp()) {
        render("@nodeRecoveryVapp");
    } else {
        render("@nodeRecovery");
    }
}
Also used : MinorityNodeRecoveryJob(jobs.MinorityNodeRecoveryJob) 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) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth) Restrictions(controllers.deadbolt.Restrictions)

Example 20 with ClusterInfo

use of com.emc.vipr.model.sys.ClusterInfo in project coprhd-controller by CoprHD.

the class Maintenance method clusterState.

public static void clusterState() {
    request.format = "json";
    ClusterInfo clusterInfo = null;
    try {
        clusterInfo = getClusterState();
        Logger.info("cluster status %s", clusterInfo.getCurrentState());
    } catch (ViPRHttpException e) {
        Common.handleExpiredToken(e);
        Logger.error(e, "Failed to get cluster state");
        error(e.getHttpCode(), e.getMessage());
    } catch (Exception e) {
        Logger.error(e, "Failed to get cluster state");
        error(e.getMessage());
    }
    renderJSON(clusterInfo);
}
Also used : ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Aggregations

ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)24 RepositoryInfo (com.emc.storageos.coordinator.client.model.RepositoryInfo)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)7 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)7 IOException (java.io.IOException)7 Path (javax.ws.rs.Path)7 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)5 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 ServiceUnavailableException (com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException)5 LocalRepositoryException (com.emc.storageos.systemservices.exceptions.LocalRepositoryException)5 RemoteRepositoryException (com.emc.storageos.systemservices.exceptions.RemoteRepositoryException)5 ArrayList (java.util.ArrayList)4 POST (javax.ws.rs.POST)4 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)3 RecoveryStatus (com.emc.vipr.model.sys.recovery.RecoveryStatus)3 Map (java.util.Map)3 Produces (javax.ws.rs.Produces)3 Service (com.emc.storageos.coordinator.common.Service)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)2