Search in sources :

Example 1 with VirtualNasParam

use of com.emc.storageos.model.project.VirtualNasParam in project coprhd-controller by CoprHD.

the class StorageSystems method dissociateProject.

@FlashException(keep = true, referrer = { "virtualNasServers" })
public static void dissociateProject(@As(",") String[] projectIdsToDissociate, String nasIds, String storageId) {
    if (projectIdsToDissociate != null && projectIdsToDissociate.length > 0) {
        for (String projectId : projectIdsToDissociate) {
            Set<String> vNASSet = new HashSet<String>();
            vNASSet.add(nasIds);
            VirtualNasParam vNasParam = new VirtualNasParam();
            vNasParam.setVnasServers(vNASSet);
            getViprClient().virtualNasServers().unassignVnasServers(uri(projectId), vNasParam);
        }
    }
    virtualNasServers(storageId);
}
Also used : VirtualNasParam(com.emc.storageos.model.project.VirtualNasParam) HashSet(java.util.HashSet) FlashException(controllers.util.FlashException)

Example 2 with VirtualNasParam

use of com.emc.storageos.model.project.VirtualNasParam in project coprhd-controller by CoprHD.

the class StorageSystems method associateProject.

@FlashException(keep = true, referrer = { "virtualNasServers" })
public static void associateProject(String nasIds, String projectIds, String storageId) throws Exception {
    boolean error = false;
    Set<String> vnasServers = new TreeSet<String>();
    String[] projectIdArray = null;
    if (nasIds != null && !nasIds.isEmpty()) {
        String[] nasArray = nasIds.split(",");
        Collections.addAll(vnasServers, nasArray);
    }
    if (projectIds != null && !projectIds.isEmpty()) {
        projectIds = projectIds.trim();
        projectIdArray = projectIds.split(",");
    }
    VirtualNasParam vNasParam = new VirtualNasParam();
    vNasParam.setVnasServers(vnasServers);
    if (projectIdArray != null && projectIdArray.length > 0) {
        for (int i = 0; i < projectIdArray.length; i++) {
            try {
                getViprClient().virtualNasServers().assignVnasServers(uri(projectIdArray[i].trim()), vNasParam);
            } catch (Exception e) {
                error = true;
                continue;
            }
        }
        if (error) {
            String errorMsg = "Some Virtual NAS servers could not be associated with selected project(s). Please check the API logs for more information.";
            throw new Exception(errorMsg);
        }
    }
    virtualNasServers(storageId);
}
Also used : VirtualNasParam(com.emc.storageos.model.project.VirtualNasParam) TreeSet(java.util.TreeSet) Endpoint(com.emc.storageos.model.valid.Endpoint) FlashException(controllers.util.FlashException) FlashException(controllers.util.FlashException)

Aggregations

VirtualNasParam (com.emc.storageos.model.project.VirtualNasParam)2 FlashException (controllers.util.FlashException)2 Endpoint (com.emc.storageos.model.valid.Endpoint)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1