use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSExportMaskVolumesValidator method validate.
@Override
public boolean validate() throws Exception {
log.info("Initiating volumes validation of HDS ExportMask: {}", id);
try {
ExportMask exportMask = getExportMask();
StorageSystem system = getStorage();
if (exportMask != null && !CollectionUtils.isEmpty(exportMask.getDeviceDataMap())) {
Set<String> hsdList = exportMask.getDeviceDataMap().keySet();
HDSApiClient client = getClientFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(system), system.getSmisUserName(), system.getSmisPassword());
HDSApiExportManager exportManager = client.getHDSApiExportManager();
String maskName = null;
String systemObjectID = HDSUtils.getSystemObjectID(system);
Set<String> volumesInExportMask = new HashSet<>();
Set<String> initiatorsInExportMask = new HashSet<>();
if (!CollectionUtils.isEmpty(exportMask.getUserAddedVolumes())) {
volumesInExportMask.addAll(exportMask.getUserAddedVolumes().keySet());
}
if (!CollectionUtils.isEmpty(exportMask.getUserAddedInitiators())) {
initiatorsInExportMask.addAll(exportMask.getUserAddedInitiators().keySet());
}
log.info("Volumes {} in Export Mask {}", volumesInExportMask, exportMask.forDisplay());
log.info("Initiators {} in Export Mask {}", initiatorsInExportMask, exportMask.forDisplay());
for (String hsdObjectIdFromDb : hsdList) {
Set<String> discoveredInitiators = new HashSet<>();
HostStorageDomain hsd = exportManager.getHostStorageDomain(systemObjectID, hsdObjectIdFromDb);
if (null == hsd) {
continue;
}
maskName = (null == hsd.getName()) ? hsd.getNickname() : hsd.getName();
// Get initiators from storage system
discoveredInitiators.addAll(HDSUtils.getInitiatorsFromHSD(hsd));
log.info("Initiators {} discovered from array for the HSD {}", discoveredInitiators, maskName);
Set<String> additionalInitiatorsOnArray = Sets.difference(discoveredInitiators, initiatorsInExportMask);
if (!CollectionUtils.isEmpty(additionalInitiatorsOnArray)) {
getValidatorLogger().logDiff(String.format("%s - %s", id, maskName), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, Joiner.on("\t").join(additionalInitiatorsOnArray));
}
}
checkForErrors();
}
} catch (Exception ex) {
log.error("Unexpected exception validating ExportMask volumes: " + ex.getMessage(), ex);
if (getValidatorConfig().isValidationEnabled()) {
throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask volumes: " + ex.getMessage());
}
}
return true;
}
use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSApiExportManager method addISCSIInitatorsToHostStorageDomain.
/**
* Add WWN to the HostStorageDomain means enable LUN security by adding WWN.
*
* @param systemId
* @param hsdId
* @param scsiNameList
* @param model
* @return
* @throws Exception
*/
public HostStorageDomain addISCSIInitatorsToHostStorageDomain(String systemId, String hsdId, List<String> scsiNameList, String model) throws Exception {
InputStream responseStream = null;
HostStorageDomain hsd = null;
try {
String addISCSINamesToHSDQuery = constructISCSIQuery(systemId, hsdId, scsiNameList, model);
log.info("Query to add SCSI Initiators to HostStorageDomain: {}", addISCSINamesToHSDQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addISCSINamesToHSDQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsd = javaResult.getBean(HostStorageDomain.class);
if (null == hsd) {
throw HDSException.exceptions.notAbleToAddInitiatorToHostStorageDomain("iSCSI", hsdId, systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Add iSCSI initiator to HostStorageDomain failed due to invalid response %1$s from server", response.getStatus()));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return hsd;
}
use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSApiExportManager method constructISCSIQuery.
/**
* Construct the iSCSINames Query by adding multiple WWNs.
* This query should be used to add the iSCSI initiators to the iSCSI HSD.
*
* @param systemId
* @param hsdId
* @param wwnList
* @return
*/
private String constructISCSIQuery(String systemId, String hsdId, List<String> scsiNameList, String model) {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.ISCSI_NAME_FOR_HSD_TARGET);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
HostStorageDomain hsd = new HostStorageDomain(hsdId);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, hsd);
List<ISCSIName> iSCSIObjList = new ArrayList<ISCSIName>();
if (null != scsiNameList && !scsiNameList.isEmpty()) {
for (String iScsiName : scsiNameList) {
ISCSIName iSCSIName = new ISCSIName(iScsiName, null);
iSCSIObjList.add(iSCSIName);
}
}
attributeMap.put(HDSConstants.ISCSINAME_LIST, iSCSIObjList);
String addISCSINamesToHSDQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_ISCSI_NAME_TO_HSD_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
return addISCSINamesToHSDQuery;
}
use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSApiExportManager method addHostStorageDomain.
/**
* Add new HostStorageDomain.
*
* @param systemId
* @param targetPortID
* @param hsdNickName
* @param hostMode.
* @param hostModeOption
* @param model
* @return
* @throws Exception
*/
public HostStorageDomain addHostStorageDomain(String systemId, String targetPortID, String domainType, String hsdName, String hsdNickName, String hostMode, String hostModeOption, String model) throws Exception {
InputStream responseStream = null;
HostStorageDomain hsd = null;
try {
Map<String, Object> attributeMap = new HashMap<String, Object>();
StorageArray array = new StorageArray(systemId);
Add addOp = new Add(HDSConstants.HOST_STORAGE_DOMAIN);
attributeMap.put(HDSConstants.STORAGEARRAY, array);
attributeMap.put(HDSConstants.ADD, addOp);
attributeMap.put(HDSConstants.MODEL, model);
HostStorageDomain inputHsd = new HostStorageDomain(targetPortID, hsdName, domainType, hsdNickName);
inputHsd.setHostMode(hostMode);
inputHsd.setHostModeOption(hostModeOption);
attributeMap.put(HDSConstants.HOST_STORAGE_DOMAIN, inputHsd);
String addHSDToSystemQuery = InputXMLGenerationClient.getInputXMLString(HDSConstants.ADD_HSD_TO_SYSTEM_OP, attributeMap, HDSConstants.HITACHI_INPUT_XML_CONTEXT_FILE, HDSConstants.HITACHI_SMOOKS_CONFIG_FILE);
log.info("Query to create HostStorageDomain: {}", addHSDToSystemQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addHSDToSystemQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsd = javaResult.getBean(HostStorageDomain.class);
if (null == hsd) {
throw HDSException.exceptions.notAbleToAddHSD(systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Not able to add HostStorageDomain due to invalid response %1$s from server", response.getStatus()));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return hsd;
}
use of com.emc.storageos.hds.model.HostStorageDomain in project coprhd-controller by CoprHD.
the class HDSApiExportManager method addWWNToHostStorageDomain.
/**
* Add WWN to the HostStorageDomain means enable LUN security by adding WWN.
*
* @param systemId
* @param hsdId
* @param wwnList
* @param model
* @return
* @throws Exception
*/
public HostStorageDomain addWWNToHostStorageDomain(String systemId, String hsdId, List<String> wwnList, String model) throws Exception {
InputStream responseStream = null;
HostStorageDomain hsd = null;
try {
String addWWNToHSDQuery = constructWWNQuery(systemId, hsdId, wwnList, model);
log.info("Query to add FC initiators to HostStorageDomain: {}", addWWNToHSDQuery);
URI endpointURI = hdsApiClient.getBaseURI();
ClientResponse response = hdsApiClient.post(endpointURI, addWWNToHSDQuery);
if (HttpStatus.SC_OK == response.getStatus()) {
responseStream = response.getEntityInputStream();
JavaResult javaResult = SmooksUtil.getParsedXMLJavaResult(responseStream, HDSConstants.SMOOKS_CONFIG_FILE);
verifyErrorPayload(javaResult);
hsd = javaResult.getBean(HostStorageDomain.class);
if (null == hsd) {
throw HDSException.exceptions.notAbleToAddInitiatorToHostStorageDomain("FC", hsdId, systemId);
}
} else {
throw HDSException.exceptions.invalidResponseFromHDS(String.format("Add initiator to HostStorageDomain failed due to invalid response %1$s from server", response.getStatus()));
}
} finally {
if (null != responseStream) {
try {
responseStream.close();
} catch (IOException e) {
log.warn("IOException occurred while closing the response stream");
}
}
}
return hsd;
}
Aggregations