use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class ExportVMwareVolumeService method setVmfsDatastoreTag.
private void setVmfsDatastoreTag(List<String> volumeIds, URI hostId) {
for (String volumeId : volumeIds) {
BlockObjectRestRep volume = BlockStorageUtils.getVolume(uri(volumeId));
Set<String> datastoreNames = VMwareDatastoreTagger.getDatastoreNames(volume);
for (String datastoreName : datastoreNames) {
vmware.addVmfsDatastoreTag(volume, hostId, datastoreName);
}
}
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class RemoveBlockVolumeService method execute.
@Override
public void execute() {
for (BlockObjectRestRep volume : volumes) {
String datastoreName = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
if (!StringUtils.isEmpty(datastoreName)) {
Datastore datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
if (datastore != null) {
vmware.unmountVmfsDatastore(host, cluster, datastore);
}
}
}
for (BlockObjectRestRep volume : volumes) {
vmware.detachLuns(host, cluster, volume);
}
vmware.disconnect();
BlockStorageUtils.removeBlockResources(uris(volumeIds), deletionType);
connectAndInitializeHost();
vmware.refreshStorage(host, cluster);
// form is always passing hostId, never clusterId - need to figure out which it is.
String hostOrClusterId = BlockStorageUtils.getHostOrClusterId(hostId);
if (hostOrClusterId != null) {
ExecutionUtils.addAffectedResource(hostOrClusterId.toString());
}
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class UnexportVMwareVolumeService method precheck.
@Override
public void precheck() throws Exception {
super.precheck();
List<Host> hosts = Lists.newArrayList();
if (BlockStorageUtils.isCluster(hostId)) {
clusterInstance = BlockStorageUtils.getCluster(hostId);
exports = BlockStorageUtils.findExportsContainingCluster(hostId, null, null);
hosts = getModelClient().hosts().findByCluster(hostId);
} else {
hostInstance = BlockStorageUtils.getHost(hostId);
exports = BlockStorageUtils.findExportsContainingHost(hostId, null, null);
hosts = Arrays.asList(hostInstance);
}
filteredExportGroups = BlockStorageUtils.filterExportsByType(exports, hostId);
String hostOrClusterLabel = clusterInstance == null ? hostInstance.getLabel() : clusterInstance.getLabel();
if (filteredExportGroups.isEmpty()) {
ExecutionUtils.fail("failTask.UnexportHostService.export", args(), args(hostOrClusterLabel));
}
volumes = BlockStorageUtils.getBlockResources(uris(volumeIds));
if (volumes.isEmpty()) {
ExecutionUtils.fail("failTask.UnexportHostService.volumes", args(), args());
}
if (volumes.size() < volumeIds.size()) {
logWarn("unexport.host.service.not.found", volumeIds.size(), volumes.size());
}
for (BlockObjectRestRep volume : volumes) {
String datastoreName = KnownMachineTags.getBlockVolumeVMFSDatastore(hostId, volume);
if (!StringUtils.isEmpty(datastoreName)) {
Datastore datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
if (datastore != null) {
vmware.verifyDatastoreForRemoval(datastore, datacenter.getLabel(), hosts);
}
}
}
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class CreateVolumeAndExtendVmfsDatastoreService method execute.
@Override
public void execute() throws Exception {
List<BlockObjectRestRep> volumes = createBlockVolumeHelper.createAndExportVolumes();
if (volumes.isEmpty()) {
ExecutionUtils.fail("CreateVolumeAndExtendVmfsDatastoreService.illegalState.noVolumesCreated", args(), args());
}
BlockObjectRestRep volume = volumes.get(0);
connectAndInitializeHost();
datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_VMWARE_EXTEND_DATASTORE);
vmware.extendVmfsDatastore(host, cluster, hostId, volume, datastore);
vmware.setMultipathPolicy(host, cluster, multipathPolicy, volume);
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class TestBlockStorageUtils method newGetBlockResources.
static final List<BlockObjectRestRep> newGetBlockResources(ViPRCoreClient client, Collection<URI> uris) {
List<BlockObjectRestRep> blockResources = Lists.newArrayList();
List<URI> blockVolumes = new ArrayList<URI>();
List<URI> blockSnapshots = new ArrayList<URI>();
for (URI resourceId : uris) {
ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
switch(volumeType) {
case VOLUME:
blockVolumes.add(resourceId);
break;
case BLOCK_SNAPSHOT:
blockSnapshots.add(resourceId);
break;
default:
break;
}
}
blockResources.addAll(client.blockVolumes().getByIds(blockVolumes));
blockResources.addAll(client.blockSnapshots().getByIds(blockSnapshots));
return blockResources;
}
Aggregations