Search in sources :

Example 11 with BlockObjectRestRep

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

the class BlockStorageUtils method removeContinuousCopy.

private static void removeContinuousCopy(URI volumeId, URI continuousCopyId, VolumeDeleteTypeEnum type) {
    if (VolumeDeleteTypeEnum.VIPR_ONLY != type) {
        BlockObjectRestRep obj = getVolume(volumeId);
        if (obj instanceof VolumeRestRep) {
            VolumeRestRep volume = (VolumeRestRep) obj;
            if (!StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vplex.name())) {
                execute(new PauseContinuousCopy(volumeId, continuousCopyId, COPY_NATIVE));
            }
        }
    }
    Tasks<VolumeRestRep> tasks = execute(new DeactivateContinuousCopy(volumeId, continuousCopyId, COPY_NATIVE, type));
    addAffectedResources(tasks);
}
Also used : DeactivateContinuousCopy(com.emc.sa.service.vipr.block.tasks.DeactivateContinuousCopy) PauseContinuousCopy(com.emc.sa.service.vipr.block.tasks.PauseContinuousCopy) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 12 with BlockObjectRestRep

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

the class AddVolumesToConsistencyGroupService method execute.

@Override
public void execute() throws Exception {
    // add volumes to CG
    BlockStorageUtils.addVolumesToConsistencyGroup(consistencyGroup, uris(volumeIds));
    // start continuous copies on one of the volumes
    BlockObjectRestRep blockObject = BlockStorageUtils.getBlockResource(uri(volumeIds.get(0)));
    List<URI> targets = BlockStorageUtils.getSrdfTargetVolumes(blockObject);
    if (!targets.isEmpty()) {
        BlockStorageUtils.createContinuousCopy(uri(volumeIds.get(0)), null, 1, BlockStorageUtils.COPY_SRDF, targets.get(0));
    }
    // Continuous copy
    // add source volume mirror's to the CG
    Map<URI, List<URI>> sourceMirrors = addSourceVolumeMirrors();
    // start continuous copies on the r1 mirrors
    startContinuousCopy(sourceMirrors);
    // add target mirrors to the CG
    Map<URI, List<URI>> targetMirrors = addTargetVolumeMirrors();
    // start continuous copies on the r2 mirrors
    startContinuousCopy(targetMirrors);
    // Snapshot
    // add source volumes' snapshots to the CG
    Map<URI, List<URI>> sourceSnapshots = addSourceVolumeSnapshots();
    // start snapshot on the r1 snapshots
    startSnapshot(sourceSnapshots);
    // add target volumes' snapshots to the CG
    Map<URI, List<URI>> targetSnapshots = addTargetVolumeSnapshots();
    // start snapshot on the r2 snapshots
    startSnapshot(targetSnapshots);
    // Full copy
    // add source volumes' full copies to the CG
    Map<URI, List<URI>> sourceFullCopies = addSourceVolumeFullCopies();
    // start full copies on the r1 full copies
    startFullCopy(sourceFullCopies);
    // add target volumes' full copies to the CG
    Map<URI, List<URI>> targetFullCopies = addTargetVolumeFullCopies();
    // start full copies on the r2 full copies
    startFullCopy(targetFullCopies);
}
Also used : List(java.util.List) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Example 13 with BlockObjectRestRep

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

the class CreateExport method isExportForHpuxOnVmax.

private boolean isExportForHpuxOnVmax() {
    // get host list
    List<HostRestRep> hosts = new ArrayList<HostRestRep>();
    if (clusterId != null) {
        hosts = ComputeUtils.getHostsInCluster(clusterId);
    } else {
        Host host = BlockStorageUtils.getHost(hostId);
        HostRestRep hostRestRep = HostMapper.map(host);
        hosts = Lists.newArrayList(hostRestRep);
    }
    // find if its a HPUX host
    boolean hasHPUX = false;
    for (HostRestRep host : hosts) {
        if (host.getType() != null && (host.getType().equalsIgnoreCase(Host.HostType.HPUX.toString()))) {
            hasHPUX = true;
            break;
        }
    }
    if (!hasHPUX) {
        return false;
    }
    // VMAX
    for (URI volumeId : volumeIds) {
        BlockObjectRestRep volume = BlockStorageUtils.getVolume(volumeId);
        URI storageURI = volume.getStorageController();
        StorageSystemRestRep storageSystem = BlockStorageUtils.getStorageSystem(storageURI);
        if (StringUtils.equals(VMAX, storageSystem.getSystemType())) {
            return true;
        }
    }
    return false;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) ArrayList(java.util.ArrayList) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

Example 14 with BlockObjectRestRep

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

the class ComputeUtils method validateBootVolumes.

/**
 * Validate that the boot volume for this host is still on the server.
 * This prevents us from deleting a re-purposed volume that was originally
 * a boot volume.
 *
 * @return true if the volumes are valid, or the volumes are not able to be validated, so we can go ahead anyway.
 */
public static boolean validateBootVolumes(Cluster cluster, List<HostRestRep> hostsToValidate) {
    // the references are fixed.
    if (cluster == null || cluster.getInactive()) {
        ExecutionUtils.currentContext().logError("computeutils.removebootvolumes.failure.cluster");
        return false;
    }
    // so return that the boot volume is valid due to lack of technical ability to dig any deeper.
    if (NullColumnValueGetter.isNullURI(cluster.getVcenterDataCenter())) {
        ExecutionUtils.currentContext().logInfo("computeutils.removebootvolumes.validation.skipped.noVcenterDataCenter", cluster.forDisplay());
        return true;
    }
    VcenterDataCenter dataCenter = execute(new GetVcenterDataCenter(cluster.getVcenterDataCenter()));
    // until that's fixed.
    if (dataCenter == null || dataCenter.getInactive() || NullColumnValueGetter.isNullURI(dataCenter.getVcenter())) {
        ExecutionUtils.currentContext().logError("computeutils.removebootvolumes.failure.datacenter", cluster.forDisplay());
        return false;
    }
    Vcenter vcenter = execute(new GetVcenter(dataCenter.getVcenter()));
    // until that's fixed.
    if (vcenter == null || vcenter.getInactive()) {
        ExecutionUtils.currentContext().logError("computeutils.removebootvolumes.failure.vcenter", cluster.forDisplay());
        return false;
    }
    VMwareSupport vmware = null;
    try {
        vmware = new VMwareSupport();
        vmware.connect(vcenter.getId());
        for (HostRestRep clusterHost : hostsToValidate) {
            Host host = BlockStorageUtils.getHost(clusterHost.getId());
            // Do not validate a host no longer in our database
            if (host == null || host.getInactive()) {
                ExecutionUtils.currentContext().logError("computeutils.removebootvolumes.failure.host", "N/A", "host not found or inactive");
                return false;
            }
            // in the vCenter cluster, and therefore we can not perform a deep validation.
            if (NullColumnValueGetter.isNullURI(host.getVcenterDataCenter())) {
                ExecutionUtils.currentContext().logInfo("computeutils.removebootvolumes.validation.skipped.vcenternotinhost", host.getHostName());
                continue;
            }
            // any update to the host using the hostService automatically adds this association.
            if (!NullColumnValueGetter.isNullURI(host.getVcenterDataCenter()) && host.getType() != null && host.getType().equalsIgnoreCase((Host.HostType.No_OS).name())) {
                ExecutionUtils.currentContext().logInfo("computeutils.removebootvolumes.validation.skipped.noOShost", host.getHostName());
                continue;
            }
            // flag it as an issue.
            if (clusterHost.getBootVolume() == null || NullColumnValueGetter.isNullURI(clusterHost.getBootVolume().getId())) {
                ExecutionUtils.currentContext().logWarn("computeutils.removebootvolumes.failure.host", host.getHostName(), "no boot volume associated with host");
                continue;
            }
            BlockObjectRestRep bootVolume = execute(new GetBlockResource(clusterHost.getBootVolume().getId()));
            // Do not validate an old/non-existent boot volume representation
            if (bootVolume == null || bootVolume.getInactive()) {
                ExecutionUtils.currentContext().logError("computeutils.removebootvolumes.failure.host", host.getHostName(), "boot volume not found or inactive");
                return false;
            }
            HostSystem hostSystem = null;
            try {
                hostSystem = vmware.getHostSystem(dataCenter.getLabel(), clusterHost.getName(), false);
                // we can't perform the validation.
                if (hostSystem == null) {
                    ExecutionUtils.currentContext().logInfo("computeutils.removebootvolumes.validation.skipped.hostnotinvcenter", host.getHostName());
                    continue;
                }
                HostSystemConnectionState connectionState = VMwareUtils.getConnectionState(hostSystem);
                if (connectionState == null || connectionState == HostSystemConnectionState.notResponding || connectionState == HostSystemConnectionState.disconnected) {
                    String exMsg = "Validation of boot volume usage on host %s failed. " + "Validation failed because host is in a disconnected state or not responding state, and therefore cannot be validated. " + "Cannot decommission in current state.  Recommended to either re-connect the host or remove the host from vCenter, " + "run vCenter discovery and address actionable events before attempting decommission of hosts in this cluster.";
                    // will print a boot volume re-purposed error message which is kind of misleading or incorrect reason for the failure.
                    throw new IllegalStateException(String.format(exMsg, host.getHostName()));
                }
            } catch (ExecutionException e) {
                if (e.getCause() instanceof IllegalStateException) {
                    ExecutionUtils.currentContext().logInfo("computeutils.removebootvolumes.validation.skipped.hostnotinvcenter", host.getHostName());
                    continue;
                }
                // If it's anything other than the IllegalStateException, re-throw the base exception
                throw e;
            }
            if (vmware.findScsiDisk(hostSystem, null, bootVolume, false, false) == null) {
                // fail, host can't see its boot volume
                ExecutionUtils.currentContext().logError("computeutils.removebootvolumes.failure.bootvolume", bootVolume.getDeviceLabel(), bootVolume.getWwn());
                return false;
            } else {
                ExecutionUtils.currentContext().logInfo("computeutils.removebootvolumes.validated", host.getHostName(), bootVolume.getDeviceLabel());
            }
        }
    } finally {
        if (vmware != null) {
            vmware.disconnect();
        }
    }
    return true;
}
Also used : GetVcenter(com.emc.sa.service.vmware.tasks.GetVcenter) Vcenter(com.emc.storageos.db.client.model.Vcenter) GetVcenter(com.emc.sa.service.vmware.tasks.GetVcenter) VMwareSupport(com.emc.sa.service.vmware.VMwareSupport) GetHost(com.emc.sa.service.vipr.tasks.GetHost) DiscoverHost(com.emc.sa.service.vipr.compute.tasks.DiscoverHost) DeactivateHost(com.emc.sa.service.vipr.compute.tasks.DeactivateHost) Host(com.emc.storageos.db.client.model.Host) GetBlockResource(com.emc.sa.service.vipr.block.tasks.GetBlockResource) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) GetVcenterDataCenter(com.emc.sa.service.vmware.tasks.GetVcenterDataCenter) HostRestRep(com.emc.storageos.model.host.HostRestRep) HostSystem(com.vmware.vim25.mo.HostSystem) GetVcenterDataCenter(com.emc.sa.service.vmware.tasks.GetVcenterDataCenter) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) HostSystemConnectionState(com.vmware.vim25.HostSystemConnectionState) ExecutionException(com.emc.sa.engine.ExecutionException)

Example 15 with BlockObjectRestRep

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

the class VMwareSupport method mountDatastores.

/**
 * Mount datastores that are backed by the list of volumes
 *
 * @param host the host to mount the datastore on, or null if cluster is being used
 * @param cluster the cluster to mount the datastore on, or null if host is being used
 * @param datacenterName name of the datacenter
 * @param volumeIds the list of volumes
 * @throws Exception thrown if an error occurs
 */
public void mountDatastores(HostSystem host, ClusterComputeResource cluster, String datacenterName, List<URI> volumeIds) throws Exception {
    List<HostSystem> hosts = cluster == null ? Lists.newArrayList(host) : Lists.newArrayList(cluster.getHosts());
    rescanVmfs(hosts);
    for (URI volumeId : volumeIds) {
        BlockObjectRestRep volume = BlockStorageUtils.getVolume(volumeId);
        Set<String> datastoreNames = VMwareDatastoreTagger.getDatastoreNames(volume);
        for (String datastoreName : datastoreNames) {
            Datastore datastore = getDatastore(datacenterName, datastoreName);
            mountDatastore(datastore, hosts);
        }
    }
}
Also used : MountDatastore(com.emc.sa.service.vmware.block.tasks.MountDatastore) ExpandVmfsDatastore(com.emc.sa.service.vmware.block.tasks.ExpandVmfsDatastore) FindLunsBackingDatastore(com.emc.sa.service.vmware.block.tasks.FindLunsBackingDatastore) UnmountVmfsDatastore(com.emc.sa.service.vmware.block.tasks.UnmountVmfsDatastore) CreateNfsDatastore(com.emc.sa.service.vmware.file.tasks.CreateNfsDatastore) ExtendVmfsDatastore(com.emc.sa.service.vmware.block.tasks.ExtendVmfsDatastore) Datastore(com.vmware.vim25.mo.Datastore) FindDatastore(com.emc.sa.service.vmware.tasks.FindDatastore) DeleteDatastore(com.emc.sa.service.vmware.tasks.DeleteDatastore) FindFilesystemWithDatastore(com.emc.sa.service.vipr.file.tasks.FindFilesystemWithDatastore) CreateVmfsDatastore(com.emc.sa.service.vmware.block.tasks.CreateVmfsDatastore) HostSystem(com.vmware.vim25.mo.HostSystem) URI(java.net.URI) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep)

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