use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ExportUtils method getPortsInInitiatorNetwork.
/**
* Returns the storage ports allocated to each initiator based
* on the connectivity between them.
*
* @param mask
* @param initiator
* @param dbClient
* @return
*/
public static List<URI> getPortsInInitiatorNetwork(ExportMask mask, Initiator initiator, DbClient dbClient) {
List<URI> list = new ArrayList<URI>();
List<StoragePort> ports = getStoragePorts(mask, dbClient);
NetworkLite networkLite = NetworkUtil.getEndpointNetworkLite(initiator.getInitiatorPort(), dbClient);
if (networkLite != null) {
for (StoragePort port : ports) {
if (port.getNetwork() != null && port.getNetwork().equals(networkLite.getId())) {
list.add(port.getId());
}
}
if (list.isEmpty() && networkLite.getRoutedNetworks() != null) {
for (StoragePort port : ports) {
if (port.getNetwork() != null && networkLite.getRoutedNetworks().contains(port.getNetwork().toString())) {
list.add(port.getId());
}
}
}
}
return list;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class ExportUtils method storagePortNamesToURIs.
/**
* Take in a list of storage port names (hex digits separated by colons),
* then returns a list of URIs representing the StoragePort URIs they represent.
*
* This method ignores the storage ports from cinder storage systems.
*
* @param storagePorts [in] - Storage port name, hex digits separated by colons
* @return List of StoragePort URIs
*/
public static List<String> storagePortNamesToURIs(DbClient dbClient, List<String> storagePorts) {
List<String> storagePortURIStrings = new ArrayList<String>();
Map<URI, String> systemURIToType = new HashMap<URI, String>();
for (String port : storagePorts) {
URIQueryResultList portUriList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(port), portUriList);
Iterator<URI> storagePortIter = portUriList.iterator();
while (storagePortIter.hasNext()) {
URI portURI = storagePortIter.next();
StoragePort sPort = dbClient.queryObject(StoragePort.class, portURI);
if (sPort != null && !sPort.getInactive()) {
String systemType = getStoragePortSystemType(dbClient, sPort, systemURIToType);
// ignore cinder managed storage system's port
if (!DiscoveredDataObject.Type.openstack.name().equals(systemType)) {
storagePortURIStrings.add(portURI.toString());
}
}
}
}
return storagePortURIStrings;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class NetworkUtil method findStoragePortsInDB.
/**
* This method returns storage ports if they exist in database.
* Returns empty list if a storage port could not be found.
*
* @param pwwn storage port pwwn
* @return storagePort object or null
*/
public static List<StoragePort> findStoragePortsInDB(String pwwn, DbClient dbClient) {
List<StoragePort> ports = new ArrayList<StoragePort>();
_log.info("Looking for storage port {} in database", pwwn);
URIQueryResultList portUriList = new URIQueryResultList();
dbClient.queryByConstraint(AlternateIdConstraint.Factory.getStoragePortEndpointConstraint(pwwn), portUriList);
Iterator<URI> itr = portUriList.iterator();
while (itr.hasNext()) {
StoragePort port = dbClient.queryObject(StoragePort.class, itr.next());
if (port != null && !port.getInactive()) {
_log.info("Found storage port {}", pwwn);
ports.add(port);
}
}
return ports;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class VPlexUtil method getBackendPortInitiators.
/**
* Returns a set of all VPLEX backend ports as their related
* Initiator URIs for a given VPLEX storage system.
*
* @param vplexUri - URI of the VPLEX system to find initiators for
* @param dbClient - database client instance
* @return a Set of Initiator URIs
*/
public static Set<URI> getBackendPortInitiators(URI vplexUri, DbClient dbClient) {
_log.info("finding backend port initiators for VPLEX: " + vplexUri);
Set<URI> initiators = new HashSet<>();
List<StoragePort> ports = ConnectivityUtil.getStoragePortsForSystem(dbClient, vplexUri);
for (StoragePort port : ports) {
if (StoragePort.PortType.backend.name().equals(port.getPortType())) {
Initiator init = ExportUtils.getInitiator(port.getPortNetworkId(), dbClient);
if (init != null) {
_log.info("found initiator {} for wwpn {}", init.getId(), port.getPortNetworkId());
initiators.add(init.getId());
}
}
}
return initiators;
}
use of com.emc.storageos.db.client.model.StoragePort in project coprhd-controller by CoprHD.
the class FileDeviceController method copyPropertiesToSave.
private void copyPropertiesToSave(FileExportRule dest, ExportRule orig, FileShare fs, FileDeviceInputOutput args) {
_log.info("Origin {}", orig.toString());
String exportPath = args.getExportPath();
// This export path is the one that is figured out at the device.
// Make sure you set the path on args object while doing the operation. Check for
// <Device>FileStorageDeviceXXX.java
dest.setExportPath(exportPath);
dest.setSecFlavor(orig.getSecFlavor());
dest.setAnon(orig.getAnon());
if (orig.getReadOnlyHosts() != null && !orig.getReadOnlyHosts().isEmpty()) {
dest.setReadOnlyHosts(new StringSet(orig.getReadOnlyHosts()));
_log.info("Read Only Hosts {}", dest.getReadOnlyHosts());
}
if (orig.getReadWriteHosts() != null && !orig.getReadWriteHosts().isEmpty()) {
dest.setReadWriteHosts(new StringSet(orig.getReadWriteHosts()));
_log.info("Read Write Hosts {}", dest.getReadWriteHosts());
}
if (orig.getRootHosts() != null && !orig.getRootHosts().isEmpty()) {
dest.setRootHosts(new StringSet(orig.getRootHosts()));
_log.info("Root hosts {}", dest.getRootHosts());
}
// Set this always at the end -- Thats how the model is defined.
if (!args.getFileOperation()) {
dest.setSnapshotId(args.getSnapshotId());
} else {
dest.setFileSystemId(fs.getId());
}
// Figure out Storage Port Network id to build the mount point.
StoragePort storagePort = _dbClient.queryObject(StoragePort.class, fs.getStoragePort());
String mountPoint = ExportUtils.getFileMountPoint(storagePort.getPortNetworkId(), exportPath);
dest.setMountPoint(mountPoint);
// dest.calculateExportRuleIndex();
if ((orig.getDeviceExportId() != null) && (!orig.getDeviceExportId().isEmpty())) {
dest.setDeviceExportId(orig.getDeviceExportId());
} else if ((args.getObjIdOnDevice() != null) && (!args.getObjIdOnDevice().isEmpty())) {
dest.setDeviceExportId(args.getObjIdOnDevice());
}
// _log.info("New File Export Rule Object {}", dest);
_log.info("Dest After {}", dest.toString());
}
Aggregations