Search in sources :

Example 1 with CinderEndPointInfo

use of com.emc.storageos.cinder.CinderEndPointInfo in project coprhd-controller by CoprHD.

the class CinderStorageDevice method doDeleteVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes
     * (com.emc.storageos.db.client.model.StorageSystem,
     * java.lang.String,
     * java.util.List,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<String> volumeNativeIdsToDelete = new ArrayList<String>(volumes.size());
        List<String> volumeLabels = new ArrayList<String>(volumes.size());
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
        log.info(logMsgBuilder.toString());
        MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        for (Volume volume : volumes) {
            logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
            try {
                // Check if the volume is present on the back-end device
                cinderApi.showVolume(volume.getNativeId());
            } catch (CinderException ce) {
                // This means, the volume is not present on the back-end device
                log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                dbClient.persistObject(volume);
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(dbClient);
                continue;
            }
            volumeNativeIdsToDelete.add(volume.getNativeId());
            volumeLabels.add(volume.getLabel());
            // cleanup if there are any snapshots created for a volume
            cleanupAnyBackupSnapshots(volume, cinderApi);
        }
        // Now - trigger the delete
        if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
            cinderApi.deleteVolumes(volumeNativeIdsToDelete.toArray(new String[] {}));
            ControllerServiceImpl.enqueueJob(new QueueJob(new CinderDeleteVolumeJob(volumeNativeIdsToDelete.get(0), volumeLabels.get(0), volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter)));
        } else {
            // If we are here, there are no volumes to delete, we have
            // invoked ready() for the VolumeDeleteCompleter, and told
            // the multiVolumeTaskCompleter to skip these completers.
            // In this case, the multiVolumeTaskCompleter complete()
            // method will not be invoked and the result is that the
            // workflow that initiated this delete request will never
            // be updated. So, here we just call complete() on the
            // multiVolumeTaskCompleter to ensure the workflow status is
            // updated.
            multiVolumeTaskCompleter.ready(dbClient);
        }
    } catch (Exception e) {
        log.error("Problem in doDeleteVolume: ", e);
        ServiceError error = DeviceControllerErrors.cinder.operationFailed("doDeleteVolume", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    log.info(logMsgBuilder.toString());
}
Also used : CinderException(com.emc.storageos.cinder.errorhandling.CinderException) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CinderDeleteVolumeJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderDeleteVolumeJob) ArrayList(java.util.ArrayList) CinderApi(com.emc.storageos.cinder.api.CinderApi) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) CinderException(com.emc.storageos.cinder.errorhandling.CinderException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 2 with CinderEndPointInfo

use of com.emc.storageos.cinder.CinderEndPointInfo in project coprhd-controller by CoprHD.

the class CinderUtils method getCinderEndPoint.

/**
 * Gets the cinder endpoint info to access the endpoint
 *
 * @param storageProviderURi
 * @return
 */
public static CinderEndPointInfo getCinderEndPoint(URI storageProviderURi, DbClient dbClient) {
    StorageProvider provider = dbClient.queryObject(StorageProvider.class, storageProviderURi);
    // Get the persisted end point info
    StringMap endPointKeys = provider.getKeys();
    String hostName = endPointKeys.get(CinderConstants.KEY_CINDER_HOST_NAME);
    String password = endPointKeys.get(CinderConstants.KEY_CINDER_REST_PASSWORD);
    String userName = endPointKeys.get(CinderConstants.KEY_CINDER_REST_USER);
    String tenantName = endPointKeys.get(CinderConstants.KEY_CINDER_TENANT_NAME);
    String tenantId = endPointKeys.get(CinderConstants.KEY_CINDER_TENANT_ID);
    String baseUri = endPointKeys.get(CinderConstants.KEY_CINDER_REST_URI_BASE);
    String token = endPointKeys.get(CinderConstants.KEY_CINDER_REST_TOKEN);
    CinderEndPointInfo ep = new CinderEndPointInfo(hostName, userName, password, tenantName);
    if (baseUri.startsWith(CinderConstants.HTTP_URL)) {
        ep.setCinderBaseUriHttp(baseUri);
    } else {
        ep.setCinderBaseUriHttps(baseUri);
    }
    ep.setCinderToken(token);
    ep.setCinderTenantId(tenantId);
    return ep;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) StorageProvider(com.emc.storageos.db.client.model.StorageProvider)

Example 3 with CinderEndPointInfo

use of com.emc.storageos.cinder.CinderEndPointInfo in project coprhd-controller by CoprHD.

the class CinderCloneOperations method createSingleClone.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.CloneOperations#createSingleClone(
     * com.emc.storageos.db.client.model.StorageSystem, java.net.URI, java.net.URI,
     * java.lang.Boolean,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceObject, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
    log.info("START createSingleClone operation");
    boolean isVolumeClone = true;
    try {
        BlockObject sourceObj = BlockObject.fetch(dbClient, sourceObject);
        URI tenantUri = null;
        if (sourceObj instanceof BlockSnapshot) {
            // In case of snapshot, get the tenant from its parent volume
            NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
            Volume parentVolume = dbClient.queryObject(Volume.class, parentVolUri);
            tenantUri = parentVolume.getTenant().getURI();
            isVolumeClone = false;
        } else {
            // This is a default flow
            tenantUri = ((Volume) sourceObj).getTenant().getURI();
            isVolumeClone = true;
        }
        Volume cloneObj = dbClient.queryObject(Volume.class, cloneVolume);
        StoragePool targetPool = dbClient.queryObject(StoragePool.class, cloneObj.getPool());
        TenantOrg tenantOrg = dbClient.queryObject(TenantOrg.class, tenantUri);
        // String cloneLabel = generateLabel(tenantOrg, cloneObj);
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        String volumeId = "";
        if (isVolumeClone) {
            volumeId = cinderApi.cloneVolume(cloneObj.getLabel(), (cloneObj.getCapacity() / (1024 * 1024 * 1024)), targetPool.getNativeId(), sourceObj.getNativeId());
        } else {
            volumeId = cinderApi.createVolumeFromSnapshot(cloneObj.getLabel(), (cloneObj.getCapacity() / (1024 * 1024 * 1024)), targetPool.getNativeId(), sourceObj.getNativeId());
        }
        log.debug("Creating volume with the id " + volumeId + " on Openstack cinder node");
        if (volumeId != null) {
            // Cinder volume/snapshot clones are not sync with source, so
            // set the replication state as DETACHED
            cloneObj.setReplicaState(ReplicationState.DETACHED.name());
            dbClient.persistObject(cloneObj);
            Map<String, URI> volumeIds = new HashMap<String, URI>();
            volumeIds.put(volumeId, cloneObj.getId());
            ControllerServiceImpl.enqueueJob(new QueueJob(new CinderSingleVolumeCreateJob(volumeId, cloneObj.getLabel(), storageSystem.getId(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, targetPool.getId(), volumeIds)));
        }
    } catch (InternalException e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceObject, cloneVolume);
        log.error(errorMsg, e);
        taskCompleter.error(dbClient, e);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceObject, cloneVolume);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("createSingleClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CinderApi(com.emc.storageos.cinder.api.CinderApi) CinderSingleVolumeCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderSingleVolumeCreateJob) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 4 with CinderEndPointInfo

use of com.emc.storageos.cinder.CinderEndPointInfo in project coprhd-controller by CoprHD.

the class CinderCommunicationInterface method discover.

/**
 * Get volume types, and create a storage pool for each volume type
 */
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
    if ((null != accessProfile.getnamespace()) && (accessProfile.getnamespace().equals(StorageSystem.Discovery_Namespaces.UNMANAGED_VOLUMES.toString()))) {
        discoverUnManagedVolumes(accessProfile);
    } else {
        _logger.info("Discovery started for system {}", accessProfile.getSystemId());
        List<StoragePool> newPools = new ArrayList<StoragePool>();
        List<StoragePool> updatePools = new ArrayList<StoragePool>();
        List<StoragePool> allPools = new ArrayList<StoragePool>();
        String token = "";
        StorageSystem system = null;
        StorageProvider provider = null;
        String detailedStatusMessage = "Unknown Status";
        try {
            String hostName = null;
            String restuserName = null;
            String restPassword = null;
            String restBaseUri = null;
            String tenantName = null;
            String oldToken = null;
            String tenantId = null;
            system = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
            system.setReachableStatus(true);
            // first add storage ports if necessary
            addPorts(system);
            // now do the pool discovery
            URI providerUri = system.getActiveProviderURI();
            provider = _dbClient.queryObject(StorageProvider.class, providerUri);
            if (null != provider.getKeys()) {
                StringMap providerKeys = provider.getKeys();
                oldToken = providerKeys.get(CinderConstants.KEY_CINDER_REST_TOKEN);
                hostName = providerKeys.get(CinderConstants.KEY_CINDER_HOST_NAME);
                restuserName = providerKeys.get(CinderConstants.KEY_CINDER_REST_USER);
                restPassword = providerKeys.get(CinderConstants.KEY_CINDER_REST_PASSWORD);
                restBaseUri = providerKeys.get(CinderConstants.KEY_CINDER_REST_URI_BASE);
                tenantName = providerKeys.get(CinderConstants.KEY_CINDER_TENANT_NAME);
                tenantId = providerKeys.get(CinderConstants.KEY_CINDER_TENANT_ID);
            }
            if (null == endPointInfo) {
                endPointInfo = new CinderEndPointInfo(hostName, restuserName, restPassword, tenantName);
                if (restBaseUri.startsWith(CinderConstants.HTTP_URL)) {
                    endPointInfo.setCinderBaseUriHttp(restBaseUri);
                } else {
                    endPointInfo.setCinderBaseUriHttps(restBaseUri);
                }
                // Always set the token and tenant id, when new instance is created
                endPointInfo.setCinderToken(oldToken);
                endPointInfo.setCinderTenantId(tenantId);
            }
            CinderApi api = _cinderApiFactory.getApi(providerUri, endPointInfo);
            _logger.debug("discover : Got the cinder api factory for provider with id: {}", providerUri);
            // check if the cinder is authenticated and if the token is valid
            if (null == oldToken || (isTokenExpired(oldToken))) {
                // This means, authentication is required, go and fetch the token
                token = api.getAuthToken(restBaseUri + "/tokens");
                if (null != token) {
                    _logger.debug("Got new token : {}", token);
                    // update the token in the provider
                    provider.addKey(CinderConstants.KEY_CINDER_REST_TOKEN, token);
                    provider.addKey(CinderConstants.KEY_CINDER_TENANT_ID, endPointInfo.getCinderTenantId());
                }
            } else {
                token = oldToken;
                _logger.debug("Using the old token : {}", token);
            }
            if (token.length() > 1) {
                // Now get the number of volume types
                VolumeTypes types = api.getVolumeTypes();
                if (types != null) {
                    _logger.info("Got {} Volume Type(s)", types.volume_types.length);
                    boolean isDefaultStoragePoolCreated = false;
                    for (int i = 0; i < types.volume_types.length; i++) {
                        boolean isNew = false;
                        String poolName = types.volume_types[i].name;
                        String nativeGuid = types.volume_types[i].id;
                        _logger.info("Storage Pool name = {}, id = {}", poolName, nativeGuid);
                        // Now find association with storage system
                        Map<String, String> extra_specs = types.volume_types[i].extra_specs;
                        String system_title = extra_specs.get(VOLUME_BACKEND_NAME);
                        boolean isThickPool = Boolean.parseBoolean(extra_specs.get(VIPR_THICK_POOL));
                        // If no volume backend name, use default
                        if (system_title == null) {
                            system_title = CinderConstants.DEFAULT;
                        }
                        if (system.getNativeGuid().toUpperCase().contains(system_title.toUpperCase())) {
                            // Check if volume type belongs to the default storage system
                            if (system.getNativeGuid().toUpperCase().startsWith(CinderConstants.DEFAULT)) {
                                isDefaultStoragePoolCreated = true;
                            }
                            // do the association
                            _logger.info("Found association between system {} and pool {}", system_title, poolName);
                            StoragePool pool = checkPoolExistsInDB(nativeGuid);
                            if (null == pool) {
                                isNew = true;
                                pool = createPoolforStorageSystem(system, nativeGuid, poolName, isThickPool);
                                newPools.add(pool);
                            }
                            pool.setPoolName(poolName);
                            pool.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
                            pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                            if (!isNew) {
                                updatePools.add(pool);
                            }
                        } else {
                            _logger.info("Pool {} doesn't belong to storage system {}", poolName, system.getLabel());
                        }
                    }
                    // create default storage pool for storage system
                    if (system.getNativeGuid().toUpperCase().startsWith(CinderConstants.DEFAULT) && !isDefaultStoragePoolCreated) {
                        _logger.debug("Creating defual pool for default storage system");
                        String nativeGuid = "DefaultPool";
                        StoragePool pool = checkPoolExistsInDB(nativeGuid);
                        String poolName = "DefaultPool";
                        if (null != pool) {
                            updatePools.add(pool);
                        } else {
                            pool = createPoolforStorageSystem(system, nativeGuid, poolName, false);
                            newPools.add(pool);
                        }
                        pool.setPoolName(poolName);
                        pool.setCompatibilityStatus(CompatibilityStatus.COMPATIBLE.name());
                        pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                    }
                    StoragePoolAssociationHelper.setStoragePoolVarrays(system.getId(), newPools, _dbClient);
                    allPools.addAll(newPools);
                    allPools.addAll(updatePools);
                    StringBuffer errorMessage = new StringBuffer();
                    ImplicitPoolMatcher.matchModifiedStoragePoolsWithAllVpool(allPools, _dbClient, _coordinator, accessProfile.getSystemId(), errorMessage);
                    _logger.info("New pools size: {}", newPools.size());
                    _logger.info("updatePools size: {}", updatePools.size());
                    DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, system.getId());
                    _dbClient.createObject(newPools);
                    _dbClient.persistObject(updatePools);
                    // discovery succeeds
                    detailedStatusMessage = String.format("Discovery completed successfully for OpenStack: %s", accessProfile.getSystemId());
                } else /* if types */
                {
                    _logger.error("Error in getting volume types from cinder");
                }
            } else /* if token length */
            {
                _logger.error("Error in getting token from keystone");
            }
        } catch (Exception e) {
            if (null != system) {
                cleanupDiscovery(system);
            }
            detailedStatusMessage = String.format("Discovery failed for Storage System: %s because %s", system.toString(), e.getLocalizedMessage());
            _logger.error(detailedStatusMessage, e);
            throw new CinderColletionException(false, ServiceCode.DISCOVERY_ERROR, null, detailedStatusMessage, null, null);
        } finally {
            try {
                if (system != null) {
                    system.setLastDiscoveryStatusMessage(detailedStatusMessage);
                    _dbClient.persistObject(system);
                }
                // persist the provider
                if (null != provider) {
                    _dbClient.persistObject(provider);
                }
            } catch (DatabaseException e) {
                _logger.error("Failed to persist cinder storage system to Database, Reason: {}", e.getMessage(), e);
            }
        }
        _logger.info("Discovery Ended for system {}", accessProfile.getSystemId());
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) CinderApi(com.emc.storageos.cinder.api.CinderApi) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) CinderColletionException(com.emc.storageos.volumecontroller.impl.cinder.CinderColletionException) VolumeTypes(com.emc.storageos.cinder.model.VolumeTypes) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) CinderColletionException(com.emc.storageos.volumecontroller.impl.cinder.CinderColletionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with CinderEndPointInfo

use of com.emc.storageos.cinder.CinderEndPointInfo in project coprhd-controller by CoprHD.

the class CinderStorageDevice method doCreateVolumes.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doCreateVolumes
     * (com.emc.storageos.db.client.model.StorageSystem,
     * com.emc.storageos.db.client.model.StoragePool,
     * java.lang.String, java.util.List,
     * com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doCreateVolumes(StorageSystem storageSystem, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
        String tenantName = "";
        try {
            TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
            tenantName = tenant.getLabel();
        } catch (DatabaseException e) {
            log.error("Error lookup TenantOrg object", e);
        }
        label = nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), CinderConstants.CHAR_HYPHEN, SmisConstants.MAX_VOLUME_NAME_LENGTH);
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
    }
    log.info(logMsgBuilder.toString());
    try {
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id {}", storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        String volumeId = null;
        Map<String, URI> volumeIds = new HashMap<String, URI>();
        if (volumes.size() == 1) {
            volumeId = cinderApi.createVolume(label, CinderUtils.convertToGB(capacity), storagePool.getNativeId());
            volumeIds.put(volumeId, volumes.get(0).getId());
            log.debug("Creating volume with the id {} on Openstack cinder node", volumeId);
        } else {
            log.debug("Starting to create {} volumes", volumes.size());
            for (int volumeIndex = 0; volumeIndex < volumes.size(); volumeIndex++) {
                volumeId = cinderApi.createVolume(label + CinderConstants.HYPHEN + (volumeIndex + 1), CinderUtils.convertToGB(capacity), storagePool.getNativeId());
                volumeIds.put(volumeId, volumes.get(volumeIndex).getId());
                log.debug("Creating volume with the id {} on Openstack cinder node", volumeId);
            }
        }
        if (!volumeIds.isEmpty()) {
            CinderJob createVolumeJob = (volumes.size() > 1) ? new CinderMultiVolumeCreateJob(volumeId, label, volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, storagePool.getId(), volumeIds) : new CinderSingleVolumeCreateJob(volumeId, label, volumes.get(0).getStorageController(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, storagePool.getId(), volumeIds);
            ControllerServiceImpl.enqueueJob(new QueueJob(createVolumeJob));
        }
    } catch (final InternalException e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(dbClient, e);
    } catch (final Exception e) {
        log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            dbClient.persistObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) HashMap(java.util.HashMap) CinderApi(com.emc.storageos.cinder.api.CinderApi) CinderSingleVolumeCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderSingleVolumeCreateJob) URI(java.net.URI) CinderJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderJob) CinderException(com.emc.storageos.cinder.errorhandling.CinderException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) CinderMultiVolumeCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderMultiVolumeCreateJob) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Aggregations

CinderEndPointInfo (com.emc.storageos.cinder.CinderEndPointInfo)10 CinderApi (com.emc.storageos.cinder.api.CinderApi)9 Volume (com.emc.storageos.db.client.model.Volume)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)6 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)6 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)6 CinderException (com.emc.storageos.cinder.errorhandling.CinderException)5 ArrayList (java.util.ArrayList)4 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 CinderJob (com.emc.storageos.volumecontroller.impl.cinder.job.CinderJob)3 URI (java.net.URI)3 Initiator (com.emc.storageos.db.client.model.Initiator)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)2 StringMap (com.emc.storageos.db.client.model.StringMap)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 CinderSingleVolumeCreateJob (com.emc.storageos.volumecontroller.impl.cinder.job.CinderSingleVolumeCreateJob)2 HashMap (java.util.HashMap)2