Search in sources :

Example 1 with UnsignedInteger32

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

the class BrocadeNetworkSMIS method addZoneAlias.

/**
 * Create an instance of an alias object on the switch. The alias object can have
 * a single member that has to be of type WWN.
 * <p>
 * This function will retry if the alias creation fails because the session is lost or timed out. The total number of tries is set to 2.
 *
 * @param client an instance of WBEMClient with an open session to SMI provider
 * @param zoneServiceIns an instance of zone service for the fabric
 * @param fabricId the fabric name
 * @param fabricWwn the fabric WWN
 * @param alias the object containing the attributes of the alias to be created
 * @throws WBEMException
 */
@SuppressWarnings("rawtypes")
public CIMObjectPath addZoneAlias(WBEMClient client, CIMInstance zoneServiceIns, String fabricId, String fabricWwn, ZoneWwnAlias alias) throws WBEMException {
    CIMObjectPath aliasPath = null;
    CIMArgument[] outargs = new CIMArgument[1];
    CIMArgument[] inargs = new CIMArgument[1];
    inargs[0] = _cimArgumentFactory.string(_CollectionAlias, alias.getName());
    _log.info("Creating alias: " + alias.getName());
    UnsignedInteger32 result = new UnsignedInteger32(Integer.MAX_VALUE);
    int count = 0;
    while (result.intValue() != 0 && count < 2) {
        result = (UnsignedInteger32) client.invokeMethod(zoneServiceIns.getObjectPath(), _CreateZoneAlias, inargs, outargs);
        if (result.intValue() == 0 && outargs[0].getValue() != null) {
            aliasPath = (CIMObjectPath) outargs[0].getValue();
            _log.info("Created alias: " + alias.getName() + " with path " + aliasPath);
            break;
        } else if (result.intValue() == 32770) {
            // session timed out or was stolen
            _log.info("Created alias: " + alias.getName() + " failed with result.intvalue() 32770: " + "Transaction Not Started. Retry to get a new session lock.");
            endSession(client, zoneServiceIns, false);
            zoneServiceIns = startSession(client, fabricId, fabricWwn);
            count++;
        } else {
            throw new NetworkDeviceControllerException("Created alias failed: " + alias.getName() + " with result.intValue() " + result.intValue());
        }
    }
    if (aliasPath == null) {
        if (count >= 2) {
            _log.info("Failed to create alias " + alias.getName() + ". The maximum number of retries (" + (count + 1) + ") was reached without successfully starting a transaction.");
        }
    } else {
        // add WWN as alias member to alias
        addZoneOrAliasMember(client, zoneServiceIns, fabricWwn, aliasPath, alias.getAddress());
    }
    return aliasPath;
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMArgument(javax.cim.CIMArgument)

Example 2 with UnsignedInteger32

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

the class BrocadeNetworkSMIS method addZoneOrAliasMember.

/**
 * Add a member to a zone or alias. The member can be a WWN or an alias
 * name when the entity modified is a zone. The member can only be a WWN when
 * the entity modified is an alias.
 *
 * @param client an instance of WBEMClient with an open session to SMI provider
 * @param zoneServiceIns an instance of zone service for the fabric
 * @param fabricWwn the fabric WWN
 * @param zonePath the CIM path of the zone object
 * @param member to be added to the zone or alias.
 * @return the CIM path to the newly created alias
 * @throws WBEMException
 */
@SuppressWarnings("rawtypes")
public boolean addZoneOrAliasMember(WBEMClient client, CIMInstance zoneServiceIns, String fabricWwn, CIMObjectPath zonePath, String member) throws WBEMException {
    CIMArgument[] outargs = new CIMArgument[1];
    CIMArgument[] inargs = null;
    UnsignedInteger32 result = null;
    if (EndpointUtility.isValidEndpoint(member, EndpointType.WWN)) {
        _log.info("Add zone or alias member of type wwn " + member);
        inargs = new CIMArgument[3];
        inargs[0] = _cimArgumentFactory.uint16(_ConnectivityMemberType, 2);
        inargs[1] = _cimArgumentFactory.string(_ConnectivityMemberID, member.replaceAll(":", ""));
        inargs[2] = _cimArgumentFactory.reference(_SystemSpecificCollection, zonePath);
        result = (UnsignedInteger32) client.invokeMethod(zoneServiceIns.getObjectPath(), _CreateZoneMembershipSettingData, inargs, outargs);
    } else {
        _log.info("Add zoneor alias  member of type alias " + member);
        inargs = new CIMArgument[2];
        inargs[0] = _cimArgumentFactory.reference(_Zone, zonePath);
        CIMObjectPath aliasPath = getZoneAliasPath(member, fabricWwn);
        inargs[1] = _cimArgumentFactory.reference(_ZoneAlias, aliasPath);
        result = (UnsignedInteger32) client.invokeMethod(zoneServiceIns.getObjectPath(), _AddZoneAlias, inargs, outargs);
    }
    _log.info("Add zone or alias member returned code " + result.toString());
    // 0 means success and 8 means member already exists
    return result.intValue() == 0 || result.intValue() == 8;
}
Also used : UnsignedInteger32(javax.cim.UnsignedInteger32) CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 3 with UnsignedInteger32

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

the class BrocadeNetworkSMIS method createZoneSet.

@SuppressWarnings("rawtypes")
public CIMObjectPath createZoneSet(WBEMClient client, CIMInstance zoneServiceIns, String zoneSetName) throws WBEMException {
    CIMArgument[] inargs = new CIMArgument[1];
    inargs[0] = _cimArgumentFactory.string(_ZoneSetName, zoneSetName);
    CIMArgument[] outargs = new CIMArgument[1];
    UnsignedInteger32 result = (UnsignedInteger32) client.invokeMethod(zoneServiceIns.getObjectPath(), _CreateZoneSet, inargs, outargs);
    if (result.intValue() == 0 && outargs.length > 0) {
        return (CIMObjectPath) outargs[0].getValue();
    }
    return null;
}
Also used : UnsignedInteger32(javax.cim.UnsignedInteger32) CIMObjectPath(javax.cim.CIMObjectPath) CIMArgument(javax.cim.CIMArgument)

Example 4 with UnsignedInteger32

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

the class DCNMDialog method startSession.

/**
 * @param client
 * @param zonesetService -- Instance of the ZonesetService
 * @return true iff session is started
 * @throws NetworkControllerSessionLockedException
 * @throws WBEMException
 */
@SuppressWarnings("rawtypes")
public boolean startSession(WBEMClient client, CIMInstance zonesetService) throws NetworkControllerSessionLockedException, WBEMException {
    UnsignedInteger32 result = null;
    try {
        int sessionState = cimIntegerProperty(zonesetService, "SessionState");
        int RequestedSessionState = cimIntegerProperty(zonesetService, "RequestedSessionState");
        if (sessionState == _notApplicable) {
            // no session control implemented by this agent
            return true;
        }
        // if (sessionState != _ended || RequestedSessionState != _noChange) {
        // _log.error("Zone session is locked by another user or agent.");
        // throw new NetworkControllerSessionLockedException(
        // "Zone session is locked by another user or agent.");
        // }
        CIMArgument[] inargs = new CIMArgument[] { _cimArgumentFactory.uint16("RequestedSessionState", _started) };
        result = (UnsignedInteger32) client.invokeMethod(zonesetService.getObjectPath(), "SessionControl", inargs, new CIMArgument[1]);
        _log.info("Start session returned code: " + result.intValue());
        return (result.intValue() == 0 || result.intValue() == 32772);
    } catch (WBEMException ex) {
        _log.error("Encountered an exception while trying to start a zone session." + ex.getLocalizedMessage());
        throw ex;
    }
}
Also used : UnsignedInteger32(javax.cim.UnsignedInteger32) WBEMException(javax.wbem.WBEMException) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) CIMArgument(javax.cim.CIMArgument)

Example 5 with UnsignedInteger32

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

the class StorageVolumeViewProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    EnumerateResponse<CIMInstance> volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    _dbClient = (DbClient) keyMap.get(Constants.dbClient);
    _updateVolumes = new ArrayList<Volume>();
    _updateSnapShots = new ArrayList<BlockSnapshot>();
    _updateMirrors = new ArrayList<BlockMirror>();
    CloseableIterator<CIMInstance> volumeInstances = null;
    try {
        _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
        if (_metaVolumeViewPaths == null) {
            _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
        }
        // create empty place holder list for meta volume paths (cannot define this in xml)
        List<CIMObjectPath> metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (metaVolumePaths == null) {
            keyMap.put(Constants.META_VOLUMES, new ArrayList<CIMObjectPath>());
        }
        CIMObjectPath storagePoolPath = getObjectPathfromCIMArgument(_args);
        volumeInstances = volumeInstanceChunks.getResponses();
        processVolumes(volumeInstances, keyMap);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), keyMap);
        }
        // if list empty, this method returns back immediately.
        // partition size might not be used in this context, as batch size < partition size.
        // TODO metering might need some extra work to push volumes in batches, hence not changing this method
        // signature
        _partitionManager.updateInBatches(_updateVolumes, getPartitionSize(keyMap), _dbClient, VOLUME);
        _partitionManager.updateInBatches(_updateSnapShots, getPartitionSize(keyMap), _dbClient, BLOCK_SNAPSHOT);
        _partitionManager.updateInBatches(_updateMirrors, getPartitionSize(keyMap), _dbClient, BLOCK_MIRROR);
    } catch (Exception e) {
        _logger.error("Processing Volumes and Snapshots failed", e);
    } finally {
        _updateVolumes = null;
        _updateSnapShots = null;
        _updateMirrors = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) CIMInstance(javax.cim.CIMInstance) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) List(java.util.List) WBEMClient(javax.wbem.client.WBEMClient) EnumerateResponse(javax.wbem.client.EnumerateResponse)

Aggregations

UnsignedInteger32 (javax.cim.UnsignedInteger32)29 CIMObjectPath (javax.cim.CIMObjectPath)22 CIMArgument (javax.cim.CIMArgument)15 WBEMClient (javax.wbem.client.WBEMClient)14 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)11 CIMInstance (javax.cim.CIMInstance)11 WBEMException (javax.wbem.WBEMException)7 FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)6 StoragePool (com.emc.storageos.db.client.model.StoragePool)6 EnumerateResponse (javax.wbem.client.EnumerateResponse)5 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)4 Volume (com.emc.storageos.db.client.model.Volume)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 CimConnection (com.emc.storageos.cimadapter.connections.cim.CimConnection)3 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 IOException (java.io.IOException)3