use of com.emc.storageos.db.client.model.DecommissionedResource in project coprhd-controller by CoprHD.
the class StorageProviderService method getDecommissionedResources.
/**
* Get zone role assignments
*
* @brief List zone role assignments
* @return Role assignment details
*/
@GET
@Path("/deactivated-systems")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN })
public DecommissionedResources getDecommissionedResources() {
List<URI> resList = _dbClient.queryByType(DecommissionedResource.class, true);
DecommissionedResources results = new DecommissionedResources();
for (URI res : resList) {
DecommissionedResource resource = _dbClient.queryObject(DecommissionedResource.class, res);
if ("StorageSystem".equals(resource.getType())) {
results.addResource(map(resource));
}
}
return results;
}
use of com.emc.storageos.db.client.model.DecommissionedResource in project coprhd-controller by CoprHD.
the class StorageProviderService method deleteStorageProvider.
/**
* Delete Storage Provider
*
* @param id
* @brief Delete a storage provider
* @return
*/
@POST
@Path("/{id}/deactivate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public Response deleteStorageProvider(@PathParam("id") URI id) {
// Validate the provider
ArgValidator.checkFieldUriType(id, StorageProvider.class, "id");
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, id);
ArgValidator.checkEntityNotNull(provider, id, isIdEmbeddedInURL(id));
// Verify the provider can be removed without leaving "dangling" storages.
StringSet providerStorageSystems = provider.getStorageSystems();
if (null != providerStorageSystems && !providerStorageSystems.isEmpty()) {
// First we need to verify that all related storage systems has at least 2 providers
for (String system : providerStorageSystems) {
StorageSystem storageSys = _dbClient.queryObject(StorageSystem.class, URI.create(system));
if (storageSys != null && !storageSys.getInactive() && storageSys.getProviders() != null && storageSys.getProviders().size() == 1) {
throw APIException.badRequests.cannotDeleteProviderWithManagedStorageSystems(storageSys.getId());
}
}
// Next we can clear this provider from storage systems.
for (String system : providerStorageSystems) {
StorageSystem storageSys = _dbClient.queryObject(StorageSystem.class, URI.create(system));
provider.removeStorageSystem(_dbClient, storageSys);
}
}
StringSet decommissionedSystems = provider.getDecommissionedSystems();
if (null != decommissionedSystems && !decommissionedSystems.isEmpty()) {
for (String decommissioned : decommissionedSystems) {
DecommissionedResource oldRes = _dbClient.queryObject(DecommissionedResource.class, URI.create(decommissioned));
if (oldRes != null) {
_dbClient.markForDeletion(oldRes);
}
}
}
// Set to inactive.
_dbClient.markForDeletion(provider);
auditOp(OperationTypeEnum.DELETE_STORAGEPROVIDER, true, null, provider.getId().toString(), provider.getLabel(), provider.getIPAddress(), provider.getPortNumber(), provider.getUserName(), provider.getInterfaceType());
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.DecommissionedResource in project coprhd-controller by CoprHD.
the class SMISProviderService method deleteSMISProvider.
/**
* Allows the user to deactivate an SMI-S provider.
* <p>
* The method is deprecated. Use /vdc/storage-providers/{id}/deactivate instead.
*
* @param id the URN of a ViPR SMI-S provider
*
* @brief Delete SMI-S provider
* @return Status indicating success or failure.
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.SYSTEM_ADMIN })
public Response deleteSMISProvider(@PathParam("id") URI id) {
// Validate the provider
ArgValidator.checkFieldUriType(id, StorageProvider.class, "id");
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, id);
ArgValidator.checkEntityNotNull(provider, id, isIdEmbeddedInURL(id));
// Verify the provider can be removed without leaving "dangling" storages.
StringSet providerStorageSystems = provider.getStorageSystems();
if (null != providerStorageSystems && !providerStorageSystems.isEmpty()) {
// First we need to verify that all related storage systems has at least 2 providers
for (String system : providerStorageSystems) {
StorageSystem storageSys = _dbClient.queryObject(StorageSystem.class, URI.create(system));
if (storageSys.getProviders().size() == 1) {
throw APIException.badRequests.cannotDeleteProviderWithManagedStorageSystems(storageSys.getId());
}
}
// Next we can clear this provider from storage systems.
for (String system : providerStorageSystems) {
StorageSystem storageSys = _dbClient.queryObject(StorageSystem.class, URI.create(system));
provider.removeStorageSystem(_dbClient, storageSys);
}
}
StringSet decommissionedSystems = provider.getDecommissionedSystems();
if (null != decommissionedSystems && !decommissionedSystems.isEmpty()) {
for (String decommissioned : decommissionedSystems) {
DecommissionedResource oldRes = _dbClient.queryObject(DecommissionedResource.class, URI.create(decommissioned));
if (oldRes != null) {
_dbClient.markForDeletion(oldRes);
}
}
}
// Set to inactive.
_dbClient.markForDeletion(provider);
auditOp(OperationTypeEnum.DELETE_SMISPROVIDER, true, null, provider.getId().toString(), provider.getLabel(), provider.getIPAddress(), provider.getPortNumber(), provider.getUserName());
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.DecommissionedResource in project coprhd-controller by CoprHD.
the class SMISProviderService method getDecommissionedResources.
/**
* Get zone role assignments
* The method is deprecated. Use /vdc/storage-providers/deactivated-systems
*
* @brief List zone role assignments
* @return Role assignment details
*/
@GET
@Path("/deactivated-systems")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN })
public DecommissionedResources getDecommissionedResources() {
List<URI> resList = _dbClient.queryByType(DecommissionedResource.class, true);
DecommissionedResources results = new DecommissionedResources();
for (URI res : resList) {
DecommissionedResource resource = _dbClient.queryObject(DecommissionedResource.class, res);
if ("StorageSystem".equals(resource.getType())) {
results.addResource(map(resource));
}
}
return results;
}
use of com.emc.storageos.db.client.model.DecommissionedResource in project coprhd-controller by CoprHD.
the class StorageSystemService method deleteStorageSystem.
/**
* Remove a storage system. The method would remove the storage system from the
* system control and will remove all resources associated with the storage system from the database.
* Note that resources (pools, ports, volumes, etc.) are not removed from the storage system physically,
* but become unavailable for the user.
*
* @param id the URN of a ViPR storage system
* @prereq none
* @brief Delete storage system
* @return An asynchronous task.
*
* @throws DatabaseException When an error occurs querying the database.
*/
@POST
@Path("/{id}/deactivate")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep deleteStorageSystem(@PathParam("id") URI id) throws DatabaseException {
StorageSystem system = _dbClient.queryObject(StorageSystem.class, id);
ArgValidator.checkEntityNotNull(system, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.UNREGISTERED.toString().equals(system.getRegistrationStatus())) {
throw APIException.badRequests.cannotDeactivateStorageSystem();
}
// Ensure the storage system has no active RecoverPoint volumes under management.
if (RPHelper.containsActiveRpVolumes(id, _dbClient)) {
throw APIException.badRequests.cannotDeactivateStorageSystemActiveRpVolumes();
}
if (DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString().equals(system.getDiscoveryStatus()) || DiscoveredDataObject.DataCollectionJobStatus.SCHEDULED.toString().equals(system.getDiscoveryStatus())) {
throw APIException.serviceUnavailable.cannotDeactivateStorageSystemWhileInDiscover(system.getId());
}
String taskId = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(StorageSystem.class, system.getId(), taskId, ResourceOperationTypeEnum.DELETE_STORAGE_SYSTEM);
// Otherwise, the created decommissioned object will not be cleared when the provider is removed and added back.
if (StringUtils.isNotBlank(system.getNativeGuid()) && system.isStorageSystemManagedByProvider() && !NullColumnValueGetter.isNullURI(system.getActiveProviderURI())) {
DecommissionedResource oldStorage = null;
List<URI> oldResources = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDecommissionedResourceIDConstraint(id.toString()));
if (oldResources != null) {
List<DecommissionedResource> objects = _dbClient.queryObject(DecommissionedResource.class, oldResources);
for (DecommissionedResource decomObj : objects) {
if (!decomObj.getInactive()) {
oldStorage = decomObj;
break;
}
}
}
if (oldStorage == null) {
oldStorage = new DecommissionedResource();
oldStorage.setNativeGuid(system.getNativeGuid());
oldStorage.setType(TypeMap.getCFName(StorageSystem.class));
oldStorage.setUser(getUserFromContext().getName());
oldStorage.setDecommissionedId(system.getId());
oldStorage.setLabel(system.getLabel());
oldStorage.setId(URIUtil.createId(DecommissionedResource.class));
_dbClient.createObject(oldStorage);
}
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, system.getActiveProviderURI());
if (provider != null) {
StringSet providerDecomSys = provider.getDecommissionedSystems();
if (providerDecomSys == null) {
providerDecomSys = new StringSet();
provider.setDecommissionedSystems(providerDecomSys);
}
providerDecomSys.add(oldStorage.getId().toString());
_dbClient.updateObject(provider);
}
}
PurgeRunnable.executePurging(_dbClient, _dbPurger, _asynchJobService.getExecutorService(), system, _retry_attempts, taskId, 60);
return toTask(system, taskId, op);
}
Aggregations