use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.
the class CustomConfigService method getCustomConfigTypeValue.
/**
* Get the custom config value set in ViPR. This is valid for simple value config type only
*
* @brief Show config type details
* @return The config type data.
*/
@GET
@Path("/types/{config_name}/value")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public SimpleValueRep getCustomConfigTypeValue(@PathParam("config_name") String configName, @QueryParam("scope") String scope) {
ArgValidator.checkFieldNotEmpty(configName, "configName");
CustomConfigType item = customConfigHandler.getCustomConfigType(configName);
if (item != null && !SIMPLE_VALUE_TYPE.equals(item.getConfigType())) {
throw APIException.badRequests.invalidConfigValueType(configName);
}
SimpleValueRep result = new SimpleValueRep();
if (item != null) {
String value = customConfigHandler.getComputedCustomConfigValue(configName, scope, null);
result.setValue(value);
} else {
log.info(String.format("Invalid config type for %s", configName));
throw APIException.badRequests.invalidConfigType(configName);
}
return result;
}
use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.
the class BlockProvider method getCurrentExportPortGroups.
@Asset("exportCurrentPortGroup")
@AssetDependencies({ "host", "exportPathExport", "exportPathVirtualArray" })
public List<AssetOption> getCurrentExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI exportId, URI varrayId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
ExportGroupRestRep exportGroup = client.blockExports().get(exportId);
List<StoragePortGroupRestRep> storagePortGroups = new ArrayList<StoragePortGroupRestRep>();
List<ExportBlockParam> blockParams = exportGroup.getVolumes();
Set<URI> storageSystemURISet = new HashSet<URI>();
if (!CollectionUtils.isEmpty(blockParams)) {
for (ExportBlockParam blockParam : blockParams) {
// Get each volume in the export group to get the storage system ID
if (blockParam != null) {
URI resourceId = blockParam.getId();
URI storageDeviceURI = null;
if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
VolumeRestRep volume = client.blockVolumes().get(resourceId);
storageDeviceURI = volume.getStorageController();
} else if (ResourceType.isType(ResourceType.BLOCK_SNAPSHOT, resourceId)) {
BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
storageDeviceURI = snapshot.getStorageController();
}
if (storageDeviceURI != null) {
storageSystemURISet.add(storageDeviceURI);
}
} else {
log.error("Block param not found in export group: {}", exportId);
}
}
}
if (!CollectionUtils.isEmpty(storageSystemURISet)) {
Set<URI> portGroupSet = new HashSet<URI>();
for (URI storageSystemURI : storageSystemURISet) {
// Now use the storage system ID as well to query the storage port groups
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, exportId, storageSystemURI, null, null, false);
List<StoragePortGroupRestRep> portGroupList = portGroups.getStoragePortGroups();
if (!CollectionUtils.isEmpty(portGroupList)) {
for (StoragePortGroupRestRep portGroup : portGroupList) {
if (portGroupSet.add(portGroup.getId())) {
storagePortGroups.add(portGroup);
}
}
}
}
}
return createPortGroupOptions(storagePortGroups);
}
return options;
}
use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportVolumeForComputePortGroups.
@Asset("exportVolumeForComputePortGroups")
@AssetDependencies({ "blockVirtualArray", "blockVirtualPool", "project" })
public List<AssetOption> getExportVolumeForComputePortGroups(AssetOptionsContext ctx, URI vArrayId, URI vpoolId, URI projectId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(vArrayId, null, null, vpoolId, null, true);
return createPortGroupOptions(portGroups.getStoragePortGroups());
}
return options;
}
use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.
the class BlockStorageUtils method isVMAXUsePortGroupEnabled.
public static boolean isVMAXUsePortGroupEnabled(URI resourceId) {
SimpleValueRep value = execute(new GetVMAXUsePortGroupEnabledConfig());
if (value.getValue().equalsIgnoreCase("true")) {
if (ResourceType.isType(ResourceType.VOLUME, resourceId)) {
BlockObjectRestRep obj = getVolume(resourceId);
if (obj instanceof VolumeRestRep) {
VolumeRestRep volume = (VolumeRestRep) obj;
boolean isVMAX = StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax3.name());
boolean isRPOrVPlex = isVplexOrRPVolume(volume);
if (isVMAX && !isRPOrVPlex) {
return true;
}
}
if (obj instanceof BlockSnapshotRestRep) {
BlockSnapshotRestRep snapshot = (BlockSnapshotRestRep) obj;
BlockObjectRestRep parent = getVolume(snapshot.getParent().getId());
if (parent instanceof VolumeRestRep) {
VolumeRestRep volume = (VolumeRestRep) obj;
if (StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(volume.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
return true;
}
}
if (parent instanceof BlockMirrorRestRep) {
BlockMirrorRestRep mirror = (BlockMirrorRestRep) obj;
if (StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
return true;
}
}
}
if (obj instanceof BlockMirrorRestRep) {
BlockMirrorRestRep mirror = (BlockMirrorRestRep) obj;
if (StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(mirror.getSystemType(), DiscoveredDataObject.Type.vmax3.name())) {
return true;
}
}
}
if (ResourceType.isType(ResourceType.VIRTUAL_POOL, resourceId)) {
BlockVirtualPoolRestRep virtualPool = execute(new GetBlockVirtualPool(resourceId));
boolean isVMAX = StringUtils.equalsIgnoreCase(virtualPool.getSystemType(), DiscoveredDataObject.Type.vmax.name()) || StringUtils.equalsIgnoreCase(virtualPool.getSystemType(), DiscoveredDataObject.Type.vmax3.name());
boolean isVPLEX = virtualPool.getHighAvailability() != null;
if (isVMAX && !isVPLEX) {
return true;
}
}
}
return false;
}
use of com.emc.storageos.model.customconfig.SimpleValueRep in project coprhd-controller by CoprHD.
the class BlockProvider method getExportVolumePortGroups.
@Asset("exportVolumePortGroups")
@AssetDependencies({ "unassignedBlockVolume", "host", "project" })
public List<AssetOption> getExportVolumePortGroups(AssetOptionsContext ctx, String selectedVolumes, URI hostOrClusterId, URI projectId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
List<URI> volumeIds = Lists.newArrayList();
info("Volumes selected by user: %s", selectedVolumes);
List<String> parsedVolumeIds = TextUtils.parseCSV(selectedVolumes);
for (String id : parsedVolumeIds) {
volumeIds.add(uri(id));
}
List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds);
Set<URI> virtualArrays = new HashSet<URI>();
Set<URI> storageSystems = new HashSet<URI>();
Set<URI> virtualPools = new HashSet<URI>();
for (VolumeRestRep volume : volumes) {
virtualArrays.add(volume.getVirtualArray().getId());
storageSystems.add(volume.getStorageController());
virtualPools.add(volume.getVirtualPool().getId());
}
if (virtualArrays.size() == 1 && storageSystems.size() == 1 && virtualPools.size() == 1) {
Iterator<URI> it = virtualArrays.iterator();
URI varrayId = it.next();
ExportGroupRestRep export = findExportGroup(hostOrClusterId, projectId, varrayId, client);
Iterator<URI> ssIt = storageSystems.iterator();
Iterator<URI> vpIt = virtualPools.iterator();
StoragePortGroupRestRepList portGroups = client.varrays().getStoragePortGroups(varrayId, export != null ? export.getId() : null, ssIt.next(), vpIt.next(), null, true);
return createPortGroupOptions(portGroups.getStoragePortGroups());
}
}
return options;
}
Aggregations