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);
}
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());
}
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;
}
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());
}
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);
}
Aggregations