Search in sources :

Example 1 with SystemCommandResult

use of com.emc.storageos.hp3par.command.SystemCommandResult in project coprhd-controller by CoprHD.

the class HP3PARStorageDriver method discoverStorageSystem.

/**
 * Get storage system information and capabilities
 */
@Override
public DriverTask discoverStorageSystem(StorageSystem storageSystem) {
    DriverTask task = createDriverTask(HP3PARConstants.TASK_TYPE_DISCOVER_STORAGE_SYSTEM);
    try {
        _log.info("3PARDriver:discoverStorageSystem information for storage system {}, name {} - start", storageSystem.getIpAddress(), storageSystem.getSystemName());
        URI deviceURI = new URI("https", null, storageSystem.getIpAddress(), storageSystem.getPortNumber(), "/", null, null);
        // remove '/' as lock fails with this name
        String uniqueId = deviceURI.toString();
        uniqueId = uniqueId.replace("/", "");
        HP3PARApi hp3parApi = hp3parUtil.getHP3PARDevice(storageSystem);
        String authToken = hp3parApi.getAuthToken(storageSystem.getUsername(), storageSystem.getPassword());
        if (authToken == null) {
            throw new HP3PARException("Could not get authentication token");
        }
        // Verify user role
        hp3parApi.verifyUserRole(storageSystem.getUsername());
        // get storage details
        SystemCommandResult systemRes = hp3parApi.getSystemDetails();
        storageSystem.setSerialNumber(systemRes.getSerialNumber());
        storageSystem.setMajorVersion(systemRes.getSystemVersion());
        // as there is no individual portion in 3par api
        storageSystem.setMinorVersion("0");
        // protocols supported
        List<String> protocols = new ArrayList<String>();
        protocols.add(Protocols.iSCSI.toString());
        protocols.add(Protocols.FC.toString());
        storageSystem.setProtocols(protocols);
        storageSystem.setFirmwareVersion(systemRes.getSystemVersion());
        if (systemRes.getSystemVersion().startsWith("3.1") || systemRes.getSystemVersion().startsWith("3.2.1")) {
            // SDK is taking care of unsupported message
            storageSystem.setIsSupportedVersion(false);
        } else {
            storageSystem.setIsSupportedVersion(true);
        }
        storageSystem.setModel(systemRes.getModel());
        storageSystem.setProvisioningType(SupportedProvisioningType.THIN_AND_THICK);
        Set<StorageSystem.SupportedReplication> supportedReplications = new HashSet<>();
        supportedReplications.add(StorageSystem.SupportedReplication.elementReplica);
        supportedReplications.add(StorageSystem.SupportedReplication.groupReplica);
        storageSystem.setSupportedReplications(supportedReplications);
        // Storage object properties
        storageSystem.setNativeId(uniqueId + ":" + systemRes.getSerialNumber());
        if (storageSystem.getDeviceLabel() == null) {
            if (storageSystem.getDisplayName() != null) {
                storageSystem.setDeviceLabel(storageSystem.getDisplayName());
            } else if (systemRes.getName() != null) {
                storageSystem.setDeviceLabel(systemRes.getName());
                storageSystem.setDisplayName(systemRes.getName());
            }
        }
        storageSystem.setAccessStatus(AccessStatus.READ_WRITE);
        setConnInfoToRegistry(storageSystem.getNativeId(), storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword());
        task.setStatus(DriverTask.TaskStatus.READY);
        _log.info("3PARDriver: Successfull discovery storage system {}, name {} - end", storageSystem.getIpAddress(), storageSystem.getSystemName());
    } catch (Exception e) {
        String msg = String.format("3PARDriver: Unable to discover the storage system %s ip %s; Error: %s.\n", storageSystem.getSystemName(), storageSystem.getIpAddress(), e);
        _log.error(msg);
        _log.error(CompleteError.getStackTrace(e));
        task.setMessage(msg);
        task.setStatus(DriverTask.TaskStatus.FAILED);
        e.printStackTrace();
    }
    return task;
}
Also used : DriverTask(com.emc.storageos.storagedriver.DriverTask) ArrayList(java.util.ArrayList) SystemCommandResult(com.emc.storageos.hp3par.command.SystemCommandResult) URI(java.net.URI) HashSet(java.util.HashSet)

Example 2 with SystemCommandResult

use of com.emc.storageos.hp3par.command.SystemCommandResult in project coprhd-controller by CoprHD.

the class HP3PARApiFactory method main.

// Sample direct program
public static void main(String[] args) {
    System.out.println("starting HP3PAR main");
    try {
        URI uri = URI.create(String.format("https://xxxxx:8080/api/v1/credentials"));
        HP3PARApiFactory factory = new HP3PARApiFactory();
        factory.setConnectionTimeoutMs(30000 * 4);
        factory.setConnManagerTimeout(60000 * 4);
        factory.setSocketConnectionTimeoutMs(7200000 * 4);
        BasicConfigurator.configure();
        factory.init();
        HP3PARApi hp3parApi = factory.getRESTClient(uri, "xxx", "xxxx");
        String authToken = hp3parApi.getAuthToken("xxxx", "xxxx");
        System.out.println(authToken);
        hp3parApi.verifyUserRole("test2");
        SystemCommandResult sysRes = hp3parApi.getSystemDetails();
        System.out.println(sysRes.toString());
        CPGCommandResult cpgRes = hp3parApi.getAllCPGDetails();
        System.out.println(cpgRes.toString());
        hp3parApi.getPortDetails();
        PortStatisticsCommandResult portStatRes = hp3parApi.getPortStatisticsDetail();
        HostSetDetailsCommandResult hostsetRes = hp3parApi.getHostSetDetails("Cluster2021");
        boolean present = false;
        for (int index = 0; index < hostsetRes.getSetmembers().size(); index++) {
            if ("myhost1".compareTo(hostsetRes.getSetmembers().get(index)) == 0) {
                present = true;
                break;
            }
        }
        if (present == false) {
            // update cluster with this host
            hp3parApi.updateHostSet("Cluster2021", "host1");
        }
    } catch (Exception e) {
        System.out.println("EROR");
        System.out.println(e);
        System.out.println(CompleteError.getStackTrace(e));
        e.printStackTrace();
    }
}
Also used : HostSetDetailsCommandResult(com.emc.storageos.hp3par.command.HostSetDetailsCommandResult) CPGCommandResult(com.emc.storageos.hp3par.command.CPGCommandResult) SystemCommandResult(com.emc.storageos.hp3par.command.SystemCommandResult) HP3PARApi(com.emc.storageos.hp3par.impl.HP3PARApi) URI(java.net.URI) PortStatisticsCommandResult(com.emc.storageos.hp3par.command.PortStatisticsCommandResult) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Example 3 with SystemCommandResult

use of com.emc.storageos.hp3par.command.SystemCommandResult in project coprhd-controller by CoprHD.

the class HP3PARApi method getSystemDetails.

/**
 * Gets the storage array information
 * @return array details
 * @throws Exception
 */
public SystemCommandResult getSystemDetails() throws Exception {
    _log.info("3PARDriver:getSystemDetails enter");
    ClientResponse clientResp = null;
    try {
        clientResp = get(URI_SYSTEM);
        if (clientResp == null) {
            _log.error("3PARDriver:There is no response from 3PAR");
            throw new HP3PARException("There is no response from 3PAR");
        } else if (clientResp.getStatus() != 200) {
            String errResp = getResponseDetails(clientResp);
            throw new HP3PARException(errResp);
        } else {
            String responseString = clientResp.getEntity(String.class);
            _log.info("3PARDriver:getSystemDetails 3PAR response is {}", responseString);
            SystemCommandResult systemRes = new Gson().fromJson(sanitize(responseString), SystemCommandResult.class);
            return systemRes;
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (clientResp != null) {
            clientResp.close();
        }
        _log.info("3PARDriver:getSystemDetails leave");
    }
// end try/catch/finally
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) SystemCommandResult(com.emc.storageos.hp3par.command.SystemCommandResult) Gson(com.google.gson.Gson)

Aggregations

SystemCommandResult (com.emc.storageos.hp3par.command.SystemCommandResult)3 URI (java.net.URI)2 CPGCommandResult (com.emc.storageos.hp3par.command.CPGCommandResult)1 HostSetDetailsCommandResult (com.emc.storageos.hp3par.command.HostSetDetailsCommandResult)1 PortStatisticsCommandResult (com.emc.storageos.hp3par.command.PortStatisticsCommandResult)1 HP3PARApi (com.emc.storageos.hp3par.impl.HP3PARApi)1 HP3PARException (com.emc.storageos.hp3par.impl.HP3PARException)1 DriverTask (com.emc.storageos.storagedriver.DriverTask)1 Gson (com.google.gson.Gson)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1