Search in sources :

Example 1 with CIMArgument

use of javax.cim.CIMArgument 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 2 with CIMArgument

use of javax.cim.CIMArgument 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 CIMArgument

use of javax.cim.CIMArgument 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 4 with CIMArgument

use of javax.cim.CIMArgument 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 5 with CIMArgument

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

the class CreatePoolSettingProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    String tierMethodologyToBeUsedForThisCreatedSetting = null;
    try {
        if (resultObj instanceof CIMArgument<?>[]) {
            CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
            CIMObjectPath path = (CIMObjectPath) outputArguments[0].getValue();
            // always set
            int index = (Integer) _args.get(1);
            @SuppressWarnings("unchecked") List<String> poolSettingsList = (List<String>) keyMap.get(Constants.VNXPOOLCAPABILITIES_TIER);
            String poolSettingToTierMethodology = poolSettingsList.get(index);
            tierMethodologyToBeUsedForThisCreatedSetting = poolSettingToTierMethodology.substring(poolSettingToTierMethodology.lastIndexOf(Constants.HYPHEN) + 1, poolSettingToTierMethodology.length());
            String poolCapabilitiesPathAssociatedWiththisSetting = poolSettingToTierMethodology.substring(0, poolSettingToTierMethodology.lastIndexOf(Constants.HYPHEN));
            keyMap.put(path.toString(), poolCapabilitiesPathAssociatedWiththisSetting);
            keyMap.put(path.toString() + Constants.HYPHEN + Constants.TIERMETHODOLOGY, tierMethodologyToBeUsedForThisCreatedSetting);
            addPath(keyMap, operation.getResult(), path);
        }
    } catch (Exception e) {
        _logger.error("Error processing Create Pool Setting with Initial Storage Tiering Methodology : {} : ", tierMethodologyToBeUsedForThisCreatedSetting, e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) List(java.util.List) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMArgument (javax.cim.CIMArgument)234 CIMObjectPath (javax.cim.CIMObjectPath)190 WBEMException (javax.wbem.WBEMException)129 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)127 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)80 ArrayList (java.util.ArrayList)74 CIMInstance (javax.cim.CIMInstance)71 Volume (com.emc.storageos.db.client.model.Volume)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 URI (java.net.URI)39 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)36 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)32 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)26 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)23 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 HashSet (java.util.HashSet)16 List (java.util.List)16 CIMProperty (javax.cim.CIMProperty)16