Search in sources :

Example 16 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class DCNMDialog method addZonesStrategy.

/**
 * Given a dialog, add one or more zones to the active zoneset of the specified vsan.
 * This method is callable from with Bourne or from MDSDialogTest for stand-alone testing.
 * For now the only type of zone members supported are pwwn.
 *
 * @param zones - List of zones to be created. Zone names will be overwritten.
 * @param vsanId - Integer vsanId
 * @return list of zone names that were added
 * @throws ControllerException
 */
public List<String> addZonesStrategy(List<Zone> zones, Integer vsanId) throws Exception {
    List<String> addedZoneNames = new ArrayList<String>();
    boolean inSession = false;
    boolean commit = true;
    CIMObjectPath zonesetServicePath = getZoneService(vsanId.toString());
    if (zonesetServicePath == null) {
        throw new DeviceControllerException("Couldn't locate ZoneSetService vsan: " + vsanId);
    }
    CIMInstance zonesetService = _client.getInstance(zonesetServicePath, false, false, null);
    try {
        // Start a session.
        inSession = startSession(_client, zonesetService);
        // Get the existing zones in the active zoneset.
        // XXX FIXME: Need to account for creating the zoneset if none exists.
        List<Zoneset> zonesets = getZonesets(vsanId);
        if (zonesets == null || zonesets.isEmpty()) {
            throw new DeviceControllerException("no zonesets");
        }
        Zoneset activeZoneset = zonesets.get(0);
        if (activeZoneset.getActive() != true) {
            throw new DeviceControllerException("no active zoneset");
        }
        for (Zone zone : zones) {
            CIMObjectPath zonePath = addZone(_client, zonesetService, ((CIMObjectPath) activeZoneset.getCimObjectPath()), zone.getName());
        }
    } finally {
        // Commit session.
        if (inSession) {
            endSession(_client, zonesetService, commit);
        }
    }
    return addedZoneNames;
}
Also used : ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMInstance(javax.cim.CIMInstance)

Example 17 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class DCNMDialog method makeZoneset.

/**
 * Make a zoneset object from a CIMInstance for the Zoneset
 * Calls makeZone().
 *
 * @param zonesetInstance
 * @return Zoneset
 */
private Zoneset makeZoneset(CIMInstance zonesetInstance) throws WBEMException {
    String name = cimStringProperty(zonesetInstance, "ElementName");
    Zoneset zs = new Zoneset(name);
    zs.setCimObjectPath(zonesetInstance.getObjectPath());
    zs.setInstanceID(cimStringProperty(zonesetInstance, "InstanceID"));
    zs.setDescription(cimStringProperty(zonesetInstance, "Description"));
    zs.setActive(cimBooleanProperty(zonesetInstance, "Active"));
    CloseableIterator<CIMInstance> zns = null;
    try {
        zns = _client.associatorInstances(((CIMObjectPath) zs.getCimObjectPath()), "CIM_MemberOfCollection", "CISCO_Zone", null, null, false, null);
        while (zns.hasNext()) {
            CIMInstance zn = zns.next();
            Zone zone = makeZone(zn);
            zs.getZones().add(zone);
        }
    } finally {
        if (zns != null) {
            zns.close();
        }
    }
    return zs;
}
Also used : CIMInstance(javax.cim.CIMInstance)

Example 18 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class DCNMDialog method makeZone.

/**
 * Make a Zone structure from a CIMInstance.
 *
 * @param zoneInstance
 * @return Zone
 */
private Zone makeZone(CIMInstance zoneInstance) throws WBEMException {
    String name = cimStringProperty(zoneInstance, "ElementName");
    Zone zn = new Zone(name);
    zn.setCimObjectPath(zoneInstance.getObjectPath());
    zn.setInstanceID(cimStringProperty(zoneInstance, "InstanceID"));
    zn.setActive(cimBooleanProperty(zoneInstance, "Active"));
    CloseableIterator<CIMInstance> zms = null;
    try {
        zms = _client.associatorInstances(((CIMObjectPath) zn.getCimObjectPath()), "CISCO_ElementSettingData", "CISCO_ZoneMemberSettingData", null, null, false, null);
        while (zms.hasNext()) {
            CIMInstance zm = zms.next();
            ZoneMember member = makeZoneMember(zm);
            zn.getMembers().add(member);
        }
    } finally {
        if (zms != null) {
            zms.close();
        }
    }
    return zn;
}
Also used : CIMInstance(javax.cim.CIMInstance)

Example 19 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class DCNMDialog method getFabricInstance.

public CIMInstance getFabricInstance(String fabricId) throws WBEMException {
    CIMObjectPath path = CimObjectPathCreator.createInstance(_fabric_path, _namespace);
    CloseableIterator<CIMInstance> fabricIter = null;
    try {
        fabricIter = _client.enumerateInstances(path, false, true, true, null);
        while (fabricIter.hasNext()) {
            CIMInstance fabricIns = fabricIter.next();
            if (fabricId.equals(cimStringProperty(fabricIns, "ElementName"))) {
                return fabricIns;
            }
        }
    } finally {
        if (fabricIter != null) {
            fabricIter.close();
        }
    }
    return null;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance)

Example 20 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class FrontEndPortStatsProcessor method processResult.

@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    Iterator<CIMInstance> storagePortStatsResponseItr = (Iterator<CIMInstance>) resultObj;
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    URI systemId = profile.getSystemId();
    DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
    logger.info("Processing FrontEnd Ports response");
    try {
        List<Stat> metricsObjList = (List<Stat>) keyMap.get(Constants._Stats);
        while (storagePortStatsResponseItr.hasNext()) {
            CIMInstance storagePortStatInstance = (CIMInstance) storagePortStatsResponseItr.next();
            Stat fePortStat = new Stat();
            fePortStat.setServiceType(Constants._Block);
            fePortStat.setTimeCollected((Long) keyMap.get(Constants._TimeCollected));
            Long providerCollectionTime = convertCIMStatisticTime(getCIMPropertyValue(storagePortStatInstance, STATISTICTIME));
            if (0 != providerCollectionTime) {
                fePortStat.setTimeInMillis(providerCollectionTime);
            } else {
                fePortStat.setTimeInMillis((Long) keyMap.get(Constants._TimeCollected));
            }
            fePortStat.setTotalIOs(ControllerUtils.getModLongValue(getCIMPropertyValue(storagePortStatInstance, TOTALIOS)));
            fePortStat.setKbytesTransferred(ControllerUtils.getModLongValue(getCIMPropertyValue(storagePortStatInstance, KBYTESTRANSFERRED)));
            setPortRelatedInfo(storagePortStatInstance, systemId, dbClient, fePortStat);
            metricsObjList.add(fePortStat);
        }
    } catch (Exception ex) {
        logger.error("Failed while extracting Stats for Front end ports: ", ex);
    } finally {
        resultObj = null;
    }
    logger.info("Processing FrontEnd Ports response completed");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Stat(com.emc.storageos.db.client.model.Stat) Iterator(java.util.Iterator) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AccessProfile(com.emc.storageos.plugins.AccessProfile) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Aggregations

CIMInstance (javax.cim.CIMInstance)370 CIMObjectPath (javax.cim.CIMObjectPath)254 WBEMException (javax.wbem.WBEMException)139 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)104 ArrayList (java.util.ArrayList)98 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)79 URI (java.net.URI)79 CIMArgument (javax.cim.CIMArgument)71 WBEMClient (javax.wbem.client.WBEMClient)69 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)62 Volume (com.emc.storageos.db.client.model.Volume)62 HashSet (java.util.HashSet)60 IOException (java.io.IOException)53 HashMap (java.util.HashMap)52 Iterator (java.util.Iterator)50 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)48 CIMProperty (javax.cim.CIMProperty)37 StringSet (com.emc.storageos.db.client.model.StringSet)31 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)29