use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ExportUtils method getZonedPorts.
/**
* Return the ports that were zoned to an initiator according to the zoningMap.
*
* @param initiator - Initiator
* @param ports - List of ports in the ExportMask
* @param zoningMap - zoningMap in the ExportMask
* @return
*/
private static List<StoragePort> getZonedPorts(Initiator initiator, List<StoragePort> ports, StringSetMap zoningMap) {
List<StoragePort> zonedPorts = new ArrayList<StoragePort>();
if (zoningMap == null || zoningMap.isEmpty()) {
return zonedPorts;
}
StringSet portSet = zoningMap.get(initiator.getId().toString());
if (portSet != null) {
for (StoragePort port : ports) {
if (portSet.contains(port.getId().toString())) {
zonedPorts.add(port);
}
}
}
return zonedPorts;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class VirtualArrayService method getVirtualArrayStoragePorts.
/**
* Returns the storage ports for the VirtualArray with the passed id. When
* the VirtualArray has been explicitly assigned to one or more storage
* ports, this API will return the ids of those storage ports. VirtualArrays
* can be explicitly assigned to storage ports when a storage port is
* created or later by modifying the storage port after it has been created.
* <p>
* Whether or not a VirtualArray has been explicitly assigned to any storage ports the VirtualArray may still have implicit associations
* with one or more storage port due to the VirtualArray's network connectivity. That is, a network resides in a VirtualArray and may
* contain storage ports. This implies that these storage ports reside in the VirtualArray. If the VirtualArray has no explicit storage
* port assignments, but does have implicit associations, the API will instead return those storage ports implicitly associated.
* <p>
* The API provides the ability to force the return of the list of storage ports implicitly associated with the VirtualArray using the
* request parameter "network_connectivity". Passing this parameter with a value of "true" will return the ids of the storage ports
* implicitly associated with the VirtualArray as described.
*
* @param id the URN of a ViPR VirtualArray.
* @param useNetworkConnectivity true to use the network connectivity to
* get the list of storage ports implicitly connected to the
* VirtualArray.
*
* @brief List VirtualArray storage ports
* @return The ids of the storage ports associated with the VirtualArray.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/storage-ports")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public StoragePortList getVirtualArrayStoragePorts(@PathParam("id") URI id, @QueryParam("network_connectivity") boolean useNetworkConnectivity) {
// Get and validate the varray with the passed id.
ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
ArgValidator.checkEntity(varray, id, isIdEmbeddedInURL(id));
// Query the database for the storage ports associated with the
// VirtualArray. If the request is for storage ports whose
// association with the VirtualArray is implicit through network
// connectivity, then return only these storage ports. Otherwise,
// the result is for storage ports explicitly assigned to the
// VirtualArray.
URIQueryResultList storagePortURIs = new URIQueryResultList();
if (useNetworkConnectivity) {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getImplicitVirtualArrayStoragePortsConstraint(id.toString()), storagePortURIs);
} else {
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVirtualArrayStoragePortsConstraint(id.toString()), storagePortURIs);
}
// Create and return the result.
StoragePortList storagePorts = new StoragePortList();
for (URI uri : storagePortURIs) {
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, uri);
if ((storagePort != null) && (RegistrationStatus.REGISTERED.toString().equals(storagePort.getRegistrationStatus())) && DiscoveryStatus.VISIBLE.toString().equals(storagePort.getDiscoveryStatus())) {
storagePorts.getPorts().add(toNamedRelatedResource(storagePort, storagePort.getNativeGuid()));
}
}
return storagePorts;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class FrontEndPortStatsProcessor method setPortRelatedInfo.
/**
* Return the port nativeGuid based on the Stat objects wwn.
*
* @param storagePortStatInstance
* @param systemId
* @param dbClient
* @return
*/
private void setPortRelatedInfo(CIMInstance storagePortStatInstance, URI systemId, DbClient dbClient, Stat fePortStat) {
String instanceId = getCIMPropertyValue(storagePortStatInstance, INSTANCE_ID);
Iterable<String> splitter = Splitter.on(HDSConstants.DOT_OPERATOR).limit(3).split(instanceId);
String portWWN = Iterables.getLast(splitter);
URIQueryResultList storagePortURIList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(SanUtils.normalizeWWN(portWWN).toUpperCase()), storagePortURIList);
Iterator<URI> itr = storagePortURIList.iterator();
while (itr.hasNext()) {
StoragePort port = dbClient.queryObject(StoragePort.class, itr.next());
if (port.getStorageDevice().equals(systemId)) {
fePortStat.setNativeGuid(port.getNativeGuid());
fePortStat.setResourceId(port.getId());
portMetricsProcessor.processFEPortMetrics(fePortStat.getKbytesTransferred(), fePortStat.getTotalIOs(), port, fePortStat.getTimeInMillis());
break;
}
}
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class HDSExportOperations method checkIfMixedTargetPortTypeSelected.
/**
* @param portURIList
* @return
*/
private boolean checkIfMixedTargetPortTypeSelected(List<StoragePort> ports) {
boolean isFC = false;
boolean isIP = false;
for (StoragePort port : ports) {
if (port.getPortType().equalsIgnoreCase(Transport.FC.name())) {
isFC = true;
} else if (port.getPortType().equalsIgnoreCase(Transport.IP.name())) {
isIP = true;
}
if (isFC && isIP) {
return true;
}
}
return false;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class HDSExportOperations method addInitiators.
@Override
public void addInitiators(StorageSystem storage, URI exportMaskURI, List<URI> volumeURIs, List<Initiator> initiators, List<URI> targetURIList, TaskCompleter taskCompleter) throws DeviceControllerException {
log.info("{} addInitiator START...", storage.getSerialNumber());
HDSApiClient hdsApiClient = null;
String systemObjectID = null;
List<HostStorageDomain> hsdsToCreate = null;
List<HostStorageDomain> hsdsWithInitiators = null;
try {
log.info("addInitiator: Export mask id: {}", exportMaskURI);
if (volumeURIs != null) {
log.info("addInitiator: volumes : {}", Joiner.on(',').join(volumeURIs));
}
log.info("addInitiator: initiators : {}", Joiner.on(',').join(initiators));
log.info("addInitiator: targets : {}", Joiner.on(",").join(targetURIList));
hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(storage), storage.getSmisUserName(), storage.getSmisPassword());
HDSApiExportManager exportMgr = hdsApiClient.getHDSApiExportManager();
systemObjectID = HDSUtils.getSystemObjectID(storage);
ExportMask exportMask = dbClient.queryObject(ExportMask.class, exportMaskURI);
List<StoragePort> ports = dbClient.queryObject(StoragePort.class, targetURIList, true);
if (checkIfMixedTargetPortTypeSelected(ports)) {
log.error("Unsupported Host as it has both FC & iSCSI Initiators");
throw HDSException.exceptions.unsupportedConfigurationFoundInHost();
}
// @TODO register new initiators by adding them to host on HiCommand DM.
// Currently, HiCommand is not supporting this. Need to see how we can handle.
String hostName = getHostNameForInitiators(initiators);
String hostMode = null, hostModeOption = null;
Pair<String, String> hostModeInfo = getHostModeInfo(storage, initiators);
if (hostModeInfo != null) {
hostMode = hostModeInfo.first;
hostModeOption = hostModeInfo.second;
}
if (targetURIList != null && !targetURIList.isEmpty()) {
Set<URI> newTargetPorts = new HashSet<>(targetURIList);
Set<URI> existingTargetPortsInMask = new HashSet<>();
if (exportMask.getStoragePorts() != null) {
existingTargetPortsInMask = new HashSet<>(targetURIList);
Collection<URI> targetPorts = Collections2.transform(exportMask.getStoragePorts(), CommonTransformerFunctions.FCTN_STRING_TO_URI);
existingTargetPortsInMask.retainAll(targetPorts);
}
newTargetPorts.removeAll(existingTargetPortsInMask);
log.info("list of new storage target ports {}", newTargetPorts);
log.info("list of existing storage target ports available in export masks {}", existingTargetPortsInMask);
// Case 1 is handled here for the new initiators & new target ports.
if (!newTargetPorts.isEmpty()) {
// If the HLU's are already configured on this target port, then an exception is thrown.
// User should make sure that all volumes should have same HLU across all target HSD's.
VolumeURIHLU[] volumeURIHLUs = getVolumeURIHLUFromExportMask(exportMask);
if (0 < volumeURIHLUs.length) {
List<URI> portList = new ArrayList<>(newTargetPorts);
hsdsToCreate = processTargetPortsToFormHSDs(hdsApiClient, storage, portList, hostName, exportMask, hostModeInfo, systemObjectID);
// Step 1: Create all HSD's using batch operation.
List<HostStorageDomain> hsdResponseList = hdsApiClient.getHDSBatchApiExportManager().addHostStorageDomains(systemObjectID, hsdsToCreate, storage.getModel());
if (null == hsdResponseList || hsdResponseList.isEmpty()) {
log.error("Batch HSD creation failed to add new initiators. Aborting operation...");
throw HDSException.exceptions.notAbleToAddHSD(storage.getSerialNumber());
}
// Step 2: Add initiators to all HSD's.
Iterator<StoragePort> storagePortIterator = dbClient.queryIterativeObjects(StoragePort.class, newTargetPorts);
List<StoragePort> stPortList = new ArrayList<>();
while (storagePortIterator.hasNext()) {
StoragePort stPort = storagePortIterator.next();
if (stPort != null && !stPort.getInactive()) {
stPortList.add(stPort);
}
}
hsdsWithInitiators = executeBatchHSDAddInitiatorsCommand(hdsApiClient, systemObjectID, hsdResponseList, stPortList, initiators, storage.getModel());
// Step 3: Add volumes to all HSD's.
List<Path> allHSDPaths = executeBatchHSDAddVolumesCommand(hdsApiClient, systemObjectID, hsdsWithInitiators, volumeURIHLUs, storage.getModel());
if (null != allHSDPaths && !allHSDPaths.isEmpty()) {
updateExportMaskDetailInDB(hsdsWithInitiators, allHSDPaths, exportMask, storage, volumeURIHLUs);
}
} else {
log.info("There are no volumes on this exportmask: {} to add to new initiator", exportMaskURI);
}
}
// existing HSD to access the volumes already exported in the exportmask.
if (!existingTargetPortsInMask.isEmpty()) {
// Step 1: Collect all HSDs from export mask
StringSetMap deviceDataMap = exportMask.getDeviceDataMap();
if (null != deviceDataMap && !deviceDataMap.isEmpty()) {
List<HostStorageDomain> hsdResponseList = new ArrayList<>();
Set<String> hsdObjectIdSet = deviceDataMap.keySet();
for (String hsdObjectId : hsdObjectIdSet) {
HostStorageDomain hsd = exportMgr.getHostStorageDomain(systemObjectID, hsdObjectId);
if (null == hsd) {
throw HDSException.exceptions.notAbleToFindHostStorageDomain(hsdObjectId);
}
hsdResponseList.add(hsd);
}
// Step 2: Add initiators to all HSD's.
Iterator<StoragePort> storagePortIterator = dbClient.queryIterativeObjects(StoragePort.class, existingTargetPortsInMask, true);
List<StoragePort> stPortList = new ArrayList<>();
while (storagePortIterator.hasNext()) {
StoragePort stPort = storagePortIterator.next();
if (stPort != null) {
stPortList.add(stPort);
}
}
hsdsWithInitiators = executeBatchHSDAddInitiatorsCommand(hdsApiClient, systemObjectID, hsdResponseList, stPortList, initiators, storage.getModel());
} else {
log.info("There are no hsd information in exportMask to add initiators");
}
}
}
taskCompleter.ready(dbClient);
} catch (Exception ex) {
try {
log.info("Exception occurred while adding new initiators: {}", ex.getMessage());
if (null != hsdsWithInitiators && !hsdsWithInitiators.isEmpty()) {
hdsApiClient.getHDSBatchApiExportManager().deleteBatchHostStorageDomains(systemObjectID, hsdsWithInitiators, storage.getModel());
} else {
if (null != hsdsToCreate && !hsdsToCreate.isEmpty()) {
List<HostStorageDomain> allHSDs = hdsApiClient.getHDSApiExportManager().getHostStorageDomains(systemObjectID);
List<HostStorageDomain> partialHSDListToRemove = getPartialHSDListToDelete(allHSDs, hsdsToCreate);
hdsApiClient.getHDSBatchApiExportManager().deleteBatchHostStorageDomains(systemObjectID, partialHSDListToRemove, storage.getModel());
}
}
log.error(String.format("addInitiator failed - maskURI: %s", exportMaskURI.toString()), ex);
} catch (Exception ex1) {
log.error("Exception occurred while deleting unsuccessful HSDs on system: {}", systemObjectID, ex1.getMessage());
} finally {
ServiceError serviceError = DeviceControllerException.errors.jobFailedOpMsg(ResourceOperationTypeEnum.ADD_EXPORT_INITIATOR.getName(), ex.getMessage());
taskCompleter.error(dbClient, serviceError);
}
}
log.info("{} addInitiator END...", storage.getSerialNumber());
}
Aggregations