use of com.emc.storageos.model.systems.StorageSystemRestRep 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.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method storageSystemsJson.
public static void storageSystemsJson(String id) {
List<StorageSystemInfo> items = Lists.newArrayList();
for (StorageSystemRestRep storageSystem : StorageSystemUtils.getStorageSystemsByVirtualArray(id)) {
items.add(new StorageSystemInfo(storageSystem));
}
renderJSON(DataTablesSupport.createJSON(items, params));
}
use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method availableStoragePortsJson.
/**
* Renders the list of storage ports that are available to be assigned to the given virtual array.
*
* @param id
* the virtual array ID.
*/
public static void availableStoragePortsJson(String id) {
List<StoragePortInfo> items = Lists.newArrayList();
CachedResources<StorageSystemRestRep> storageSystems = StorageSystemUtils.createCache();
Map<URI, String> networks = NetworkUtils.getNetworkNames();
List<StoragePortRestRep> storagePorts = StoragePortUtils.getStoragePortsAssignableToVirtualArray(uri(id));
for (StoragePortRestRep storagePort : storagePorts) {
StoragePortInfo item = new StoragePortInfo(storagePort, storageSystems.get(storagePort.getStorageDevice()));
item.network = networks.get(id(storagePort.getNetwork()));
items.add(item);
}
renderJSON(DataTablesSupport.createJSON(items, params));
}
use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method storagePoolsJson.
/**
* Renders the list of storage pools for a given virtual array as JSON.
*
* @param id
* the virtual array ID.
*/
public static void storagePoolsJson(String id) {
List<StoragePoolInfo> items = Lists.newArrayList();
CachedResources<StorageSystemRestRep> storageSystems = StorageSystemUtils.createCache();
for (StoragePoolRestRep storagePool : StoragePoolUtils.getStoragePoolsAssignedToVirtualArray(id)) {
StoragePoolInfo item = new StoragePoolInfo(storagePool, storageSystems);
item.assigned = VirtualArrayUtils.isAssigned(storagePool, id);
items.add(item);
}
renderJSON(DataTablesSupport.createJSON(items, params));
}
use of com.emc.storageos.model.systems.StorageSystemRestRep in project coprhd-controller by CoprHD.
the class VirtualArrays method addStorageSystemsJson.
/**
* Gets the list of storage systems that may be associated to a virtual array.
*
* @param id
* the virtual array ID.
*/
public static void addStorageSystemsJson(String id) {
List<StorageSystemInfo> allitems = Lists.newArrayList();
Map<String, String> associatedStorage = new HashMap<String, String>();
for (StorageSystemRestRep associatedstorageSystem : StorageSystemUtils.getStorageSystemsByVirtualArray(id)) {
associatedStorage.put(associatedstorageSystem.getId().toString(), associatedstorageSystem.getName());
}
for (StorageSystemRestRep storageSystem : StorageSystemUtils.getStorageSystems()) {
if (associatedStorage.get(storageSystem.getId().toString()) == null) {
allitems.add(new StorageSystemInfo(storageSystem));
}
}
renderJSON(DataTablesSupport.createJSON(allitems, params));
}
Aggregations