Search in sources :

Example 46 with ExportGroupRestRep

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

the class BlockExportGroups method deleteExportGroup.

@FlashException(referrer = { "exportGroup" })
public static void deleteExportGroup(String exportGroupId) {
    if (StringUtils.isNotBlank(exportGroupId)) {
        ViPRCoreClient client = BourneUtil.getViprClient();
        Task<ExportGroupRestRep> task = client.blockExports().deactivate(uri(exportGroupId));
        flash.put("info", MessagesUtils.get("resources.exportgroup.deactivate"));
    }
    exportGroup(exportGroupId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) FlashException(controllers.util.FlashException)

Example 47 with ExportGroupRestRep

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

the class BlockExportGroups method addHosts.

@FlashException(referrer = { "exportGroup" })
public static void addHosts(String exportId, @As(",") String[] ids) {
    ExportUpdateParam exportUpdateParam = new ExportUpdateParam();
    exportUpdateParam.setHosts(new HostsUpdateParam());
    if (ids != null && ids.length > 0) {
        for (String hostId : ids) {
            exportUpdateParam.getHosts().getAdd().add(uri(hostId));
        }
    }
    Task<ExportGroupRestRep> task = getViprClient().blockExports().update(uri(exportId), exportUpdateParam);
    flash.put("info", MessagesUtils.get("resources.exportgroup.hosts.added", task.getOpId()));
    exportGroup(exportId);
}
Also used : ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ExportUpdateParam(com.emc.storageos.model.block.export.ExportUpdateParam) HostsUpdateParam(com.emc.storageos.model.block.export.HostsUpdateParam) FlashException(controllers.util.FlashException)

Example 48 with ExportGroupRestRep

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

the class BlockSnapshots method snapshotExports.

public static void snapshotExports(String snapshotId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    Map<URI, ExportGroupRestRep> exportGroups = Maps.newHashMap();
    Map<URI, List<ITLRestRep>> exportGroupItlMap = Maps.newHashMap();
    List<ITLRestRep> itls = client.blockSnapshots().listExports(uri(snapshotId));
    for (ITLRestRep itl : itls) {
        NamedRelatedResourceRep export = itl.getExport();
        if (export != null && export.getId() != null) {
            List<ITLRestRep> exportGroupItls = exportGroupItlMap.get(export.getId());
            if (exportGroupItls == null) {
                exportGroupItls = Lists.newArrayList();
                exportGroupItlMap.put(export.getId(), exportGroupItls);
            }
            exportGroupItls.add(itl);
            if (exportGroups.keySet().contains(export.getId()) == false) {
                ExportGroupRestRep exportGroup = client.blockExports().get(export.getId());
                exportGroups.put(exportGroup.getId(), exportGroup);
            }
        }
    }
    render(itls, exportGroups, exportGroupItlMap);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) List(java.util.List) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 49 with ExportGroupRestRep

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

the class BlockVolumes method volumeExports.

public static void volumeExports(String volumeId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    Map<URI, ExportGroupRestRep> exportGroups = Maps.newHashMap();
    Map<URI, List<ITLRestRep>> exportGroupItlMap = Maps.newHashMap();
    List<ITLRestRep> itls = Lists.newArrayList();
    VolumeRestRep volume = client.blockVolumes().get(uri(volumeId));
    if (volume != null && volume.getInactive() == false) {
        itls = client.blockVolumes().getExports(uri(volumeId));
        for (ITLRestRep itl : itls) {
            NamedRelatedResourceRep export = itl.getExport();
            if (export != null && export.getId() != null) {
                List<ITLRestRep> exportGroupItls = exportGroupItlMap.get(export.getId());
                if (exportGroupItls == null) {
                    exportGroupItls = Lists.newArrayList();
                    exportGroupItlMap.put(export.getId(), exportGroupItls);
                }
                exportGroupItls.add(itl);
                if (exportGroups.keySet().contains(export.getId()) == false) {
                    ExportGroupRestRep exportGroup = client.blockExports().get(export.getId());
                    exportGroups.put(exportGroup.getId(), exportGroup);
                }
            }
        }
    }
    // Remove 'internal' marked export groups, we don't want to show these in the exports list
    Set<URI> internalExportGroups = Sets.newHashSet();
    for (ExportGroupRestRep exportGroup : exportGroups.values()) {
        if (Boolean.TRUE.equals(exportGroup.getInternal())) {
            internalExportGroups.add(exportGroup.getId());
        }
    }
    // Remove internal export groups
    exportGroups.keySet().removeAll(internalExportGroups);
    // Remove initiators from interal export groups
    exportGroupItlMap.keySet().removeAll(internalExportGroups);
    render(itls, exportGroups, exportGroupItlMap);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ITLRestRep(com.emc.storageos.model.block.export.ITLRestRep) List(java.util.List) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 50 with ExportGroupRestRep

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

the class UnexportVMwareVolumeService method execute.

@Override
public void execute() throws Exception {
    for (BlockObjectRestRep volume : volumes) {
        String datastoreName = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
        if (!StringUtils.isEmpty(datastoreName)) {
            Datastore datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
            if (datastore != null) {
                boolean storageIOControlEnabled = datastore.getIormConfiguration() != null ? datastore.getIormConfiguration().isEnabled() : false;
                vmware.unmountVmfsDatastore(host, cluster, datastore);
                datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
                if (storageIOControlEnabled && datastore != null && datastore.getSummary() != null && datastore.getSummary().isAccessible()) {
                    vmware.setStorageIOControl(datastore, true);
                }
            }
        }
    }
    for (BlockObjectRestRep volume : volumes) {
        vmware.detachLuns(host, cluster, volume);
    }
    vmware.disconnect();
    ExecutionUtils.clearRollback();
    for (BlockObjectRestRep volume : volumes) {
        if (volume.getTags() != null) {
            vmware.removeVmfsDatastoreTag(volume, hostId);
        }
    }
    for (ExportGroupRestRep export : filteredExportGroups) {
        URI exportId = ResourceUtils.id(export);
        String exportName = ResourceUtils.name(export);
        // Check each volume to see if it is in this export
        Set<URI> exportedVolumeIds = Sets.newHashSet();
        for (BlockObjectRestRep volume : volumes) {
            URI volumeId = ResourceUtils.id(volume);
            String volumeName = ResourceUtils.name(volume);
            if (BlockStorageUtils.isVolumeInExportGroup(export, volumeId)) {
                logInfo("unexport.host.service.volume.in.export", volumeName, exportName);
                exportedVolumeIds.add(volumeId);
            }
        }
        if (!exportedVolumeIds.isEmpty()) {
            logInfo("unexport.host.service.volume.remove", exportedVolumeIds.size(), exportName);
            BlockStorageUtils.removeBlockResourcesFromExport(exportedVolumeIds, exportId);
        } else {
            logDebug("unexport.host.service.volume.skip", exportName);
        }
        String hostOrClusterId = BlockStorageUtils.getHostOrClusterId(hostId);
        if (hostOrClusterId != null) {
            ExecutionUtils.addAffectedResource(hostOrClusterId.toString());
        }
    }
    connectAndInitializeHost();
    vmware.refreshStorage(host, cluster);
}
Also used : Datastore(com.vmware.vim25.mo.Datastore) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) BlockObjectRestRep(com.emc.storageos.model.block.BlockObjectRestRep) URI(java.net.URI)

Aggregations

ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)59 URI (java.net.URI)36 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)24 Asset (com.emc.sa.asset.annotation.Asset)10 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)10 FlashException (controllers.util.FlashException)9 ExportUpdateParam (com.emc.storageos.model.block.export.ExportUpdateParam)8 AssetOption (com.emc.vipr.model.catalog.AssetOption)8 ArrayList (java.util.ArrayList)8 ExportBlockParam (com.emc.storageos.model.block.export.ExportBlockParam)7 DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)5 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)5 ITLRestRep (com.emc.storageos.model.block.export.ITLRestRep)5 HostRestRep (com.emc.storageos.model.host.HostRestRep)5 HashSet (java.util.HashSet)5 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 SimpleValueRep (com.emc.storageos.model.customconfig.SimpleValueRep)4 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)4