Search in sources :

Example 21 with FCZoneReference

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);
}
Also used : Joiner(com.emc.storageos.db.joiner.Joiner) Initiator(com.emc.storageos.db.client.model.Initiator) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) URI(java.net.URI) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 22 with FCZoneReference

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());
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 23 with FCZoneReference

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);
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 24 with FCZoneReference

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;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) Volume(com.emc.storageos.db.client.model.Volume) ExportMask(com.emc.storageos.db.client.model.ExportMask) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Example 25 with FCZoneReference

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()));
                }
            }
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) FCZoneReference(com.emc.storageos.db.client.model.FCZoneReference)

Aggregations

FCZoneReference (com.emc.storageos.db.client.model.FCZoneReference)34 URI (java.net.URI)15 ArrayList (java.util.ArrayList)14 StoragePort (com.emc.storageos.db.client.model.StoragePort)10 HashMap (java.util.HashMap)8 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)6 Volume (com.emc.storageos.db.client.model.Volume)6 Initiator (com.emc.storageos.db.client.model.Initiator)5 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 List (java.util.List)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)4 NetworkFCZoneInfo (com.emc.storageos.networkcontroller.NetworkFCZoneInfo)4 Zone (com.emc.storageos.networkcontroller.impl.mds.Zone)4 ZoneMember (com.emc.storageos.networkcontroller.impl.mds.ZoneMember)4 DbClient (com.emc.storageos.db.client.DbClient)3 BlockObject (com.emc.storageos.db.client.model.BlockObject)3 BulkList (com.emc.storageos.api.service.impl.response.BulkList)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 Network (com.emc.storageos.db.client.model.Network)2