Search in sources :

Example 6 with SysClientException

use of com.emc.storageos.systemservices.exceptions.SysClientException in project coprhd-controller by CoprHD.

the class LicenseManagerImpl method getControllerCapacity.

/**
 * Gets capacity from controller.
 * List of returned resources include volume, file and free storage pool capacities.
 */
public ManagedResourcesCapacity getControllerCapacity() throws InternalServerErrorException {
    _log.info("Getting controller capacity");
    List<Service> services = _coordinator.locateAllServices(LicenseConstants.API_SVC_LOOKUP_KEY, LicenseConstants.SERVICE_LOOKUP_VERSION, null, null);
    for (Service service : services) {
        try {
            // service could be null, if so get next service.
            if (service != null) {
                return getClient(service).get(SysClientFactory._URI_PROVISIONING_MANAGED_CAPACITY, ManagedResourcesCapacity.class, null);
            }
        } catch (SysClientException exception) {
            _log.error("LicenseManager::getCapacity for Controller. Cannot connect to host: {}", service.getEndpoint().toString());
        }
    }
    // if capacity cannot be retrieved
    _log.error("Controller capacity could not be retrieved");
    throw APIException.internalServerErrors.getObjectError("controller capacity", null);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 7 with SysClientException

use of com.emc.storageos.systemservices.exceptions.SysClientException in project coprhd-controller by CoprHD.

the class InternalAlertsClient method getControllerSysClient.

/**
 * Returns client for active controller VMs syssvc instance.
 */
private SysClientFactory.SysClient getControllerSysClient() {
    List<Service> services = coordinatorClient.locateAllServices(SYS_SVC_LOOKUP_KEY, SERVICE_LOOKUP_VERSION, null, null);
    URI hostUri = null;
    for (Service service : services) {
        try {
            // service could be null, if so get next service.
            if (service != null && CONTROL_NODE_SYSSVC_ID_PATTERN.matcher(service.getId()).matches()) {
                _log.info("Using {} to send alert event", service.getId());
                hostUri = service.getEndpoint();
                String baseNodeURL = String.format(SysClientFactory.BASE_URL_FORMAT, hostUri.getHost(), hostUri.getPort());
                return SysClientFactory.getSysClient(URI.create(baseNodeURL));
            }
        } catch (SysClientException exception) {
            _log.error("InternalAlertsClient. Cannot connect to host: {}", hostUri != null ? hostUri.toString() : "");
        }
    }
    throw APIException.internalServerErrors.getObjectError("controller sysvsc instance", null);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException) URI(java.net.URI)

Example 8 with SysClientException

use of com.emc.storageos.systemservices.exceptions.SysClientException in project coprhd-controller by CoprHD.

the class NodeResourceAllocationChecker method getNodeHardwareInfo.

private NodeHardwareInfoRestRep getNodeHardwareInfo(String svcId) throws SysClientException {
    NodeHardwareInfoRestRep nodeHardwareInfoRestRep = null;
    try {
        _log.info("Get node: {} resp.", svcId);
        nodeHardwareInfoRestRep = SysClientFactory.getSysClient(_coordinator.getNodeEndpointForSvcId(svcId)).get(SysClientFactory.URI_GET_INTERNAL_NODE_HARDWARE, NodeHardwareInfoRestRep.class, null);
    } catch (SysClientException ex) {
        _log.error("Error get node hardware info with node: {} Cause: {}", svcId, ex.getMessage());
        throw ex;
    }
    return nodeHardwareInfoRestRep;
}
Also used : NodeHardwareInfoRestRep(com.emc.vipr.model.sys.healthmonitor.NodeHardwareInfoRestRep) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 9 with SysClientException

use of com.emc.storageos.systemservices.exceptions.SysClientException in project coprhd-controller by CoprHD.

the class NodeResourceAllocationChecker method getNodeResourceAllocationCheckResult.

public String getNodeResourceAllocationCheckResult() {
    try {
        final List<String> svcIds = _coordinator.getAllNodes();
        final String mySvcId = _coordinator.getMySvcId();
        NodeHardwareInfoRestRep myBaseRep = getNodeHardwareInfo(mySvcId);
        for (String svcId : svcIds) {
            if (!svcId.equals(mySvcId)) {
                NodeHardwareInfoRestRep compareRep = getNodeHardwareInfo(svcId);
                if (!check2NodesReourceAllocation(myBaseRep, compareRep)) {
                    return STATUS_IMBALANCE;
                }
            }
        }
        return STATUS_OK;
    } catch (SysClientException ex) {
        // Ignore exception
        return STATUS_IMBALANCE;
    }
}
Also used : NodeHardwareInfoRestRep(com.emc.vipr.model.sys.healthmonitor.NodeHardwareInfoRestRep) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Example 10 with SysClientException

use of com.emc.storageos.systemservices.exceptions.SysClientException in project coprhd-controller by CoprHD.

the class OpenSourceLicenseManagerImpl method getControllerCapacity.

/**
 * Gets capacity from controller.
 * List of returned resources include volume, file and free storage pool capacities.
 */
public ManagedResourcesCapacity getControllerCapacity() throws InternalServerErrorException {
    _log.info("Getting controller capacity");
    List<Service> services = _coordinator.locateAllServices(LicenseConstants.API_SVC_LOOKUP_KEY, LicenseConstants.SERVICE_LOOKUP_VERSION, null, null);
    for (Service service : services) {
        try {
            // service could be null, if so get next service.
            if (service != null) {
                return getClient(service).get(SysClientFactory._URI_PROVISIONING_MANAGED_CAPACITY, ManagedResourcesCapacity.class, null);
            }
        } catch (SysClientException exception) {
            _log.error("LicenseManager::getCapacity for Controller. Cannot connect to host: {}", service.getEndpoint().toString());
        }
    }
    // if capacity cannot be retrieved
    _log.error("Controller capacity could not be retrieved");
    throw APIException.internalServerErrors.getObjectError("controller capacity", null);
}
Also used : Service(com.emc.storageos.coordinator.common.Service) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Aggregations

SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)10 URI (java.net.URI)5 Service (com.emc.storageos.coordinator.common.Service)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 NodeHardwareInfoRestRep (com.emc.vipr.model.sys.healthmonitor.NodeHardwareInfoRestRep)2 POST (javax.ws.rs.POST)2 DbOfflineStatus (com.emc.vipr.model.sys.recovery.DbOfflineStatus)1 GET (javax.ws.rs.GET)1