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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations