use of com.emc.storageos.xiv.api.XIVRestClient in project coprhd-controller by CoprHD.
the class XIVRestOperationsHelper method isClusteredHost.
/**
* Validates if the Host is part of a Cluster on XIV system. Uses initiators to find out the Hosts
*
* @param storage XIV Storage System instance
* @param exportMaskURI ExportMask instance
* @param initiatorList Host Initiators
* @param exportType Host/Cluster export type of the operation
* @return True if the host is part of Cluster else false.
*/
public boolean isClusteredHost(StorageSystem storage, List<Initiator> initiators, String exportType) {
boolean isClusteredHost = false;
if (null != initiators && !initiators.isEmpty()) {
Set<String> hostNames = new HashSet<String>();
XIVRestClient restExportOpr = getRestClient(storage);
if (null == restExportOpr) {
return isClusteredHost;
}
// From Initiators find all the Hosts on Array
for (Initiator initiator : initiators) {
try {
final String hostName = restExportOpr.getHostNameFromPort(storage.getSmisProviderIP(), Initiator.normalizePort(initiator.getInitiatorPort()));
if (null != hostName) {
hostNames.add(hostName);
}
} catch (Exception e) {
_log.error("Invalid host : {} or Port : {} for HSM from Storage System : {} ", storage.getSmisProviderIP(), initiator.getInitiatorPort(), storage.getLabel());
final String errorMessage = "Unable to contact Hyper Scale Manager to execute operation. Either Host or Port could be invalid.";
throw XIVRestException.exceptions.errorInHSMHostConfiguration(errorMessage);
}
}
// Check if Host is part of Cluster
if (hostNames.isEmpty()) {
if (ExportGroup.ExportGroupType.Cluster.name().equals(exportType)) {
isClusteredHost = true;
}
} else {
Set<Boolean> result = new HashSet<Boolean>();
for (String hostName : hostNames) {
result.add(isClusteredHostOnArray(storage, hostName));
}
isClusteredHost = (result.size() == 1 ? result.iterator().next() : false);
}
}
return isClusteredHost;
}
Aggregations