Search in sources :

Example 61 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class CimSubscriptionManager method createInstance.

/**
 * Creates an instance in the CIMOM.
 *
 * The instance name is included as one of the properties and/or derived by
 * the CIMOM.
 *
 * @param className The CIM class name.
 * @param properties The CIM properties.
 *
 * @return The CIM object path of the instance.
 *
 * @throws WBEMException
 */
private CIMObjectPath createInstance(String className, CIMProperty<?>[] properties) throws WBEMException {
    s_logger.trace("className :{}", className);
    s_logger.trace("properties :{}", properties);
    WBEMClient cimClient = _connection.getCimClient();
    String interopNS = _connection.getInteropNamespace();
    CIMObjectPath path = CimObjectPathCreator.createInstance(className, interopNS);
    CIMInstance instance = new CIMInstance(path, properties);
    s_logger.trace("interopNS :{}", interopNS);
    s_logger.trace("path :{}", path);
    path = cimClient.createInstance(instance);
    s_logger.debug("Created: {}", path);
    return path;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance)

Example 62 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class CimSubscriptionManager method enumerateSubscriptions.

/**
 * Finds all of the CIM_Subscription objects that look like they were
 * created for this manager's connection. This is useful for rounding up and
 * removing stale subscriptions in the CIMOM.
 *
 * This works by looking for subscriptions that are attached to the handler
 * for this connection. The name of the handler is fixed by its destination
 * properties, so all subscriptions for a destination are going to be
 * attached to the same handler whose name is more or less predictable (if
 * created by this class).
 *
 * @return The set of subscriptions that look like they were created for
 *         this manager's connection.
 *
 * @throws WBEMException, ConnectionManagerException
 */
private Set<CIMObjectPath> enumerateSubscriptions() throws WBEMException, ConnectionManagerException {
    CIMInstance subscription;
    CIMProperty<?> property;
    CIMObjectPath subscriptionHandlerPath;
    Object subscriptionHandlerName;
    Set<CIMObjectPath> subscriptionSet = new HashSet<CIMObjectPath>();
    WBEMClient cimClient = _connection.getCimClient();
    String interopNS = _connection.getInteropNamespace();
    CIMObjectPath subscriptionPath = CimObjectPathCreator.createInstance(CimConstants.CIM_SUBSCRIPTION_NAME, interopNS);
    CloseableIterator<CIMInstance> subscriptionIter = null;
    try {
        subscriptionIter = cimClient.enumerateInstances(subscriptionPath, true, true, false, null);
        while (subscriptionIter.hasNext()) {
            subscription = subscriptionIter.next();
            property = subscription.getProperty(CimConstants.SUBSCRIPTION_PROP_HANDLER);
            subscriptionHandlerPath = (CIMObjectPath) property.getValue();
            subscriptionHandlerName = subscriptionHandlerPath.getKey(CimConstants.NAME_KEY).getValue();
            if (subscriptionHandlerName.equals(getHandler().getKey(CimConstants.NAME_KEY).getValue())) {
                subscriptionPath = subscription.getObjectPath();
                s_logger.debug("Found: {}", subscriptionPath);
                subscriptionSet.add(subscriptionPath);
            }
        }
    } finally {
        if (subscriptionIter != null) {
            subscriptionIter.close();
        }
    }
    return subscriptionSet;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) WBEMClient(javax.wbem.client.WBEMClient) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

Example 63 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class VnxExportOperations method updateStorageGroupPolicyAndLimits.

/**
 * Updates Auto-tiering policy for the given volumes.
 *
 * @param storage
 *            the storage
 * @param exportMask
 *            the export mask
 * @param volumeURIs
 *            the volume uris
 * @param newVirtualPool
 *            the new virtual pool where policy name can be obtained
 * @param rollback
 *            boolean to know if it is called as a roll back step from workflow.
 * @param taskCompleter
 * @throws Exception
 *             the exception
 */
@Override
public void updateStorageGroupPolicyAndLimits(StorageSystem storage, ExportMask exportMask, List<URI> volumeURIs, VirtualPool newVirtualPool, boolean rollback, TaskCompleter taskCompleter) throws Exception {
    String message = rollback ? ("updateAutoTieringPolicy" + "(rollback)") : ("updateAutoTieringPolicy");
    _log.info("{} {} START...", storage.getSerialNumber(), message);
    _log.info("{} : volumeURIs: {}", message, volumeURIs);
    try {
        String newPolicyName = ControllerUtils.getFastPolicyNameFromVirtualPool(_dbClient, storage, newVirtualPool);
        _log.info("{} : AutoTieringPolicy: {}", message, newPolicyName);
        List<Volume> volumes = _dbClient.queryObject(Volume.class, volumeURIs);
        /**
         * get tier methodology for policy name
         * volume has tier methodology as '4' when no policy set (START_HIGH_THEN_AUTO_TIER).
         *
         * For VNX, Policy is set on Volumes during creation.
         */
        int storageTierMethodologyId = DEFAULT_STORAGE_TIER_METHODOLOGY;
        if (!Constants.NONE.equalsIgnoreCase(newPolicyName)) {
            storageTierMethodologyId = getStorageTierMethodologyFromPolicyName(newPolicyName);
        }
        // Build list of native ids
        Set<String> nativeIds = new HashSet<String>();
        for (Volume volume : volumes) {
            nativeIds.add(volume.getNativeId());
        }
        _log.info("Native Ids of Volumes: {}", nativeIds);
        CimConnection connection = _helper.getConnection(storage);
        WBEMClient client = connection.getCimClient();
        // CIMObjectPath replicationSvc = _cimPath.getControllerReplicationSvcPath(storage);
        String[] memberNames = nativeIds.toArray(new String[nativeIds.size()]);
        CIMObjectPath[] volumePaths = _cimPath.getVolumePaths(storage, memberNames);
        CIMProperty[] inArgs = _helper.getModifyStorageTierMethodologyIdInputArguments(storageTierMethodologyId);
        for (CIMObjectPath volumeObject : volumePaths) {
            if (_helper.getVolumeStorageTierMethodologyId(storage, volumeObject) == storageTierMethodologyId) {
                _log.info("Current and new Storage Tier Methodology Ids are same '{}'." + " No need to update it on Volume Object Path {}.", storageTierMethodologyId, volumeObject);
            } else {
                CIMInstance modifiedSettingInstance = new CIMInstance(volumeObject, inArgs);
                _log.info("Updating Storage Tier Methodology ({}) on Volume Object Path {}.", storageTierMethodologyId, volumeObject);
                client.modifyInstance(modifiedSettingInstance, SmisConstants.PS_EMC_STORAGE_TIER_METHODOLOGY);
            }
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        String errMsg = String.format("An error occurred while updating Auto-tiering policy for Volumes %s", volumeURIs);
        _log.error(errMsg, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailedMsg(errMsg, e);
        taskCompleter.error(_dbClient, serviceError);
    }
    _log.info("{} {} END...", storage.getSerialNumber(), message);
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) HashSet(java.util.HashSet)

Example 64 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class VnxExportOperations method addVolumes.

/*
     * (non-Javadoc)
     *
     * @see
     * com.emc.storageos.volumecontroller.impl.smis.ExportMaskOperations#addVolume(com.emc.storageos.db.client.model.
     * StorageSystem, java.net.URI, com.emc.storageos.volumecontroller.impl.VolumeURIHLU[],
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void addVolumes(StorageSystem storage, URI exportMaskURI, VolumeURIHLU[] volumeURIHLUs, List<Initiator> initiatorList, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} addVolumes START...", storage.getSerialNumber());
    try {
        _log.info("addVolumes: Export mask id: {}", exportMaskURI);
        _log.info("addVolumes: volume-HLU pairs: {}", Joiner.on(',').join(volumeURIHLUs));
        if (initiatorList != null) {
            _log.info("addVolumes: initiators impacted: {}", Joiner.on(',').join(initiatorList));
        }
        ExportOperationContext context = new VnxExportOperationContext();
        // Prime the context object
        taskCompleter.updateWorkflowStepContext(context);
        // Determine if the volume is already in the masking view.
        // If so, log and remove from volumes we need to process.
        ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
        CIMInstance maskingView = _helper.getLunMaskingProtocolController(storage, mask);
        Map<String, Integer> discoveredVolumes = new HashMap<String, Integer>();
        if (maskingView != null) {
            WBEMClient client = _helper.getConnection(storage).getCimClient();
            // Get volumes for the masking instance
            discoveredVolumes = _helper.getVolumesFromLunMaskingInstance(client, maskingView);
        }
        List<VolumeURIHLU> removeURIs = new ArrayList<>();
        for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
            BlockObject bo = BlockObject.fetch(_dbClient, volumeUriHLU.getVolumeURI());
            if (discoveredVolumes.keySet().contains(bo.getNativeId())) {
                _log.info("Found volume {} is already associated with masking view.  Assuming this is from a previous operation.", bo.getLabel());
                removeURIs.add(volumeUriHLU);
            }
        }
        // Create the new array of volumes that don't exist yet in the masking view.
        VolumeURIHLU[] addVolumeURIHLUs = new VolumeURIHLU[volumeURIHLUs.length - removeURIs.size()];
        int index = 0;
        for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
            if (!removeURIs.contains(volumeUriHLU)) {
                addVolumeURIHLUs[index++] = volumeUriHLU;
            }
        }
        CIMObjectPath[] protocolControllers = createOrGrowStorageGroup(storage, exportMaskURI, addVolumeURIHLUs, null, null, taskCompleter);
        CimConnection cimConnection = _helper.getConnection(storage);
        ExportMaskOperationsHelper.populateDeviceNumberFromProtocolControllers(_dbClient, cimConnection, exportMaskURI, addVolumeURIHLUs, protocolControllers, taskCompleter);
        // Test mechanism to invoke a failure. No-op on production systems.
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_002);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Unexpected error: addVolumes failed.", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("addVolumes", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    _log.info("{} addVolumes END...", storage.getSerialNumber());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) ExportOperationContext(com.emc.storageos.volumecontroller.impl.utils.ExportOperationContext) CimConnection(com.emc.storageos.cimadapter.connections.cim.CimConnection) WBEMClient(javax.wbem.client.WBEMClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Example 65 with WBEMClient

use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.

the class VmaxExportOperations method createOrSelectSLOBasedStorageGroup.

/**
 * This is used only for VMAX3.
 */
private CIMObjectPath createOrSelectSLOBasedStorageGroup(StorageSystem storage, URI exportMaskURI, Collection<Initiator> initiators, VolumeURIHLU[] volumeURIHLUs, String parentGroupName, Map<StorageGroupPolicyLimitsParam, CIMObjectPath> newlyCreatedChildVolumeGroups, TaskCompleter taskCompleter) throws Exception {
    List<CIMObjectPath> childVolumeGroupsToBeAddedToParentGroup = new ArrayList<CIMObjectPath>();
    String groupName = null;
    CIMObjectPath groupPath = null;
    ExportMask mask = _dbClient.queryObject(ExportMask.class, exportMaskURI);
    // group volumes based on policy
    ListMultimap<StorageGroupPolicyLimitsParam, VolumeURIHLU> policyToVolumeGroup = ArrayListMultimap.create();
    WBEMClient client = _helper.getConnection(storage).getCimClient();
    for (VolumeURIHLU volumeUriHLU : volumeURIHLUs) {
        StorageGroupPolicyLimitsParam sgPolicyLimitsParam = null;
        URI boUri = volumeUriHLU.getVolumeURI();
        BlockObject bo = BlockObject.fetch(_dbClient, boUri);
        String policyName = volumeUriHLU.getAutoTierPolicyName();
        boolean fastAssociatedAlready = false;
        // Also note that Volumes with Compression set to true are also fast managed below is for vmax3.
        if (_helper.isFastPolicy(policyName) || volumeUriHLU.getCompression()) {
            policyName = _helper.getVMAX3FastSettingForVolume(boUri, policyName);
            fastAssociatedAlready = _helper.checkVolumeAssociatedWithAnySGWithPolicy(bo.getNativeId(), storage, policyName);
        }
        // should not be created with a FAST policy assigned.
        if (fastAssociatedAlready || isRPJournalVolume(bo)) {
            _log.info("Forcing policy name to NONE to prevent volume from using FAST policy.");
            volumeUriHLU.setAutoTierPolicyName(Constants.NONE);
            // Compression was applied on existing SG associated with policy!!
            volumeUriHLU.setCompression(false);
            sgPolicyLimitsParam = new StorageGroupPolicyLimitsParam(Constants.NONE, volumeUriHLU.getHostIOLimitBandwidth(), volumeUriHLU.getHostIOLimitIOPs(), storage);
        } else {
            sgPolicyLimitsParam = new StorageGroupPolicyLimitsParam(volumeUriHLU, storage, _helper);
        }
        policyToVolumeGroup.put(sgPolicyLimitsParam, volumeUriHLU);
    }
    _log.info("{} Groups generated based on grouping volumes by fast policy", policyToVolumeGroup.size());
    /**
     * Grouped Volumes based on Fast Policy
     */
    for (Entry<StorageGroupPolicyLimitsParam, Collection<VolumeURIHLU>> policyToVolumeGroupEntry : policyToVolumeGroup.asMap().entrySet()) {
        List<CIMObjectPath> childVolumeGroupsToBeAdded = new ArrayList<CIMObjectPath>();
        StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = policyToVolumeGroupEntry.getKey();
        ListMultimap<String, VolumeURIHLU> expectedVolumeHluMap = ControllerUtils.getVolumeNativeGuids(policyToVolumeGroupEntry.getValue(), _dbClient);
        Map<String, Set<String>> existingGroupPaths;
        /**
         * Find any existing Storage Groups can be reused, in
         * case of Fast Enabled volumes
         */
        _log.info("Running Storage Group Selection Process");
        existingGroupPaths = _helper.findAnyStorageGroupsCanBeReUsed(storage, expectedVolumeHluMap, storageGroupPolicyLimitsParam);
        _log.info("Existing Storage Groups Found :" + Joiner.on("\t").join(existingGroupPaths.keySet()));
        if (existingGroupPaths.size() > 0) {
            if (existingGroupPaths.size() > 0) {
                childVolumeGroupsToBeAdded.addAll(_helper.constructMaskingGroupPathsFromNames(existingGroupPaths.keySet(), storage));
            }
        }
        Set<String> volumesInExistingStorageGroups = _helper.constructVolumeNativeGuids(existingGroupPaths.values());
        _log.debug("Volumes part of existing reusable Storage Groups {}", Joiner.on("\t").join(volumesInExistingStorageGroups));
        // Storage Group needs to be created for those volumes,
        // which doesn't fit into
        // existing groups.
        Set<String> diff = Sets.difference(expectedVolumeHluMap.asMap().keySet(), volumesInExistingStorageGroups);
        _log.debug("Remaining Volumes, for which new Storage Group needs to be created", Joiner.on("\t").join(diff));
        // need to construct a new group for remaining volumes.
        if (!diff.isEmpty()) {
            VolumeURIHLU[] volumeURIHLU = ControllerUtils.constructVolumeUriHLUs(diff, expectedVolumeHluMap);
            // TODO: VMAX3 customized names
            groupName = generateStorageGroupName(storage, mask, initiators, storageGroupPolicyLimitsParam);
            _log.debug("Group Name Created :", groupName);
            groupPath = createVolumeGroup(storage, groupName, volumeURIHLU, taskCompleter, true);
            _log.info("{} Volume Group created on Array {}", storage.getSerialNumber());
        }
        if (null != groupPath) {
            /**
             * used later in deleting created groups on failure
             */
            newlyCreatedChildVolumeGroups.put(storageGroupPolicyLimitsParam, groupPath);
            childVolumeGroupsToBeAdded.add(groupPath);
        }
        childVolumeGroupsToBeAddedToParentGroup.addAll(childVolumeGroupsToBeAdded);
    }
    // Avoid duplicate names for the Cascaded VolumeGroup
    parentGroupName = _helper.generateGroupName(_helper.getExistingStorageGroupsFromArray(storage), parentGroupName);
    CIMObjectPath cascadedGroupPath = createCascadedVolumeGroup(storage, parentGroupName, childVolumeGroupsToBeAddedToParentGroup, taskCompleter);
    // for proper roll back , that is volume removal, if exception is thrown during update
    for (Entry<StorageGroupPolicyLimitsParam, CIMObjectPath> createdChildVolumeGroupEntry : newlyCreatedChildVolumeGroups.entrySet()) {
        CIMObjectPath childGroupPath = createdChildVolumeGroupEntry.getValue();
        StorageGroupPolicyLimitsParam storageGroupPolicyLimitsParam = createdChildVolumeGroupEntry.getKey();
        if (storageGroupPolicyLimitsParam.isHostIOLimitBandwidthSet()) {
            _helper.updateHostIOLimitBandwidth(client, childGroupPath, storageGroupPolicyLimitsParam.getHostIOLimitBandwidth());
        }
        if (storageGroupPolicyLimitsParam.isHostIOLimitIOPsSet()) {
            _helper.updateHostIOLimitIOPs(client, childGroupPath, storageGroupPolicyLimitsParam.getHostIOLimitIOPs());
        }
    }
    return cascadedGroupPath;
}
Also used : Set(java.util.Set) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ExportMask(com.emc.storageos.db.client.model.ExportMask) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) URI(java.net.URI) Collection(java.util.Collection) StorageGroupPolicyLimitsParam(com.emc.storageos.volumecontroller.impl.StorageGroupPolicyLimitsParam) WBEMClient(javax.wbem.client.WBEMClient) BlockObject(com.emc.storageos.db.client.model.BlockObject) VolumeURIHLU(com.emc.storageos.volumecontroller.impl.VolumeURIHLU)

Aggregations

WBEMClient (javax.wbem.client.WBEMClient)110 CIMObjectPath (javax.cim.CIMObjectPath)75 CIMInstance (javax.cim.CIMInstance)69 WBEMException (javax.wbem.WBEMException)42 ArrayList (java.util.ArrayList)39 URI (java.net.URI)35 DbClient (com.emc.storageos.db.client.DbClient)29 Volume (com.emc.storageos.db.client.model.Volume)29 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)27 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)25 HashSet (java.util.HashSet)25 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)24 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)18 HashMap (java.util.HashMap)17 ExportMask (com.emc.storageos.db.client.model.ExportMask)16 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)16 CIMProperty (javax.cim.CIMProperty)14 UnsignedInteger32 (javax.cim.UnsignedInteger32)14 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)13