@Override public void injectColumnsDetails(Stat statObj, DbClient client) throws Exception { ProtectionSystem protectionObj = client.queryObject(ProtectionSystem.class, statObj.getResourceId()); // Given a protection system, find a volume protected by this protection system, // and then extract the project and vpool Volume protectedVolume = null; URIQueryResultList resultList = new URIQueryResultList(); client.queryByConstraint( ContainmentConstraint.Factory.getProtectionSystemVolumesConstraint(protectionObj.getId()), resultList); for (Iterator<URI> volumeItr = resultList.iterator(); volumeItr.hasNext(); ) { Volume volume = client.queryObject(Volume.class, volumeItr.next()); if (volume.getProtectionController().equals(protectionObj.getId())) { protectedVolume = volume; break; } } if (protectedVolume != null) { _logger.info( "Found volume " + protectedVolume.getWWN() + " protected by this protection controller. Get the Cos/Project/Tenant."); statObj.setProject(protectedVolume.getProject().getURI()); statObj.setVirtualPool(protectedVolume.getVirtualPool()); statObj.setTenant(protectedVolume.getTenant().getURI()); } else { statObj.setProject(null); statObj.setVirtualPool(null); statObj.setTenant(null); throw new SMIPluginException( "Cassandra Database Insertion Error. Cannot identify Project/CoS/Tenant for ProtectionSystem", -1); } }
@Override public void createGroupSnapshots( StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException { try { URI snapshot = snapshotList.get(0); BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot); Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent()); TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI()); String tenantName = tenant.getLabel(); String snapLabelToUse = _nameGenerator.generate( tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH); String groupName = getConsistencyGroupName(snapshotObj); VNXeApiClient apiClient = getVnxeClient(storage); VNXeCommandJob job = apiClient.createLunGroupSnap(groupName, snapLabelToUse); if (job != null) { ControllerServiceImpl.enqueueJob( new QueueJob( new VNXeBlockCreateCGSnapshotJob( job.getId(), storage.getId(), !createInactive, taskCompleter))); } } catch (VNXeException e) { _log.error("Create volume snapshot got the exception", e); taskCompleter.error(_dbClient, e); } catch (Exception ex) { _log.error("Create volume snapshot got the exception", ex); ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateCGSnapshot", ex.getMessage()); taskCompleter.error(_dbClient, error); } }
@Override public void createSingleVolumeMirror( StorageSystem storage, URI mirror, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException { _log.info("createSingleVolumeMirror operation START"); try { BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror); StoragePool targetPool = _dbClient.queryObject(StoragePool.class, mirrorObj.getPool()); Volume source = _dbClient.queryObject(Volume.class, mirrorObj.getSource()); TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, source.getTenant().getURI()); String tenantName = tenant.getLabel(); String targetLabelToUse = _nameGenerator.generate( tenantName, mirrorObj.getLabel(), mirror.toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH); CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storage); CIMArgument[] inArgs = null; if (storage.checkIfVmax3()) { CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, source, targetPool); CIMInstance replicaSettingData = getDefaultReplicationSettingData(storage); inArgs = _helper.getCreateElementReplicaMirrorInputArguments( storage, source, targetPool, createInactive, targetLabelToUse, volumeGroupPath, replicaSettingData); } else { inArgs = _helper.getCreateElementReplicaMirrorInputArguments( storage, source, targetPool, createInactive, targetLabelToUse); } CIMArgument[] outArgs = new CIMArgument[5]; _helper.invokeMethod( storage, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs); CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB); if (job != null) { ControllerServiceImpl.enqueueJob( new QueueJob( new SmisBlockCreateMirrorJob( job, storage.getId(), !createInactive, taskCompleter))); // Resynchronizing state applies to the initial copy as well as future // re-synchronization's. mirrorObj.setSyncState(SynchronizationState.RESYNCHRONIZING.toString()); _dbClient.persistObject(mirrorObj); } } catch (final InternalException e) { _log.info("Problem making SMI-S call: ", e); taskCompleter.error(_dbClient, e); } catch (Exception e) { _log.info("Problem making SMI-S call: ", e); ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage()); taskCompleter.error(_dbClient, serviceError); } }
/* * (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 isThinVolume = false; 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 , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned())); if ((label == null) && (volumes.size() == 1)) { String tenantName = ""; try { TenantOrg tenant = dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI()); tenantName = tenant.getLabel(); } catch (DatabaseException e) { log.error("Error lookup TenantOrb object", e); } label = nameGenerator.generate( tenantName, volume.getLabel(), volume.getId().toString(), '-', HDSConstants.MAX_VOLUME_NAME_LENGTH); } if (capacity == null) { capacity = volume.getCapacity(); } isThinVolume = volume.getThinlyProvisioned(); } log.info(logMsgBuilder.toString()); try { multiVolumeCheckForHitachiModel(volumes, storageSystem); HDSApiClient hdsApiClient = hdsApiFactory.getClient( HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword()); String systemObjectID = HDSUtils.getSystemObjectID(storageSystem); String poolObjectID = HDSUtils.getPoolObjectID(storagePool); String asyncTaskMessageId = null; // isThinVolume = true, creates VirtualVolumes // isThinVolume = false, creates LogicalUnits if (isThinVolume) { asyncTaskMessageId = hdsApiClient.createThinVolumes( systemObjectID, storagePool.getNativeId(), capacity, volumes.size(), label, QUICK_FORMAT_TYPE, storageSystem.getModel()); } else if (!isThinVolume) { asyncTaskMessageId = hdsApiClient.createThickVolumes( systemObjectID, poolObjectID, capacity, volumes.size(), label, null, storageSystem.getModel(), null); } if (asyncTaskMessageId != null) { HDSJob createHDSJob = (volumes.size() > 1) ? new HDSCreateMultiVolumeJob( asyncTaskMessageId, volumes.get(0).getStorageController(), storagePool.getId(), volumes.size(), taskCompleter) : new HDSCreateVolumeJob( asyncTaskMessageId, volumes.get(0).getStorageController(), storagePool.getId(), taskCompleter); ControllerServiceImpl.enqueueJob(new QueueJob(createHDSJob)); } } 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.hds.methodFailed("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()); }
/* * (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) { 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); } }