Search in sources :

Example 6 with VNXeHostInitiator

use of com.emc.storageos.vnxe.models.VNXeHostInitiator in project coprhd-controller by CoprHD.

the class VNXeApiClient method deleteInitiators.

/**
 * Delete initiators by moving initiators to a dummy host, then delete the dummy host
 *
 * This should be used if there is mapped resource on the host that the initiators are registered to.
 * It can also be used in case of no mapped resource.
 *
 * @param initiatorIds initiator Ids (IQN or WWN)
 * @return VNXeCommandResult
 */
public VNXeCommandResult deleteInitiators(List<String> initiatorIds) throws VNXeException {
    _logger.info("deleting initiators: " + Joiner.on(',').join(initiatorIds));
    // create a dummy host
    HostListRequest hostListReq = new HostListRequest(_khClient);
    HostCreateParam hostCreateParm = new HostCreateParam();
    hostCreateParm.setName(VIPR_TMP_HOST_PREFIX + initiatorIds.get(0));
    hostCreateParm.setType(HostTypeEnum.HOSTMANUAL.getValue());
    VNXeCommandResult result = hostListReq.createHost(hostCreateParm);
    String dummyHostId = result.getId();
    // get initiators
    for (String initiatorId : initiatorIds) {
        VNXeHostInitiator initiator = getInitiatorByWWN(initiatorId);
        if (initiator == null) {
            _logger.info("Could not find initiator: {}", initiatorId);
        } else {
            // move the initiator to the dummy host
            setInitiatorHost(initiator.getId(), dummyHostId);
        }
    }
    // delete the dummy host
    return deleteHost(dummyHostId);
}
Also used : HostListRequest(com.emc.storageos.vnxe.requests.HostListRequest) HostCreateParam(com.emc.storageos.vnxe.models.HostCreateParam) VNXeCommandResult(com.emc.storageos.vnxe.models.VNXeCommandResult) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator)

Example 7 with VNXeHostInitiator

use of com.emc.storageos.vnxe.models.VNXeHostInitiator in project coprhd-controller by CoprHD.

the class DeleteHostInitiatorRequest method deleteInitiator.

public VNXeCommandResult deleteInitiator(String initiatorId) throws VNXeException {
    logger.info("deleting initiator: {}", initiatorId);
    HostInitiatorRequest hostInitiatorRequest = new HostInitiatorRequest(_client);
    VNXeHostInitiator initiator = hostInitiatorRequest.getByIQNorWWN(initiatorId);
    if (initiator == null) {
        logger.info("Could not find initiator: {}", initiatorId);
        return null;
    }
    return deleteHostInitiatorSync(initiator.getId());
}
Also used : VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator)

Example 8 with VNXeHostInitiator

use of com.emc.storageos.vnxe.models.VNXeHostInitiator in project coprhd-controller by CoprHD.

the class HostInitiatorRequest method getByIQNorWWN.

public VNXeHostInitiator getByIQNorWWN(String initiatorId) {
    _url = URL_ALL;
    String filter = null;
    if (_client.isUnity()) {
        filter = VNXeConstants.INITIATORID_FILTER + "\"" + initiatorId + "\"";
    } else {
        filter = VNXeConstants.INITIATORID_FILTER + initiatorId;
    }
    setFilter(filter);
    VNXeHostInitiator result = null;
    List<VNXeHostInitiator> initList = getDataForObjects(VNXeHostInitiator.class);
    // it should just return 1
    if (initList != null && !initList.isEmpty()) {
        result = initList.get(0);
    } else {
        _logger.info("No HostInitiator found using iqn: {}", initiatorId);
    }
    return result;
}
Also used : VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator)

Example 9 with VNXeHostInitiator

use of com.emc.storageos.vnxe.models.VNXeHostInitiator in project coprhd-controller by CoprHD.

the class ApiClientTest method exportLun.

// @Test
public void exportLun() {
    String lunId = "sv_1";
    VNXeHostInitiator init = new VNXeHostInitiator();
    init.setChapUserName("iqn.1998-01.com.vmware:lgly6193-7ae20d76");
    init.setType(HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI);
    init.setName("lgly6193.lss.emc.com");
    List<VNXeHostInitiator> inits = new ArrayList<VNXeHostInitiator>();
    inits.add(init);
    VNXeBase vnxehost = apiClient.prepareHostsForExport(inits);
    VNXeExportResult result = apiClient.exportLun(vnxehost, lunId, null);
    System.out.println(result.getHlu());
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) ArrayList(java.util.ArrayList) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) VNXeExportResult(com.emc.storageos.vnxe.models.VNXeExportResult)

Example 10 with VNXeHostInitiator

use of com.emc.storageos.vnxe.models.VNXeHostInitiator in project coprhd-controller by CoprHD.

the class ApiClientTest method unexportLun.

// @Test
public void unexportLun() {
    String lunId = "sv_26";
    VNXeHostInitiator init = new VNXeHostInitiator();
    init.setChapUserName("iqn.1998-01.com.vmware:lgly6193-7ae20d76");
    init.setType(HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI);
    init.setName("lgly6193.lss.emc.com");
    List<VNXeHostInitiator> inits = new ArrayList<VNXeHostInitiator>();
    inits.add(init);
    VNXeBase vnxehost = apiClient.prepareHostsForExport(inits);
    apiClient.unexportLun(vnxehost.getId(), lunId);
}
Also used : VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) ArrayList(java.util.ArrayList) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator)

Aggregations

VNXeHostInitiator (com.emc.storageos.vnxe.models.VNXeHostInitiator)22 Initiator (com.emc.storageos.db.client.model.Initiator)13 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 URI (java.net.URI)9 ArrayList (java.util.ArrayList)8 HashSet (java.util.HashSet)8 ExportMask (com.emc.storageos.db.client.model.ExportMask)7 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)7 VNXeException (com.emc.storageos.vnxe.VNXeException)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)5 ExportOperationContext (com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext)5 VNXeHost (com.emc.storageos.vnxe.models.VNXeHost)4 HashMap (java.util.HashMap)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 HostLun (com.emc.storageos.vnxe.models.HostLun)3 VNXeExportResult (com.emc.storageos.vnxe.models.VNXeExportResult)3