Search in sources :

Example 1 with Initiator_Type

use of com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type in project coprhd-controller by CoprHD.

the class VPlexDeviceController method getVPlexInitiatorType.

/**
 * Gets the VPLEX initiator type for the passed initiator.
 *
 * @param initiator
 *            A reference to an initiator.
 *
 * @return The VPLEX initiator type.
 */
private String getVPlexInitiatorType(Initiator initiator) {
    Initiator_Type initiatorType = Initiator_Type.DEFAULT;
    URI initiatorHostURI = initiator.getHost();
    if (!NullColumnValueGetter.isNullURI(initiatorHostURI)) {
        Host initiatorHost = getDataObject(Host.class, initiatorHostURI, _dbClient);
        if (initiatorHost != null) {
            // registering an HPUX initiator in VPLEX.
            if (Host.HostType.HPUX.name().equals(initiatorHost.getType())) {
                initiatorType = Initiator_Type.HPUX;
            } else if ((Host.HostType.AIX.name().equals(initiatorHost.getType())) || (Host.HostType.AIXVIO.name().equals(initiatorHost.getType()))) {
                initiatorType = Initiator_Type.AIX;
            } else if (Host.HostType.SUNVCS.name().equals(initiatorHost.getType())) {
                initiatorType = Initiator_Type.SUN_VCS;
            }
        }
    }
    return initiatorType.getType();
}
Also used : Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) Host(com.emc.storageos.db.client.model.Host) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 2 with Initiator_Type

use of com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type in project coprhd-controller by CoprHD.

the class VPlexApiExportManager method findInitiatorsOnCluster.

/**
 * Tries to find initiators on the the passed cluster corresponding to the
 * passed port information.
 *
 * @param clusterName The name of the cluster.
 * @param initiatorsToFind The port information.
 *
 * @return A list of VPlexInitiatorInfo representing the found initiators.
 *
 * @throws VPlexApiException When an error occurs finding initiators on the
 *             cluster.
 */
private List<VPlexInitiatorInfo> findInitiatorsOnCluster(String clusterName, List<PortInfo> initiatorsToFind) throws VPlexApiException {
    List<VPlexInitiatorInfo> foundInitiators = new ArrayList<VPlexInitiatorInfo>();
    // Get the initiators on the passed cluster.
    VPlexApiDiscoveryManager discoveryMgr = _vplexApiClient.getDiscoveryManager();
    List<VPlexInitiatorInfo> clusterInitiatorInfoList = discoveryMgr.getInitiatorInfoForCluster(clusterName, false);
    // an initiator found on the cluster.
    for (PortInfo portInfo : initiatorsToFind) {
        String portWWN = portInfo.getPortWWN();
        for (VPlexInitiatorInfo clusterInitiatorInfo : clusterInitiatorInfoList) {
            // TBD: Check node WWNs as well? They are optional.
            if (portWWN.equals(clusterInitiatorInfo.getPortWwn())) {
                foundInitiators.add(clusterInitiatorInfo);
                // Make sure a registration name is set. If the caller
                // passed a specific port name, then it was or will be
                // registered with that name. Otherwise, we give it a
                // default name.
                String portName = portInfo.getName();
                if ((portName != null) && (portName.length() != 0)) {
                    clusterInitiatorInfo.setRegistrationName(portName);
                } else {
                    clusterInitiatorInfo.setRegistrationName(VPlexApiConstants.REGISTERED_INITIATOR_PREFIX + clusterInitiatorInfo.getPortWwnRaw());
                }
                // Also, if the caller passed an initiator type make sure
                // it is set so that it can be passed when the initiator
                // is registered.
                Initiator_Type initiatorType = Initiator_Type.valueOfType(portInfo.getType());
                if (initiatorType == null) {
                    s_logger.info("Initiator port type {} not found, using default", portInfo.getType());
                    initiatorType = Initiator_Type.DEFAULT;
                }
                clusterInitiatorInfo.setInitiatorType(initiatorType);
                break;
            }
        }
    }
    return foundInitiators;
}
Also used : PortInfo(com.emc.storageos.vplex.api.clientdata.PortInfo) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) ArrayList(java.util.ArrayList)

Example 3 with Initiator_Type

use of com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type in project coprhd-controller by CoprHD.

the class VPlexApiExportManager method registerInitiators.

/**
 * Register the passed initiators if they have yet to be registered.
 *
 * @param clusterInfo The cluster on which the initiators are registered.
 * @param initiatorInfoList The initiators to be registered.
 *
 * @throws VPlexApiException When an error occurs registering an initiator.
 */
void registerInitiators(VPlexClusterInfo clusterInfo, List<VPlexInitiatorInfo> initiatorInfoList) throws VPlexApiException {
    for (VPlexInitiatorInfo initiatorInfo : initiatorInfoList) {
        // UNREGISTERED- then the initiator is already registered.
        if (!initiatorInfo.getName().startsWith(VPlexApiConstants.UNREGISTERED_INITIATOR_PREFIX)) {
            continue;
        }
        String initiatorName = initiatorInfo.getName();
        s_logger.info("Registering initiator {}", initiatorName);
        ClientResponse response = null;
        try {
            // Build the value for the port argument for the request.
            StringBuilder argBuilder = new StringBuilder();
            argBuilder.append(initiatorInfo.getPortWwnRaw());
            String nodeWWN = initiatorInfo.getNodeWwnRaw();
            String portWWN = initiatorInfo.getPortWwnRaw();
            if ((nodeWWN != null) && (nodeWWN.length() != 0)) {
                argBuilder.append(VPlexApiConstants.INITIATOR_REG_DELIM);
                argBuilder.append(nodeWWN);
            }
            // Build the register initiator request and make the request.
            URI requestURI = _vplexApiClient.getBaseURI().resolve(VPlexApiConstants.URI_REGISTER_INITIATOR);
            s_logger.info("Register initiator URI is {}", requestURI.toString());
            Map<String, String> argsMap = new HashMap<String, String>();
            argsMap.put(VPlexApiConstants.ARG_DASH_I, initiatorInfo.getRegistrationName());
            argsMap.put(VPlexApiConstants.ARG_DASH_P, argBuilder.toString());
            argsMap.put(VPlexApiConstants.ARG_DASH_C, clusterInfo.getPath());
            if (isRecoverPointInitiator(portWWN)) {
                argsMap.put(VPlexApiConstants.ARG_DASH_T, "recoverpoint");
            }
            Initiator_Type initiatorType = initiatorInfo.getInitiatorType();
            if (initiatorType != Initiator_Type.DEFAULT) {
                argsMap.put(VPlexApiConstants.ARG_DASH_T, initiatorType.getType());
            }
            JSONObject postDataObject = VPlexApiUtils.createPostData(argsMap, false);
            s_logger.info("Register initiator POST data is {}", postDataObject.toString());
            response = _vplexApiClient.post(requestURI, postDataObject.toString());
            String responseStr = response.getEntity(String.class);
            s_logger.info("Register initiator response is {}", responseStr);
            if (response.getStatus() != VPlexApiConstants.SUCCESS_STATUS) {
                if (response.getStatus() == VPlexApiConstants.ASYNC_STATUS) {
                    s_logger.info("Initiator registration completing asynchronously");
                    _vplexApiClient.waitForCompletion(response);
                } else {
                    String cause = VPlexApiUtils.getCauseOfFailureFromResponse(responseStr);
                    throw VPlexApiException.exceptions.registerInitiatorFailureStatus(initiatorName, String.valueOf(response.getStatus()), cause);
                }
            }
            // Update the initiator info to reflect the registration name
            // for the initiator.
            initiatorInfo.updateOnRegistration();
            s_logger.info(String.format("Successfully registered initiator %s", initiatorInfo.getName()));
        } catch (VPlexApiException vae) {
            throw vae;
        } catch (Exception e) {
            throw VPlexApiException.exceptions.failedRegisterInitiator(initiatorName, e);
        } finally {
            if (response != null) {
                response.close();
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) JSONObject(org.codehaus.jettison.json.JSONObject) HashMap(java.util.HashMap) Initiator_Type(com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type) URI(java.net.URI)

Aggregations

Initiator_Type (com.emc.storageos.vplex.api.VPlexInitiatorInfo.Initiator_Type)3 URI (java.net.URI)2 Host (com.emc.storageos.db.client.model.Host)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 PortInfo (com.emc.storageos.vplex.api.clientdata.PortInfo)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JSONObject (org.codehaus.jettison.json.JSONObject)1