use of com.emc.storageos.db.client.model.FCZoneReference in project coprhd-controller by CoprHD.
the class ExportMaskUtils method removeMaskCoexistInitiators.
/**
* When a co-exist initiator is delete in ViPR, no action will be taken on the storage array
* but the ExportMask and FCZoneReferences in ViPR need to be updated. Note that the only
* time a co-exist initiator can be removed is by actually deleting this initiator in ViPR.
* This means all references will need to be deleted.
*
* @param dbModelClient an instance of DbModelClient
* @param exportMaskUri the export mask being updates
* @param initiatorsUris the ids of the initiators being removed.
*/
public static void removeMaskCoexistInitiators(DbModelClient dbModelClient, URI exportMaskUri, List<URI> initiatorsUris) {
_log.info("removeMaskEoexistInitiators - Removing FCZoneReferences for initiators {}", initiatorsUris);
ExportMask mask = dbModelClient.find(ExportMask.class, exportMaskUri);
if (mask == null || mask.getInactive() || initiatorsUris == null) {
return;
}
// Get the initiators that are removed and all ports in the mask. Generate all possible keys.
List<Initiator> initiators = DataObjectUtils.iteratorToList(dbModelClient.find(Initiator.class, initiatorsUris));
List<StoragePort> ports = DataObjectUtils.iteratorToList(dbModelClient.find(StoragePort.class, StringSetUtil.stringSetToUriList(mask.getStoragePorts())));
List<String> keys = new ArrayList<String>();
for (Initiator initiator : initiators) {
for (StoragePort port : ports) {
keys.add(FCZoneReference.makeEndpointsKey(initiator.getInitiatorPort(), port.getPortNetworkId()));
}
}
if (!keys.isEmpty()) {
_log.info("removeMaskEoexistInitiators - Removing FCZoneReferences for keys {}", keys);
Joiner joiner = dbModelClient.join(FCZoneReference.class, "refs", "pwwnKey", keys).go();
List<FCZoneReference> list = joiner.list("refs");
if (list != null && !list.isEmpty()) {
_log.info("removeMaskEoexistInitiators - found {} FCZoneReferences for keys {}", list.size(), keys);
dbModelClient.remove(list);
}
}
// now clean the export mask
mask.removeInitiators(initiators);
for (URI uri : initiatorsUris) {
mask.removeZoningMapEntry(uri.toString());
}
_log.info("removeMaskEoexistInitiators - removed initiators {} from mask {}", initiatorsUris, mask.getMaskName());
dbModelClient.update(mask);
}
use of com.emc.storageos.db.client.model.FCZoneReference in project coprhd-controller by CoprHD.
the class FCZoneReferenceMigrationTest method verifyResults.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.db.server.upgrade.DbSimpleMigrationTestBase#verifyResults()
*/
@Override
protected void verifyResults() throws Exception {
DbClient dbClient = getDbClient();
FCZoneReference zr = dbClient.queryObject(FCZoneReference.class, zrId);
Assert.assertEquals("1234567812345678_8765432187654321_" + volId, zr.getLabel());
}
use of com.emc.storageos.db.client.model.FCZoneReference in project coprhd-controller by CoprHD.
the class FCZoneReferenceMigrationTest method prepareData.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.db.server.upgrade.DbSimpleMigrationTestBase#prepareData()
*/
@Override
protected void prepareData() throws Exception {
DbClient dbClient = getDbClient();
FCZoneReference zr = new FCZoneReference();
zrId = URIUtil.createId(FCZoneReference.class);
zr.setId(zrId);
volId = URIUtil.createId(Volume.class);
zr.setLabel("1234567812345678_8765432187654321");
zr.setVolumeUri(volId);
dbClient.createObject(zr);
}
use of com.emc.storageos.db.client.model.FCZoneReference in project coprhd-controller by CoprHD.
the class ExportUtilsTestUtils method createExportMask.
public static ExportMask createExportMask(DbClientImpl _dbClient, List<ExportGroup> egs, List<Initiator> initiators, List<Volume> volumes, List<StoragePort> storagePorts, int i) {
ExportMask em = new ExportMask();
String label = "mask" + i;
em.setId(URI.create(label));
em.setLabel(label);
em.setMaskName(label);
StringSet storageIds = new StringSet();
for (StoragePort sp : storagePorts) {
storageIds.add(sp.getId().toString());
}
em.setStoragePorts(storageIds);
for (Initiator initiator : initiators) {
em.addInitiator(initiator);
// Add some ITL mappings
em.addZoningMapEntry(initiator.getId().toString(), storageIds);
for (StoragePort sp : storagePorts) {
for (Volume v : volumes) {
FCZoneReference zr = new FCZoneReference();
String key = FCZoneReference.makeEndpointsKey(Arrays.asList(new String[] { initiator.getInitiatorPort(), sp.getPortNetworkId() }));
zr.setId(URIUtil.createId(FCZoneReference.class));
zr.setLabel(FCZoneReference.makeLabel(zr.getPwwnKey(), v.getId().toString()));
zr.setPwwnKey(key);
zr.setVolumeUri(v.getId());
_dbClient.createObject(zr);
}
}
}
for (Volume volume : volumes) {
em.addVolume(volume.getId(), i);
}
_dbClient.createObject(em);
for (ExportGroup eg : egs) {
eg.addExportMask(em.getId());
_dbClient.updateObject(eg);
}
return em;
}
use of com.emc.storageos.db.client.model.FCZoneReference in project coprhd-controller by CoprHD.
the class NetworkDeviceController method createZoneReferences.
/**
* Create zone references when we discover zones off the switch.
* Normally this routine will not do anything, because the ExportMask is freshly created, and
* will therefore have no volumes in it.
* @param network -- Network Lite
* @param networkSystem -- URI of network system
* @param exportGroup -- ExportGroup
* @param exportMask -- ExportMask
* @param initiatorWwntoZonesMap -- Map of initiator WWN string to a list of corresponding Zones
*/
void createZoneReferences(NetworkLite network, URI networkSystem, ExportGroup exportGroup, ExportMask exportMask, Map<String, List<Zone>> initiatorWwntoZonesMap) {
StringMap maskVolumes = exportMask.getVolumes();
if (maskVolumes == null || maskVolumes.isEmpty()) {
_log.info(String.format("No volumes in ExportMask %s %s so no zone references created", exportMask.getMaskName(), exportMask.getId()));
return;
}
// create a separate zone reference for each initiator - target pair.
for (String maskVolume : maskVolumes.keySet()) {
for (List<Zone> zones : initiatorWwntoZonesMap.values()) {
for (Zone zone : zones) {
// Find the initiatorWwn
String initiatorWwn = null;
for (ZoneMember member : zone.getMembers()) {
if (initiatorWwntoZonesMap.containsKey(member.getAddress())) {
initiatorWwn = member.getAddress();
break;
}
}
if (initiatorWwn == null) {
// Could not locate the initiator
_log.info("Could not locat the initiator: " + zone.getName());
continue;
}
for (ZoneMember member : zone.getMembers()) {
if (initiatorWwn.equals(member.getAddress())) {
continue;
}
String key = FCZoneReference.makeEndpointsKey(initiatorWwn, member.getAddress());
String[] newOrExisting = new String[1];
FCZoneReference ref = addZoneReference(exportGroup.getId(), URI.create(maskVolume), key, network.getNativeId(), networkSystem, zone.getName(), true, newOrExisting);
_log.info(String.format("Created FCZoneReference for existing zone %s %s %s %s", ref.getZoneName(), ref.getPwwnKey(), ref.getVolumeUri(), ref.getGroupUri()));
}
}
}
}
}
Aggregations