Search in sources :

Example 1 with CIMProperty

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

the class DCNMDialog method getFabricIds.

/**
 * Get the list of Vsan Ids.
 *
 * @return List<String>
 * @throws Exception
 */
public List<String> getFabricIds() throws Exception {
    // A set is used because in the case of a disconnected network the same Vsan can
    // show up twice. Conerted to list at end.
    Set<String> fabricIds = new HashSet<String>();
    List<Zoneset> zonesets = new ArrayList<Zoneset>();
    CIMObjectPath path = CimObjectPathCreator.createInstance("Cisco_Vsan", _namespace);
    CloseableIterator<CIMInstance> vsanIt = null;
    try {
        vsanIt = _client.enumerateInstances(path, false, true, true, null);
        while (vsanIt.hasNext()) {
            String vsanId = null;
            CIMInstance vsanIns = vsanIt.next();
            CIMProperty prop = vsanIns.getProperty("OtherIdentifyingInfo");
            String[] idinfoValue = (String[]) prop.getValue();
            if (idinfoValue.length == 2 && idinfoValue[0].equals("Fabric")) {
                vsanId = idinfoValue[1];
            }
            if (vsanId != null) {
                fabricIds.add(vsanId);
            }
        }
    } finally {
        if (vsanIt != null) {
            vsanIt.close();
        }
    }
    List<String> alist = new ArrayList<String>();
    alist.addAll(fabricIds);
    return alist;
}
Also used : CIMProperty(javax.cim.CIMProperty) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

Example 2 with CIMProperty

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

the class BaseSANCIMObject method cimStringProperty.

protected String cimStringProperty(CIMInstance ins, String field) {
    CIMProperty prop = ins.getProperty(field);
    if (prop == null) {
        return null;
    }
    Object obj = prop.getValue();
    if (obj == null) {
        return null;
    }
    return obj.toString();
}
Also used : CIMProperty(javax.cim.CIMProperty)

Example 3 with CIMProperty

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

the class BrocadeNetworkSMIS method getLogicalToPhysicalSwitcheMap.

/**
 * get Logical switches to physical switch map
 * @param client an instance of WBEMClient
 * @return a map of logical to physical switch name
 * @throws WBEMException
 */
public HashMap<String, String> getLogicalToPhysicalSwitcheMap(WBEMClient client) throws WBEMException {
    HashMap<String, String> switchMap = new HashMap<>();
    CIMObjectPath path = new CIMObjectPath(null, null, null, _namespace, _Brocade_SwitchPCS, null);
    CloseableIterator<CIMInstance> it = null;
    try {
        it = client.enumerateInstances(path, false, true, true, null);
        while (it.hasNext()) {
            CIMInstance ins = it.next();
            String parentName = cimStringProperty(ins, _Parent);
            String childName = cimStringProperty(ins, _Child);
            _log.debug("Brocade Switch: Parent :  {} - Child : {} )", parentName, childName);
            CIMProperty[] props = ins.getProperties();
            for (int i = 0; i < props.length; i++) {
                _log.debug("Switch property : " + props[i].getName() + ": value : " + props[i].getValue());
            }
            CIMInstance parentObject = client.getInstance(new CIMObjectPath(parentName), true, true, null);
            CIMInstance childObject = client.getInstance(new CIMObjectPath(childName), true, true, null);
            parentName = cimStringProperty(parentObject, _element_name);
            childName = cimStringProperty(childObject, _element_name);
            switchMap.put(childName, parentName);
            _log.info("Brocade Switch: Logical Switch : " + childName + " In (" + parentName + ")");
        }
    } finally {
        if (it != null) {
            it.close();
        }
    }
    return switchMap;
}
Also used : HashMap(java.util.HashMap) CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint)

Example 4 with CIMProperty

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

the class ExportProcessor method processResult.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.plugins.common.Processor#processResult(com.emc.storageos.plugins.common.domainmodel.Operation,
     * java.lang.Object, java.util.Map)
     */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    initialize(operation, resultObj, keyMap);
    CloseableIterator<CIMInstance> it = null;
    EnumerateResponse<CIMInstance> response = null;
    List<Initiator> matchedInitiators = new ArrayList<Initiator>();
    List<StoragePort> matchedPorts = new ArrayList<StoragePort>();
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    StringSet knownIniSet = new StringSet();
    StringSet knownNetworkIdSet = new StringSet();
    StringSet knownPortSet = new StringSet();
    StringSet knownVolumeSet = new StringSet();
    try {
        // set lun masking view CIM path
        CIMObjectPath path = this.getObjectPathfromCIMArgument(_args, keyMap);
        UnManagedExportMask mask = this.getUnManagedExportMask(path);
        mask.setMaskingViewPath(path.toString());
        _logger.info("looking at lun masking view: " + path.toString());
        CIMInstance lunMaskingView = client.getInstance(path, false, false, null);
        if (lunMaskingView != null) {
            String maskName = CIMPropertyFactory.getPropertyValue(lunMaskingView, SmisConstants.CP_NAME);
            if (maskName != null) {
                mask.setMaskName(maskName);
            }
            _logger.info("set UnManagedExportMask maskName to " + mask.getMaskName());
        } else {
            _logger.info("lunMaskingView was null");
        }
        CIMProperty<String> deviceIdProperty = (CIMProperty<String>) path.getKey(SmisConstants.CP_DEVICE_ID);
        if (deviceIdProperty != null) {
            mask.setNativeId(deviceIdProperty.getValue());
        }
        _logger.info("set UnManagedExportMask nativeId to " + mask.getNativeId());
        // set storage system id
        URI systemId = (URI) keyMap.get(Constants.SYSTEMID);
        mask.setStorageSystemUri(systemId);
        response = (EnumerateResponse<CIMInstance>) resultObj;
        processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
        while (!response.isEnd()) {
            _logger.info("Processing next Chunk");
            response = client.getInstancesWithPath(Constants.MASKING_PATH, response.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
        }
        // CTRL - 8918 - always update the mask with new initiators and volumes.
        mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, knownPortSet);
        // get zones and store them?
        updateZoningMap(mask, matchedInitiators, matchedPorts);
        updateVplexBackendVolumes(mask, matchedInitiators);
        updateRecoverPointVolumes(mask, matchedInitiators);
    } catch (Exception e) {
        _logger.error("something failed", e);
    } finally {
        if (it != null) {
            it.close();
        }
        wrapUp();
        if (response != null) {
            try {
                client.closeEnumeration(Constants.MASKING_PATH, response.getContext());
            } catch (Exception e) {
                _logger.debug("Exception occurred while closing enumeration", e);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Initiator(com.emc.storageos.db.client.model.Initiator) CIMProperty(javax.cim.CIMProperty) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 5 with CIMProperty

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

the class MetaVolumeTypeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath metaVolumePath = getObjectPathfromCIMArgument(_args);
        if (metaVolumePath == null) {
            _logger.info(String.format("MetaVolumePath is null."));
        } else {
            _logger.info(String.format("Processing EMC_Meta for meta volume: %s", metaVolumePath));
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(metaVolumePath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(metaVolumePath);
                _logger.debug("Meta volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeTypeProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            final Iterator<?> it = (Iterator<?>) resultObj;
            if (it.hasNext()) {
                final CIMObjectPath symmMetaPath = (CIMObjectPath) it.next();
                _logger.debug(String.format("Processing EMC_Meta: %s", symmMetaPath));
                CIMInstance cimMeta = client.getInstance(symmMetaPath, false, false, STRIPE_EXTENTS_NUMBER);
                CIMProperty stripeLengthProperty = cimMeta.getProperty(SmisConstants.CP_EXTENT_STRIPE_LENGTH);
                Long stripeLength = Long.valueOf(stripeLengthProperty.getValue().toString());
                String metaVolumeType;
                if (stripeLength < 1) {
                    _logger.error(String.format("Stripe length for EMC_Meta is less than 1: %s", stripeLength));
                    return;
                } else if (stripeLength == 1) {
                    // this is concatenated meta volume
                    _logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is concatenated.", stripeLength));
                    metaVolumeType = Volume.CompositionType.CONCATENATED.toString();
                } else {
                    // this is striped meta volume
                    _logger.debug(String.format("Stripe length for EMC_Meta is : %s. Type is striped.", stripeLength));
                    metaVolumeType = Volume.CompositionType.STRIPED.toString();
                }
                _logger.info(String.format("Meta volume: %s, type: %s", metaVolumePath, metaVolumeType));
                if (null == preExistingVolume) {
                    // storage volume update
                    storageVolume.setCompositionType(metaVolumeType);
                    // persist volume in db
                    dbClient.persistObject(storageVolume);
                } else {
                    // unmanaged volume update
                    StringSet metaVolumeTypeSet = new StringSet();
                    metaVolumeTypeSet.add(metaVolumeType);
                    preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_VOLUME_TYPE.toString(), metaVolumeTypeSet);
                    // for this volume.
                    if (Volume.CompositionType.STRIPED.toString().equalsIgnoreCase(metaVolumeType)) {
                        URI storageSystemUri = preExistingVolume.getStorageSystemUri();
                        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, storageSystemUri);
                        if (DiscoveredDataObject.Type.vmax.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
                            _logger.info("Check matched vpool list for vmax striped meta volume and remove fastExpansion vpools.");
                            StringSet matchedVirtualPools = preExistingVolume.getSupportedVpoolUris();
                            if (matchedVirtualPools != null && !matchedVirtualPools.isEmpty()) {
                                _logger.debug("Matched Pools :" + Joiner.on("\t").join(matchedVirtualPools));
                                StringSet newMatchedPools = new StringSet();
                                boolean needToReplace = false;
                                for (String vPoolUriStr : matchedVirtualPools) {
                                    URI vPoolUri = new URI(vPoolUriStr);
                                    VirtualPool virtualPool = dbClient.queryObject(VirtualPool.class, vPoolUri);
                                    // null check since supported vPool list in UnManagedVolume may contain inactive vPool
                                    if (virtualPool != null && !virtualPool.getFastExpansion()) {
                                        newMatchedPools.add(vPoolUriStr);
                                    } else {
                                        needToReplace = true;
                                    }
                                }
                                if (needToReplace) {
                                    matchedVirtualPools.replace(newMatchedPools);
                                    _logger.info("Replaced VPools : {}", Joiner.on("\t").join(preExistingVolume.getSupportedVpoolUris()));
                                }
                            }
                        }
                    }
                    // persist volume in db
                    dbClient.updateAndReindexObject(preExistingVolume);
                }
            }
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume type information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

CIMProperty (javax.cim.CIMProperty)75 CIMObjectPath (javax.cim.CIMObjectPath)58 CIMInstance (javax.cim.CIMInstance)37 ArrayList (java.util.ArrayList)26 WBEMException (javax.wbem.WBEMException)25 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)18 CIMArgument (javax.cim.CIMArgument)16 WBEMClient (javax.wbem.client.WBEMClient)14 IOException (java.io.IOException)11 Volume (com.emc.storageos.db.client.model.Volume)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10 URI (java.net.URI)9 ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)8 UnsignedInteger16 (javax.cim.UnsignedInteger16)8 DbClient (com.emc.storageos.db.client.DbClient)7 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 HashMap (java.util.HashMap)6 ExportMask (com.emc.storageos.db.client.model.ExportMask)5 Initiator (com.emc.storageos.db.client.model.Initiator)5