Search in sources :

Example 1 with XtremIOTag

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOTag in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method doDeleteConsistencyGroup.

@Override
public void doDeleteConsistencyGroup(StorageSystem storage, final URI consistencyGroupId, String replicationGroupName, Boolean keepRGName, Boolean markInactive, final TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("{} doDeleteConsistencyGroup START ...", storage.getSerialNumber());
    ServiceError serviceError = null;
    try {
        // Check if the consistency group exists
        BlockConsistencyGroup consistencyGroup = dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
        URI systemURI = storage.getId();
        if (consistencyGroup == null || consistencyGroup.getInactive()) {
            _log.info(String.format("%s is inactive or deleted", consistencyGroupId));
            return;
        }
        String groupName = replicationGroupName != null ? replicationGroupName : consistencyGroup.getLabel();
        // This will be null, if consistencyGroup references no system CG's for storage.
        if (groupName == null) {
            _log.info(String.format("%s contains no system CG for %s.  Assuming it has already been deleted.", consistencyGroupId, systemURI));
            // Clean up the system consistency group references
            BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), groupName, markInactive, dbClient);
            return;
        }
        XtremIOClient client = XtremIOProvUtils.getXtremIOClient(dbClient, storage, xtremioRestClientFactory);
        // We still need throw exception for standard CG.
        if (!client.isVersion2() && consistencyGroup.isProtectedCG()) {
            StringSet cgTypes = consistencyGroup.getTypes();
            cgTypes.remove(BlockConsistencyGroup.Types.LOCAL.name());
            consistencyGroup.setTypes(cgTypes);
            _log.info("{} Operation deleteConsistencyGroup not supported for the xtremio array version");
        } else {
            String clusterName = client.getClusterDetails(storage.getSerialNumber()).getName();
            Project cgProject = dbClient.queryObject(Project.class, consistencyGroup.getProject());
            XtremIOTag tagDetails = XtremIOProvUtils.isTagAvailableInArray(client, cgProject.getLabel(), XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
            // If the tag has no references, delete the tag completely
            if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) == 0) {
                _log.info("Deleting the CG tag {} as no references found.", cgProject.getLabel());
                client.deleteTag(cgProject.getLabel(), XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
            } else if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) > 0) {
                deleteEntityTag(client, cgProject.getLabel(), groupName, clusterName);
            }
            // Finally remove the CG.
            if (null != XtremIOProvUtils.isCGAvailableInArray(client, groupName, clusterName)) {
                client.removeConsistencyGroup(groupName, clusterName);
            }
            if (keepRGName) {
                return;
            }
            // Clean up the system consistency group references
            BlockConsistencyGroupUtils.cleanUpCG(consistencyGroup, storage.getId(), groupName, markInactive, dbClient);
        }
        dbClient.updateObject(consistencyGroup);
        _log.info("{} doDeleteConsistencyGroup END ...", storage.getSerialNumber());
    } catch (Exception e) {
        _log.error(String.format("Delete Consistency Group operation failed %s", e));
        serviceError = DeviceControllerException.errors.jobFailed(e);
    } finally {
        if (serviceError != null) {
            taskCompleter.error(dbClient, serviceError);
        } else {
            taskCompleter.ready(dbClient);
        }
    }
}
Also used : XtremIOTag(com.emc.storageos.xtremio.restapi.model.response.XtremIOTag) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Project(com.emc.storageos.db.client.model.Project) XtremIOClient(com.emc.storageos.xtremio.restapi.XtremIOClient) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 2 with XtremIOTag

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOTag in project coprhd-controller by CoprHD.

the class XtremIOStorageDevice method deleteEntityTag.

/**
 * Untag the given entity and also deletes the tag if no more referring objects.
 *
 * @param client
 *            - XtremIO client.
 * @param tagName
 *            - Tag to unset.
 * @param entityName
 *            - Entity in which untagging.
 * @param clusterName
 *            - XtremIO cluster name
 * @throws Exception
 */
private void deleteEntityTag(XtremIOClient client, String tagName, String entityName, String clusterName) throws Exception {
    _log.info("Untagging the CG tag: {} on entity: {}", tagName, entityName);
    try {
        client.deleteEntityTag(tagName, XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), entityName, clusterName);
    } catch (Exception e) {
        if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
            _log.error("Deleting entity {} from tag {} failed with exception {}", entityName, tagName, e.getMessage());
            throw e;
        } else {
            _log.warn("Entity {} in tag {} not found. Might be already deleted.", entityName, tagName);
        }
    }
    XtremIOTag tagDetails = XtremIOProvUtils.isTagAvailableInArray(client, tagName, XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
    // If the last entity got untagged, then delete the tag completely.
    if (null != tagDetails && Integer.parseInt(tagDetails.getNumberOfDirectObjs()) == 0) {
        _log.info("Deleting the CG tag {} as no references found.", tagName);
        client.deleteTag(tagName, XtremIOConstants.XTREMIO_ENTITY_TYPE.ConsistencyGroup.name(), clusterName);
    }
}
Also used : XtremIOTag(com.emc.storageos.xtremio.restapi.model.response.XtremIOTag) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 3 with XtremIOTag

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOTag in project coprhd-controller by CoprHD.

the class XtremIOProvUtils method cleanupVolumeFoldersIfNeeded.

/**
 * Check the number of volumes under the tag/volume folder.
 * If zero, delete the tag/folder
 *
 * @param client
 * @param xioClusterName
 * @param volumeFolderName
 * @param storageSystem
 * @throws Exception
 */
public static void cleanupVolumeFoldersIfNeeded(XtremIOClient client, String xioClusterName, String volumeFolderName, StorageSystem storageSystem) throws Exception {
    try {
        boolean isVersion2 = client.isVersion2();
        // Find the # volumes in folder, if the Volume folder is empty,
        // then delete the folder too
        XtremIOTag tag = client.getTagDetails(volumeFolderName, XTREMIO_ENTITY_TYPE.Volume.name(), xioClusterName);
        if (tag == null) {
            _log.info("Tag {} not found on the array", volumeFolderName);
            return;
        }
        _log.info("Got back tag details {}", tag.toString());
        String numOfVols = isVersion2 ? tag.getNumberOfDirectObjs() : tag.getNumberOfVolumes();
        int numberOfVolumes = Integer.parseInt(numOfVols);
        if (numberOfVolumes == 0) {
            if (isVersion2) {
                client.deleteTag(volumeFolderName, XtremIOConstants.XTREMIO_ENTITY_TYPE.Volume.name(), xioClusterName);
            } else {
                String volumesFolderName = volumeFolderName.concat(XtremIOConstants.VOLUMES_SUBFOLDER);
                String snapshotsFolderName = volumeFolderName.concat(XtremIOConstants.SNAPSHOTS_SUBFOLDER);
                _log.info("Deleting Volumes Folder ...");
                client.deleteTag(volumesFolderName, XtremIOConstants.XTREMIO_ENTITY_TYPE.Volume.name(), xioClusterName);
                _log.info("Deleting Snapshots Folder ...");
                client.deleteTag(snapshotsFolderName, XtremIOConstants.XTREMIO_ENTITY_TYPE.Volume.name(), xioClusterName);
                _log.info("Deleting Root Folder ...");
                client.deleteTag(volumeFolderName, XtremIOConstants.XTREMIO_ENTITY_TYPE.Volume.name(), xioClusterName);
            }
        }
    } catch (Exception e) {
        _log.warn("Deleting root folder {} failed", volumeFolderName, e);
    }
}
Also used : XtremIOTag(com.emc.storageos.xtremio.restapi.model.response.XtremIOTag) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)

Example 4 with XtremIOTag

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOTag in project coprhd-controller by CoprHD.

the class XtremIOV1Client method getVolumeGroupFolder.

private XtremIOTag getVolumeGroupFolder(String volumeFolderName, String clusterName) throws Exception {
    try {
        String uriStr = XtremIOConstants.XTREMIO_VOLUME_FOLDERS_STR.concat(XtremIOConstants.getInputNameString(volumeFolderName));
        ClientResponse response = get(URI.create(uriStr));
        XtremIOTags folderResponse = getResponseObject(XtremIOTags.class, response);
        XtremIOTag folder = folderResponse.getContent();
        log.info(folder.toString());
        return folder;
    } catch (Exception e) {
        if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
            throw e;
        } else {
            log.warn("Volume folder {} not found on cluster {}", volumeFolderName, clusterName);
        }
    }
    log.info("Volume Folder not available on Array with name : {}", volumeFolderName);
    return null;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) XtremIOTag(com.emc.storageos.xtremio.restapi.model.response.XtremIOTag) XtremIOTags(com.emc.storageos.xtremio.restapi.model.response.XtremIOTags) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)

Example 5 with XtremIOTag

use of com.emc.storageos.xtremio.restapi.model.response.XtremIOTag in project coprhd-controller by CoprHD.

the class XtremIOExportOperations method deleteInitiatorGroupFolder.

private void deleteInitiatorGroupFolder(XtremIOClient client, String xioClusterName, String clusterName, String hostName, StorageSystem system) throws Exception {
    String tempIGFolderName = getInitiatorGroupFolderName(clusterName, hostName, system);
    XtremIOTag igFolder = client.getTagDetails(tempIGFolderName, XTREMIO_ENTITY_TYPE.InitiatorGroup.name(), xioClusterName);
    if (null != igFolder && "0".equalsIgnoreCase(igFolder.getNumberOfDirectObjs())) {
        try {
            _log.info("# of IGs  {} in Folder {}", igFolder.getNumberOfDirectObjs(), clusterName);
            client.deleteTag(tempIGFolderName, XtremIOConstants.XTREMIO_ENTITY_TYPE.InitiatorGroup.name(), xioClusterName);
        } catch (Exception e) {
            if (null != e.getMessage() && !e.getMessage().contains(XtremIOConstants.OBJECT_NOT_FOUND)) {
                _log.warn("Deleting Initatiator Group Folder {} failed with exception {}", tempIGFolderName, e.getMessage());
                throw e;
            } else {
                _log.warn("Initatiator Group Folder {} not found. Might be already deleted.", tempIGFolderName);
            }
        }
    }
}
Also used : XtremIOTag(com.emc.storageos.xtremio.restapi.model.response.XtremIOTag) XtremIOApiException(com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

XtremIOApiException (com.emc.storageos.xtremio.restapi.errorhandling.XtremIOApiException)6 XtremIOTag (com.emc.storageos.xtremio.restapi.model.response.XtremIOTag)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)3 XtremIOTags (com.emc.storageos.xtremio.restapi.model.response.XtremIOTags)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)1 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)1 Project (com.emc.storageos.db.client.model.Project)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 XtremIOClient (com.emc.storageos.xtremio.restapi.XtremIOClient)1 URI (java.net.URI)1