Search in sources :

Example 31 with StorageSystemRestRep

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();
    }
}
Also used : HashMap(java.util.HashMap) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) Calendar(java.util.Calendar) JsonObject(com.google.gson.JsonObject) JsonArray(com.google.gson.JsonArray) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) List(java.util.List) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject)

Example 32 with StorageSystemRestRep

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));
}
Also used : StorageSystemInfo(models.datatable.StorageSystemDataTable.StorageSystemInfo) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep)

Example 33 with StorageSystemRestRep

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));
}
Also used : StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) StoragePortInfo(models.datatable.StoragePortDataTable.StoragePortInfo) URI(java.net.URI)

Example 34 with StorageSystemRestRep

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));
}
Also used : StoragePoolInfo(models.datatable.StoragePoolDataTable.StoragePoolInfo) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep) StoragePoolRestRep(com.emc.storageos.model.pools.StoragePoolRestRep)

Example 35 with StorageSystemRestRep

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));
}
Also used : StorageSystemInfo(models.datatable.StorageSystemDataTable.StorageSystemInfo) HashMap(java.util.HashMap) StorageSystemRestRep(com.emc.storageos.model.systems.StorageSystemRestRep)

Aggregations

StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)44 URI (java.net.URI)11 ArrayList (java.util.ArrayList)10 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)7 HashSet (java.util.HashSet)7 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 StoragePoolRestRep (com.emc.storageos.model.pools.StoragePoolRestRep)5 Asset (com.emc.sa.asset.annotation.Asset)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)3 StorageProviderRestRep (com.emc.storageos.model.smis.StorageProviderRestRep)3 JsonArray (com.google.gson.JsonArray)3 JsonObject (com.google.gson.JsonObject)3 HashMap (java.util.HashMap)3 GetStorageSystems (com.emc.sa.service.vipr.tasks.GetStorageSystems)2 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)2