use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class VMWareProvider method listVcentersForCluster.
protected List<VcenterRestRep> listVcentersForCluster(AssetOptionsContext context, URI clusterId) {
ClusterRestRep clusterRestRep = api(context).clusters().get(clusterId);
RelatedResourceRep vcenterDatacenter = clusterRestRep.getVcenterDataCenter();
if (vcenterDatacenter == null) {
// return all vcenters
return api(context).vcenters().getByTenant(context.getTenant(), REGISTERED.and(INCOMPATIBLE.not()));
} else {
// return the vcenter this vipr cluster is already associated with in vcenter
RelatedResourceRep vcenterRelatedRestRep = api(context).vcenterDataCenters().get(vcenterDatacenter.getId()).getVcenter();
VcenterRestRep vcenterRestRep = api(context).vcenters().get(vcenterRelatedRestRep.getId());
return Arrays.asList(vcenterRestRep);
}
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockVirtualPools method createAllFlashAuto.
/**
* This method create virtual pool according to storage system types
* @param types : List of storage system types discovered
*/
public static void createAllFlashAuto(List<String> types) {
List<String> vaIds4allflash = new ArrayList<String>();
List<String> vaIds4vmax = new ArrayList<String>();
List<String> vaIds4xio = new ArrayList<String>();
List<String> vaIds4unity = new ArrayList<String>();
JsonArray vpools = new JsonArray();
// Read cookies for storage systems and virtual pools
JsonObject dataObject = getCookieAsJson(GUIDE_DATA);
if (dataObject != null) {
JsonArray varrays = dataObject.getAsJsonArray(VARRAYS);
if (varrays != null) {
for (Object varray : varrays) {
JsonObject jsonvarray = (JsonObject) varray;
String varrayid = jsonvarray.get("id").getAsString();
// Check virtual array first
VirtualArrayRestRep varrayRest = VirtualArrayUtils.getVirtualArray(varrayid);
if (varrayRest != null) {
// Get virtual array attributes
Map<String, Set<String>> attributes = VirtualArrayUtils.getAvailableAttributes(uris(varrayid));
Set<String> system_type = attributes.get(ATTRIBUTE_SYSTEM_TYPES);
if (system_type != null && !system_type.isEmpty()) {
if (system_type.size() > 1) {
vaIds4allflash.add(varrayid);
} else {
// It has one system type
for (String vasystemtype : system_type) {
if (StringUtils.equals(UNITY, vasystemtype)) {
vaIds4unity.add(varrayid);
}
if (StringUtils.equals(VMAX, vasystemtype)) {
vaIds4vmax.add(varrayid);
}
if (StringUtils.equals(XTREMIO, vasystemtype)) {
vaIds4xio.add(varrayid);
}
}
}
} else {
// Control should not reach here but let add in all flash
vaIds4allflash.add(varrayid);
}
}
}
}
}
if (!vaIds4allflash.isEmpty()) {
Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
String vpid = virtualpoolAllFlashMap.get(VP_ALL_FLASH);
if (vpid != null) {
BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
for (String vaid : vaIds4allflash) {
RelatedResourceRep newVaId = new RelatedResourceRep();
newVaId.setId(URI.create(vaid));
virtualarrays.add(newVaId);
}
blockvpool.setVirtualArrays(virtualarrays);
updateAutoVirtualPool(vpid, blockvpool, vpools);
} else {
createBaseVPool(VP_ALL_FLASH, StorageSystemTypes.NONE, vaIds4allflash, Messages.get("gettingStarted.vpool.allflash.desc"), vpools);
}
}
if (!vaIds4vmax.isEmpty()) {
Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
// Check if we should add in existing compressed vpool
boolean isCompression = isCompressionEnable(vaIds4vmax);
String vpid = virtualpoolAllFlashMap.get(VP_VMAX_DIAMOND);
if (vpid != null && !isCompression) {
BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
for (String vaid : vaIds4vmax) {
RelatedResourceRep newVaId = new RelatedResourceRep();
newVaId.setId(URI.create(vaid));
virtualarrays.add(newVaId);
}
blockvpool.setVirtualArrays(virtualarrays);
updateAutoVirtualPool(vpid, blockvpool, vpools);
} else {
// Check compressed vpool
vpid = virtualpoolAllFlashMap.get(VP_VMAX_DIAMOND_COMPRESSED);
if (vpid != null && isCompression) {
BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
for (String vaid : vaIds4vmax) {
RelatedResourceRep newVaId = new RelatedResourceRep();
newVaId.setId(URI.create(vaid));
virtualarrays.add(newVaId);
}
blockvpool.setVirtualArrays(virtualarrays);
updateAutoVirtualPool(vpid, blockvpool, vpools);
} else {
createBaseVPool(VP_VMAX_DIAMOND, StorageSystemTypes.VMAX, vaIds4vmax, Messages.get("gettingStarted.vpool.vmax.desc"), vpools);
}
}
}
if (!vaIds4xio.isEmpty()) {
Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
String vpid = virtualpoolAllFlashMap.get(VP_XIO_DIAMOND);
if (vpid != null) {
BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
for (String vaid : vaIds4xio) {
RelatedResourceRep newVaId = new RelatedResourceRep();
newVaId.setId(URI.create(vaid));
virtualarrays.add(newVaId);
}
blockvpool.setVirtualArrays(virtualarrays);
updateAutoVirtualPool(vpid, blockvpool, vpools);
} else {
createBaseVPool(VP_XIO_DIAMOND, StorageSystemTypes.XTREMIO, vaIds4xio, Messages.get("gettingStarted.vpool.xio.desc"), vpools);
}
}
if (!vaIds4unity.isEmpty()) {
Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
String vpid = virtualpoolAllFlashMap.get(VP_UNITY_DIAMOND);
if (vpid != null) {
BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
for (String vaid : vaIds4unity) {
RelatedResourceRep newVaId = new RelatedResourceRep();
newVaId.setId(URI.create(vaid));
virtualarrays.add(newVaId);
}
blockvpool.setVirtualArrays(virtualarrays);
updateAutoVirtualPool(vpid, blockvpool, vpools);
} else {
createBaseVPool(VP_UNITY_DIAMOND, StorageSystemTypes.UNITY, vaIds4unity, Messages.get("gettingStarted.vpool.unity.desc"), vpools);
}
}
dataObject.add(VPOOL_COOKIES, vpools);
saveJsonAsCookie(GUIDE_DATA, dataObject);
list();
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method listComputePoolElements.
public static void listComputePoolElements(String id) {
List<ComputeVirtualElementInfo> results = Lists.newArrayList();
List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
List<RelatedResourceRep> matchedElements = computePool.getMatchedComputeElements();
for (RelatedResourceRep poolElement : matchedElements) {
for (ComputeElementRestRep element : allComputeElements) {
if (element.getId().equals(poolElement.getId())) {
results.add(new ComputeVirtualElementInfo(element, computePool.getName(), (String) "No Name yet"));
break;
}
}
}
renderJSON(DataTablesSupport.createJSON(results, params));
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method computeVirtualPoolDetails.
public static void computeVirtualPoolDetails(String id) {
ComputeVirtualPoolRestRep computeVirtualPool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
if (computeVirtualPool == null) {
error(MessagesUtils.get(UNKNOWN, id));
}
List<NamedRelatedResourceRep> temps = computeVirtualPool.getServiceProfileTemplates();
List<RelatedResourceRep> varrays = computeVirtualPool.getVirtualArrays();
StringBuilder selectedTemplatesBuilder = new StringBuilder();
for (RelatedResourceRep varray : varrays) {
List<ComputeSystemRestRep> arrayComputes = VirtualArrayUtils.getComputeSystems(varray.getId());
for (ComputeSystemRestRep acomp : arrayComputes) {
for (NamedRelatedResourceRep spt : acomp.getServiceProfileTemplates()) {
if (CollectionUtils.isNotEmpty(temps)) {
for (NamedRelatedResourceRep template : temps) {
if (spt.getId().equals(template.getId())) {
selectedTemplatesBuilder.append(acomp.getName()).append(" - ").append(template.getName()).append(", ");
}
}
}
}
}
}
String selectedTemplatesString = StringUtils.stripEnd(selectedTemplatesBuilder.toString(), ", ");
render(computeVirtualPool, selectedTemplatesString);
}
use of com.emc.storageos.model.RelatedResourceRep in project coprhd-controller by CoprHD.
the class BlockProvider method getAddMobilityGroupResources.
@Asset("addMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getAddMobilityGroupResources(AssetOptionsContext ctx, final URI mobilityGroupId) {
final ViPRCoreClient client = api(ctx);
VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
// VPLEX volumes that don't have reference to this mobility group
List<URI> volumeIds = client.blockVolumes().listBulkIds();
final ResourceFilter<VolumeRestRep> vplexFilter = new VplexVolumeFilter();
List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds, new ResourceFilter<VolumeRestRep>() {
@Override
public boolean acceptId(URI id) {
return true;
}
@Override
public boolean accept(VolumeRestRep item) {
boolean accept = (item.getVolumeGroups() == null || !contains(item, mobilityGroupId)) && vplexFilter.accept(item);
if (accept) {
boolean rpProtection = (item.getProtection() != null && item.getProtection().getRpRep() != null && item.getProtection().getRpRep().getPersonality() != null);
if (rpProtection) {
// If RP+VPLEX protection specified, only allow RP SOURCE volumes to be listed
// as candidates for mobility groups. Exclude TARGETs and JOURNALs.
String personality = item.getProtection().getRpRep().getPersonality();
if (Volume.PersonalityTypes.TARGET.name().equals(personality) || Volume.PersonalityTypes.METADATA.name().equals(personality)) {
accept = false;
}
}
}
return accept;
}
private boolean contains(VolumeRestRep item, URI mobilityGroup) {
for (RelatedResourceRep vg : item.getVolumeGroups()) {
if (vg.getId().equals(mobilityGroup)) {
return true;
}
}
return false;
}
});
return createBaseResourceOptions(volumes);
} else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
List<URI> hostIds = client.hosts().listBulkIds();
List<HostRestRep> hosts = client.hosts().getByIds(hostIds, new ResourceFilter<HostRestRep>() {
@Override
public boolean acceptId(URI id) {
return true;
}
@Override
public boolean accept(HostRestRep item) {
return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
}
private boolean contains(HostRestRep item, URI mobilityGroup) {
for (RelatedResourceRep vg : item.getVolumeGroups()) {
if (vg.getId().equals(mobilityGroup)) {
return true;
}
}
return false;
}
});
return createBaseResourceOptions(hosts);
} else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
List<URI> clusterIds = client.clusters().listBulkIds();
List<ClusterRestRep> clusters = client.clusters().getByIds(clusterIds, new ResourceFilter<ClusterRestRep>() {
@Override
public boolean acceptId(URI id) {
return true;
}
@Override
public boolean accept(ClusterRestRep item) {
return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
}
private boolean contains(ClusterRestRep item, URI mobilityGroup) {
for (RelatedResourceRep vg : item.getVolumeGroups()) {
if (vg.getId().equals(mobilityGroup)) {
return true;
}
}
return false;
}
});
return createBaseResourceOptions(clusters);
} else {
return Lists.newArrayList();
}
}
Aggregations