Search in sources :

Example 36 with VirtualArrayRestRep

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));
    }
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) StoragePortRestRep(com.emc.storageos.model.ports.StoragePortRestRep) URI(java.net.URI)

Example 37 with VirtualArrayRestRep

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);
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) FlashException(controllers.util.FlashException)

Example 38 with VirtualArrayRestRep

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();
    }
}
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 39 with VirtualArrayRestRep

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();
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) FlashException(controllers.util.FlashException)

Example 40 with VirtualArrayRestRep

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);
}
Also used : VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep)

Aggregations

VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)56 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)15 URI (java.net.URI)15 AssetOption (com.emc.vipr.model.catalog.AssetOption)14 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 ArrayList (java.util.ArrayList)10 FlashException (controllers.util.FlashException)9 HashSet (java.util.HashSet)8 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)6 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)6 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)5 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)4 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)4 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)4 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)4 HashMap (java.util.HashMap)4 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)3