Search in sources :

Example 26 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class BlockProvider method getProjectBlockResources.

protected List<BlockObjectRestRep> getProjectBlockResources(ViPRCoreClient client, URI hostOrClusterId, URI project, boolean onlyMounted) {
    List<BlockObjectRestRep> blockObjects = Lists.newArrayList();
    // the list of host ids that the volume could be mounted to
    List<URI> hostIds = getHostIds(client, hostOrClusterId, onlyMounted);
    // get a list of all volumes and snapshots in the project
    List<VolumeRestRep> projectVolumes = client.blockVolumes().findByProject(project);
    List<BlockSnapshotRestRep> projectSnapshots = client.blockSnapshots().findByProject(project);
    // cycle through every volume in the project and add the volume and its snapshots
    for (VolumeRestRep volume : projectVolumes) {
        boolean isMounted = isMounted(hostIds, volume);
        if ((onlyMounted && isMounted) || (!onlyMounted && !isMounted)) {
            addVolume(blockObjects, volume, projectSnapshots);
        }
    }
    // remaining snapshots can be added now. We don't know their parent volume but we need them in the list anyway
    blockObjects.addAll(projectSnapshots);
    return blockObjects;
}
Also used : BlockSnapshotRestRep(com.emc.storageos.model.block.BlockSnapshotRestRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 27 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class CreateAndMountVolumeService method execute.

@Override
public void execute() throws Exception {
    BlockObjectRestRep volume = createVolume();
    acquireHostsLock();
    ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_AIX_MOUNT_VOLUME);
    mountVolume(volume);
}
Also used : BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 28 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class CreateAndMountVolumeService method execute.

@Override
public void execute() throws Exception {
    BlockObjectRestRep volume = createVolume();
    acquireHostsLock();
    ViPRService.artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_HPUX_MOUNT_VOLUME);
    mountVolume(volume);
}
Also used : BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 29 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method removeBlockResources.

public static void removeBlockResources(Collection<URI> blockResourceIds, VolumeDeleteTypeEnum type) {
    List<URI> allBlockResources = Lists.newArrayList(blockResourceIds);
    for (URI volumeId : blockResourceIds) {
        BlockObjectRestRep volume = getVolume(volumeId);
        allBlockResources.addAll(getSrdfTargetVolumes(volume));
    }
    // export groups/masks if the volume is exported.
    if (VolumeDeleteTypeEnum.VIPR_ONLY != type) {
        removeBlockResourcesFromExports(allBlockResources);
    }
    for (URI volumeId : allBlockResources) {
        if (canRemoveReplicas(volumeId)) {
            removeSnapshotsForVolume(volumeId, type);
            removeSnapshotSessionsForVolume(volumeId, type);
            removeContinuousCopiesForVolume(volumeId, type);
            removeFullCopiesForVolume(volumeId, blockResourceIds, type);
        } else {
            unexportReplicas(volumeId, blockResourceIds, type);
        }
    }
    deactivateBlockResources(blockResourceIds, type);
}
Also used : URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 30 with BlockObjectRestRep

use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.

the class BlockStorageUtils method getVolumeTagCommand.

/**
 * Returns the viprcli command for adding a tag to a block volume
 *
 * @param blockObjectId the id of the block object
 * @param tagName the tag name
 * @param tagValue the tag value
 * @return viprcli command
 */
public static String getVolumeTagCommand(URI blockObjectId, String tagName, String tagValue) {
    BlockObjectRestRep blockObject = getBlockResource(blockObjectId);
    URI projectId = getProjectId(blockObject);
    ProjectRestRep project = getProject(projectId);
    TenantOrgRestRep tenant = getTenant(project.getTenant().getId());
    return ExecutionUtils.getMessage("viprcli.volume.tag", blockObject.getName(), tenant.getName(), project.getName(), tagName, tagValue);
}
Also used : TenantOrgRestRep(com.emc.storageos.model.tenant.TenantOrgRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Aggregations

BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)60 URI (java.net.URI)30 Host (com.emc.storageos.db.client.model.Host)8 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)8 ArrayList (java.util.ArrayList)8 DiskDrive (com.iwave.ext.windows.model.wmi.DiskDrive)7 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 Datastore (com.vmware.vim25.mo.Datastore)5 Map (java.util.Map)5 ExecutionException (com.emc.sa.engine.ExecutionException)4 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)4 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)4 GetHost (com.emc.sa.service.vipr.tasks.GetHost)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HostRestRep (com.emc.storageos.model.host.HostRestRep)3 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)3 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)3 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 Disk (com.iwave.ext.windows.model.Disk)3