use of com.emc.storageos.vnxe.requests.HostInitiatorRequest in project coprhd-controller by CoprHD.
the class VNXeApiClient method setInitiatorHost.
/**
* Modify initiator's parent host
*
* @param initiatorId initiator Id
* @param hostId host Id
*/
public void setInitiatorHost(String initiatorId, String hostId) {
HostInitiatorModifyParam initModifyParam = new HostInitiatorModifyParam();
VNXeBase host = new VNXeBase(hostId);
initModifyParam.setHost(host);
HostInitiatorRequest req = new HostInitiatorRequest(_khClient);
req.modifyHostInitiator(initModifyParam, initiatorId);
}
use of com.emc.storageos.vnxe.requests.HostInitiatorRequest in project coprhd-controller by CoprHD.
the class VNXeApiClient method prepareHostsForExport.
/**
* given host name and initiators, find/create hosts/initiators in the
*
* @param hostInitiators
* @return
*/
public VNXeBase prepareHostsForExport(Collection<VNXeHostInitiator> hostInitiators) throws VNXeException {
String hostId = null;
Set<VNXeHostInitiator> notExistingInits = new HashSet<VNXeHostInitiator>();
Set<VNXeHostInitiator> existingNoHostInits = new HashSet<VNXeHostInitiator>();
String hostOsType = null;
String hostName = null;
for (VNXeHostInitiator init : hostInitiators) {
VNXeHostInitiator existingInit = getInitiatorByWWN(init.getInitiatorId());
if (existingInit != null && existingInit.getParentHost() != null) {
if (hostId == null) {
hostId = existingInit.getParentHost().getId();
} else if (!hostId.equals(existingInit.getParentHost().getId())) {
_logger.error("Initiators belong to different hosts");
throw VNXeException.exceptions.vnxeCommandFailed("Initiators belong to different hosts");
}
} else if (existingInit != null) {
existingNoHostInits.add(existingInit);
} else {
notExistingInits.add(init);
}
if (hostOsType == null) {
hostOsType = init.getHostOsType();
}
if (hostName == null) {
hostName = init.getName();
}
}
if (hostId == null) {
// create host and hostInitiator
HostListRequest hostReq = new HostListRequest(_khClient);
HostCreateParam hostCreateParm = new HostCreateParam();
hostCreateParm.setName(hostName);
hostCreateParm.setType(HostTypeEnum.HOSTMANUAL.getValue());
if (isUnityClient() && hostOsType != null) {
hostCreateParm.setOsType(hostOsType);
}
VNXeCommandResult result = hostReq.createHost(hostCreateParm);
hostId = result.getId();
}
for (VNXeHostInitiator newInit : notExistingInits) {
HostInitiatorCreateParam initCreateParam = new HostInitiatorCreateParam();
VNXeBase host = new VNXeBase(hostId);
initCreateParam.setHost(host);
if (newInit.getType() == HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI) {
initCreateParam.setInitiatorType(HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI.getValue());
initCreateParam.setInitiatorWWNorIqn(newInit.getChapUserName());
initCreateParam.setChapUser(newInit.getChapUserName());
} else {
initCreateParam.setInitiatorType(HostInitiatorTypeEnum.INITIATOR_TYPE_FC.getValue());
initCreateParam.setInitiatorWWNorIqn(newInit.getInitiatorId());
}
HostInitiatorRequest req = new HostInitiatorRequest(_khClient);
try {
req.createHostInitiator(initCreateParam);
} catch (VNXeException e) {
// For ESX hosts, even if we could not get the initiators when we query them, when we try to create the host
// initiator with the created host, it would throw error, saying the initiator exists. ignore the error.
String message = e.getMessage();
if (message != null && message.contains(VNXeConstants.INITIATOR_EXISITNG)) {
_logger.info("The initiator exists. Ignore the error.");
} else {
throw e;
}
}
}
for (VNXeHostInitiator exitInit : existingNoHostInits) {
setInitiatorHost(exitInit.getId(), hostId);
}
return new VNXeBase(hostId);
}
use of com.emc.storageos.vnxe.requests.HostInitiatorRequest in project coprhd-controller by CoprHD.
the class VNXeApiClient method createInitiator.
/**
* Create host initiator in the array
*
* @param inits
* @param hostId
*/
public void createInitiator(VNXeHostInitiator newInit, String hostId) {
HostInitiatorCreateParam initCreateParam = new HostInitiatorCreateParam();
VNXeBase host = new VNXeBase(hostId);
initCreateParam.setHost(host);
if (newInit.getType() == HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI) {
initCreateParam.setInitiatorType(HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI.getValue());
initCreateParam.setInitiatorWWNorIqn(newInit.getChapUserName());
initCreateParam.setChapUser(newInit.getChapUserName());
} else {
initCreateParam.setInitiatorType(HostInitiatorTypeEnum.INITIATOR_TYPE_FC.getValue());
initCreateParam.setInitiatorWWNorIqn(newInit.getInitiatorId());
}
HostInitiatorRequest req = new HostInitiatorRequest(_khClient);
req.createHostInitiator(initCreateParam);
}
Aggregations