use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class TestBlockStorageUtils method originalGetBlockResources.
static final List<BlockObjectRestRep> originalGetBlockResources(ViPRCoreClient client, Collection<URI> uris) {
List<BlockObjectRestRep> returnList = new ArrayList<>();
for (URI uri : uris) {
BlockObjectRestRep s = getSingle(client, uri);
if (s != null) {
returnList.add(s);
}
returnList.add(getSingle(client, uri));
}
return returnList;
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class TestBlockStorageUtils method testGetBlockResources.
@Test
public void testGetBlockResources() throws URISyntaxException {
Logger.getRootLogger().setLevel(Level.OFF);
ViPRCoreClient client = new ViPRCoreClient("host", true).withLogin("root", "password");
try {
List<URI> uris = prepare(client);
StopWatch w = new StopWatch();
w.start();
List<BlockObjectRestRep> original = originalGetBlockResources(client, uris);
w.stop();
float firstTime = w.getTime();
System.out.println(String.format("Original query time with %s volumes : %s ms", original.size(), firstTime));
w.reset();
w.start();
List<BlockObjectRestRep> fixed = newGetBlockResources(client, uris);
w.stop();
float secondTime = w.getTime();
System.out.println(String.format("Updated query time with %s volumes : %s ms", fixed.size(), w.getTime()));
System.out.println(String.format("Improvement : %s %%", firstTime / secondTime * 100.0f));
Assert.assertTrue(firstTime > secondTime);
} finally {
client.auth().logout();
}
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class CreateVolumeAndVmfsDatastoreService method execute.
@Override
public void execute() throws Exception {
if (datastoreNames.size() != createBlockVolumeHelpers.size()) {
throw new IllegalStateException(ExecutionUtils.getMessage("CreateVolumeAndVmfsDatastoreService.datastore.volume.mismatch"));
}
Map<String, BlockObjectRestRep> datastoreVolumeMap = Maps.newHashMap();
List<URI> volumes = BlockStorageUtils.createMultipleVolumes(createBlockVolumeHelpers);
if (volumes.isEmpty()) {
ExecutionUtils.fail("CreateVolumeAndVmfsDatastoreService.illegalState.noVolumesCreated", args(), args());
}
// use one of the helpers to export all volumes to the host or cluster
createBlockVolumeHelpers.get(0).exportVolumes(volumes);
int index = 0;
for (String datastoreName : datastoreNames) {
BlockObjectRestRep volume = BlockStorageUtils.getBlockResource(volumes.get(index));
datastoreVolumeMap.put(datastoreName, volume);
index++;
}
connectAndInitializeHost();
vmware.refreshStorage(host, cluster);
for (Entry<String, BlockObjectRestRep> entry : datastoreVolumeMap.entrySet()) {
Datastore datastore = vmware.createVmfsDatastore(host, cluster, hostId, entry.getValue(), entry.getKey());
vmware.setMultipathPolicy(host, cluster, multipathPolicy, entry.getValue());
vmware.setStorageIOControl(datastore, storageIOControl, true);
}
vmware.disconnect();
}
use of com.emc.storageos.model.block.BlockObjectRestRep in project coprhd-controller by CoprHD.
the class ExpandVmfsDatastoreService method execute.
@Override
public void execute() throws Exception {
BlockObjectRestRep volume = BlockStorageUtils.getVolume(volumeId);
// Skip the expand if the current volume capacity is larger than the requested expand size
if (BlockStorageUtils.isVolumeExpanded(volume, sizeInGb)) {
logWarn("expand.vmfs.datastore.skip", volumeId, BlockStorageUtils.getCapacity(volume));
} else {
BlockStorageUtils.expandVolume(volumeId, sizeInGb);
}
connectAndInitializeHost();
datastore = vmware.getDatastore(datacenter.getLabel(), datastoreName);
vmware.refreshStorage(host, cluster);
artificialFailure(ArtificialFailures.ARTIFICIAL_FAILURE_VMWARE_EXPAND_DATASTORE);
vmware.expandVmfsDatastore(host, cluster, hostId, volume, datastore);
if (hostId != null) {
ExecutionUtils.addAffectedResource(hostId.toString());
}
}
use of com.emc.storageos.model.block.BlockObjectRestRep 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