use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method updateStoragePorts.
/**
* Updates the given storage ports with the virtual array assignment changes.
*
* @param ids
* the storage port IDs.
* @param changes
* the virtual array changes.
*/
private static void updateStoragePorts(List<URI> ids, VirtualArrayAssignmentChanges changes) {
if (ids.isEmpty()) {
return;
}
List<StoragePortRestRep> storagePorts = StoragePortUtils.getStoragePorts(ids);
for (StoragePortRestRep storagePort : storagePorts) {
StoragePortUpdate update = new StoragePortUpdate();
update.setVarrayChanges(changes);
StoragePortUtils.update(storagePort.getId(), update);
}
}
use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPathPorts.
@Asset("exportPathPorts")
@AssetDependencies({ "exportPathVirtualArray", "exportPathStorageSystem", "exportPathExport" })
public List<AssetOption> getExportPathPorts(AssetOptionsContext ctx, URI vArrayId, URI storageSystemId, URI exportId) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
// Get all the PGs for the varray/storage system/EG combo then check to
// see if there are any non-mutable PGs;
// if there are the storage ports displayed to the user would be limited
// to just those ones.
StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(vArrayId, exportId, storageSystemId, null, null, false);
// Keep a list of ports from the non-mutable PGs. This could remain
// empty if there are no PGs or none that are non-mutable.
List<URI> nonMutablePGPortURIs = new ArrayList<URI>();
if (portGroupsRestRep != null) {
// Drill down to get the PG and the storage ports
List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
if (!CollectionUtils.isEmpty(portGroups)) {
for (StoragePortGroupRestRep pg : portGroups) {
// Check to see if the PG is non-mutable
if (!pg.getMutable()) {
// Keep track of these storage ports, they will be used
// to filter out
// other storage ports.
StoragePortList pgPortsList = pg.getStoragePorts();
List<NamedRelatedResourceRep> pgPorts = pgPortsList.getPorts();
for (NamedRelatedResourceRep pgPort : pgPorts) {
nonMutablePGPortURIs.add(pgPort.getId());
}
}
}
}
}
List<StoragePortRestRep> ports = client.storagePorts().getByVirtualArray(vArrayId);
for (StoragePortRestRep port : ports) {
// Check to see if this port needs to be filtered out.
boolean filterOutPortBasedOnPG = (!nonMutablePGPortURIs.isEmpty()) ? !nonMutablePGPortURIs.contains(port.getId()) : false;
if (!filterOutPortBasedOnPG) {
if (port.getPortType().equals(StoragePort.PortType.frontend.toString()) && port.getStorageDevice().getId().equals(storageSystemId) && port.getOperationalStatus().equals(StoragePort.OperationalStatus.OK.toString())) {
if (port.getNetwork() != null) {
String portPercentBusy = (port.getPortPercentBusy() != null) ? String.valueOf(Math.round(port.getPortPercentBusy() * 100 / 100)) + "%" : "N/A";
String networkName = client.networks().get(port.getNetwork().getId()).getName();
String label = getMessage("exportPathAdjustment.ports", port.getPortName(), networkName, port.getPortNetworkId(), portPercentBusy);
options.add(new AssetOption(port.getId(), label));
}
}
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method buildPathOptions.
/* helper for building the list of asset option for affected and removed paths */
private List<AssetOption> buildPathOptions(AssetOptionsContext ctx, List<InitiatorPortMapRestRep> list, String message) {
ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
for (InitiatorPortMapRestRep ipm : list) {
InitiatorRestRep initiator = ipm.getInitiator();
List<NamedRelatedResourceRep> ports = ipm.getStoragePorts();
String portList = new String(" ");
List<URI> portURIs = new ArrayList<URI>();
for (NamedRelatedResourceRep port : ports) {
StoragePortRestRep p = client.storagePorts().get(port.getId());
portList += p.getPortName() + " ";
portURIs.add(port.getId());
}
Map<URI, List<URI>> key = new HashMap<URI, List<URI>>();
key.put(initiator.getId(), portURIs);
String label = getMessage(message, initiator.getHostName(), initiator.getName(), portList);
String keyString = EMPTY_STRING;
try {
keyString = CatalogSerializationUtils.serializeToString(key);
} catch (Exception ex) {
}
options.add(new AssetOption(keyString, label));
}
return options;
}
use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.
the class VirtualArrayProvider method getVirtualArrayForStorageSystem.
protected List<AssetOption> getVirtualArrayForStorageSystem(AssetOptionsContext context, URI storageSystem) {
ViPRCoreClient client = api(context);
Set<String> virtualArrayIds = Sets.newHashSet();
for (StoragePortRestRep storagePortRestRep : client.storagePorts().getByStorageSystem(storageSystem)) {
virtualArrayIds.addAll(storagePortRestRep.getAssignedVirtualArrays());
virtualArrayIds.addAll(storagePortRestRep.getConnectedVirtualArrays());
}
List<VirtualArrayRestRep> virtualArrays = client.varrays().getByIds(ResourceUtils.uris(virtualArrayIds));
filterByContextTenant(virtualArrays, client.varrays().getByTenant(context.getTenant()));
return createBaseResourceOptions(virtualArrays);
}
use of com.emc.storageos.model.ports.StoragePortRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method addVarrayStorageSystem.
/**
* Adds all ports of the given storage systems to a virtual array.
*
* @param virtualArrayId
* the virtual array ID.
* @param ids
* the storage system IDs.
*/
private static void addVarrayStorageSystem(String virtualArrayId, String id) {
List<URI> storagePorts = Lists.newArrayList();
URI storageSystemId = uri(id);
List<StoragePortRestRep> ports = StoragePortUtils.getStoragePortsByStorageSystem(storageSystemId);
storagePorts.addAll(ResourceUtils.ids(ports));
if (!storagePorts.isEmpty()) {
VirtualArrayRestRep virtualArray = getVirtualArray(virtualArrayId);
updateStoragePorts(storagePorts, addVirtualArray(virtualArray));
}
}
Aggregations