use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method addVarrayStorageSystem.
/**
* Adds all ports of the given storage systems to a virtual array.
*
* @param virtualArrayId
* the virtual array ID.
* @param ids
* the storage system IDs.
*/
private static void addVarrayStorageSystem(String virtualArrayId, String id) {
List<URI> storagePorts = Lists.newArrayList();
URI storageSystemId = uri(id);
List<StoragePortRestRep> ports = StoragePortUtils.getStoragePortsByStorageSystem(storageSystemId);
storagePorts.addAll(ResourceUtils.ids(ports));
if (!storagePorts.isEmpty()) {
VirtualArrayRestRep virtualArray = getVirtualArray(virtualArrayId);
updateStoragePorts(storagePorts, addVirtualArray(virtualArray));
}
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method createSimple.
/**
* Simple create and save operation that takes only the name.
*
* @param name
* Name of the virtual array
*/
@FlashException("list")
public static void createSimple(String name) {
VirtualArrayForm virtualArray = new VirtualArrayForm();
virtualArray.name = name;
virtualArray.validate("virtualArray");
if (Validation.hasErrors()) {
flash.error(MessagesUtils.get(SAVED_ERROR, virtualArray.name));
list();
}
VirtualArrayRestRep varray = virtualArray.save();
flash.success(MessagesUtils.get(SAVED_SUCCESS, virtualArray.name));
virtualArray.load(varray);
edit(virtualArray.id);
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method createDefaultVarray.
/**
* Create default virtual array for checklist
*/
public static void createDefaultVarray(String defaultVarrayType) {
boolean isVarrayAvail = false;
if (StringUtils.equals(defaultVarrayType, SIMPLE)) {
// Check if virtual array is already created
String existVarrayId = null;
List<VirtualArrayRestRep> availVarrays = VirtualArrayUtils.getVirtualArrays();
for (VirtualArrayRestRep availVarray : availVarrays) {
if (StringUtils.equals(availVarray.getName(), ALL_FLASH_VARRAY)) {
existVarrayId = availVarray.getId().toString();
isVarrayAvail = true;
break;
}
}
if (isVarrayAvail && existVarrayId != null) {
// Virtual Array already created, add rest of storage
// List Storages already attached to this virtual array
HashMap<String, String> attachedStorageMaps = new HashMap<String, String>();
List<String> ids = Lists.newArrayList();
for (StorageSystemRestRep storageSystem : StorageSystemUtils.getStorageSystemsByVirtualArray(existVarrayId)) {
attachedStorageMaps.put(storageSystem.getId().toString(), storageSystem.getId().toString());
}
for (StorageSystemRestRep storageSystem : StorageSystemUtils.getStorageSystems()) {
if (attachedStorageMaps.isEmpty()) {
// Check if storage system is of type UNITY, VMAX or XtremIO
if (StringUtils.equals(XTREMIO, storageSystem.getSystemType())) {
ids.add(storageSystem.getId().toString());
}
if (StringUtils.equals(VMAX, storageSystem.getSystemType()) || StringUtils.equals(UNITY, storageSystem.getSystemType())) {
String modelType = storageSystem.getModel();
if (modelType != null && (modelType.contains(SUFFIX_ALL_FLASH) || modelType.contains(POWERMAX) || modelType.contains(PMAX))) {
ids.add(storageSystem.getId().toString());
}
}
} else {
if (null == attachedStorageMaps.get(storageSystem.getId().toString())) {
// Check if storage system is of type UNITY, VMAX or XtremIO
if (StringUtils.equals(XTREMIO, storageSystem.getSystemType())) {
ids.add(storageSystem.getId().toString());
}
if (StringUtils.equals(VMAX, storageSystem.getSystemType()) || StringUtils.equals(UNITY, storageSystem.getSystemType())) {
String modelType = storageSystem.getModel();
if (modelType != null && (modelType.contains(SUFFIX_ALL_FLASH) || modelType.contains(POWERMAX) || modelType.contains(PMAX))) {
ids.add(storageSystem.getId().toString());
}
}
}
}
}
addStorageSysVarray(existVarrayId, ids);
} else {
// First time adding virtual array
addAllFlashVirtualArray();
}
} else if (StringUtils.equals(defaultVarrayType, MAPPING1X1)) {
// Read available virtual array
List<VirtualArrayRestRep> availVarrays = VirtualArrayUtils.getVirtualArrays();
// If storage system ids are passed, use them and create virtual arrays
JsonObject dataObject = getCookieAsJson(GUIDE_DATA);
JsonArray storage_systems = dataObject.getAsJsonArray(STORAGE_SYSTEMS);
JsonArray varrays = dataObject.getAsJsonArray(VARRAYS);
if (varrays == null) {
varrays = new JsonArray();
}
if (storage_systems != null) {
for (Object storageobject : storage_systems) {
JsonObject storage = (JsonObject) storageobject;
String storageid = storage.get("id").getAsString();
String storagename = storage.get("name").getAsString();
StorageSystemRestRep storageSystem = StorageSystemUtils.getStorageSystem(storageid);
if (storageSystem != null && isEMCAFA(storageSystem)) {
VirtualArrayForm virtualArray = new VirtualArrayForm();
String vArrayName = VARRAY_PREFIX + storagename;
for (VirtualArrayRestRep availVarray : availVarrays) {
if (StringUtils.equals(availVarray.getName(), vArrayName)) {
Calendar localCalendar = Calendar.getInstance();
// Made time in seconds for name length
long currTime = localCalendar.getTimeInMillis() / 1000;
vArrayName = vArrayName + VARRAY_POSTFIX + currTime;
break;
}
}
virtualArray.name = vArrayName;
VirtualArrayRestRep varray = virtualArray.save();
virtualArray.load(varray);
addVarrayStorageSystem(virtualArray.id, storageid);
buildVarrayCookies(virtualArray.id, virtualArray.name, varrays);
}
}
dataObject.add(VARRAYS, varrays);
saveJsonAsCookie(GUIDE_DATA, dataObject);
} else {
// Create a storage system map that have virtual arrays attached
HashMap<String, String> storageSysVarrayMap = new HashMap<String, String>();
for (VirtualArrayRestRep availVarray : VirtualArrayUtils.getVirtualArrays()) {
for (StorageSystemRestRep storageSystem : StorageSystemUtils.getStorageSystemsByVirtualArray(availVarray.getId().toString())) {
storageSysVarrayMap.put(storageSystem.getId().toString(), storageSystem.getId().toString());
}
}
// Get all storage systems, and create varrays for those storage system that do not have varray
for (StorageSystemRestRep storageSystem : StorageSystemUtils.getStorageSystems()) {
if (storageSysVarrayMap.get(storageSystem.getId().toString()) == null) {
if (isEMCAFA(storageSystem)) {
createVirtualArray(storageSystem);
}
}
}
}
list();
} else // List page so that user can add virtual array them self
{
list();
}
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method save.
/**
* Saves a virtual array.
*
* @param virtualArray
* the virtual array.
*/
@FlashException(referrer = { "createSimple", "edit", "list" })
public static void save(VirtualArrayForm virtualArray) {
if (virtualArray == null) {
list();
}
virtualArray.validate("virtualArray");
if (Validation.hasErrors()) {
Common.handleError();
}
VirtualArrayRestRep varray = virtualArray.save();
if (TenantUtils.canReadAllTenants() && VirtualArrayUtils.canUpdateACLs()) {
saveTenantACLs(varray.getId().toString(), virtualArray.tenants);
}
flash.success(MessagesUtils.get(SAVED_SUCCESS, virtualArray.name));
backToReferrer();
list();
}
use of com.emc.storageos.model.varray.VirtualArrayRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method networks.
/**
* Displays the networks page for the given virtual array.
*
* @param id
* the virtual array ID.
*/
public static void networks(String id) {
VirtualArrayRestRep virtualArray = getVirtualArray(id);
VirtualArrayNetworksDataTable dataTable = new VirtualArrayNetworksDataTable();
render(virtualArray, dataTable);
}
Aggregations