Search in sources :

Example 6 with ProjectRestRep

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

the class FileSystems method getReplicationPolicy.

private static FilePolicyRestRep getReplicationPolicy(ViPRCoreClient client, FileShareRestRep fs) {
    if (fs != null) {
        // Check file system vpool has replication policy!!!
        FileVirtualPoolRestRep vpool = client.fileVpools().get(fs.getVirtualPool().getId());
        if (vpool != null && vpool.getFileProtectionPolicies() != null && !vpool.getFileProtectionPolicies().isEmpty()) {
            for (String uriPolicy : vpool.getFileProtectionPolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType())) {
                    return policyRestRep;
                }
            }
        }
        // Check file system project has replication policy!!!
        ProjectRestRep project = client.projects().get(fs.getProject().getId());
        if (project != null && project.getFileProtectionPolicies() != null && !project.getFileProtectionPolicies().isEmpty()) {
            for (String uriPolicy : project.getFileProtectionPolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType()) && policyRestRep.getVpool() != null && policyRestRep.getVpool().getId() != null && policyRestRep.getVpool().getId().equals(vpool.getId())) {
                    return policyRestRep;
                }
            }
        }
        // Check file system has replication policy!!!
        if (fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
            for (String uriPolicy : fs.getFilePolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType())) {
                    return policyRestRep;
                }
            }
        }
    }
    return null;
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep)

Example 7 with ProjectRestRep

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

the class ResourceController method validateActiveProjectId.

@Util
private static boolean validateActiveProjectId(String activeProjectId) {
    if (StringUtils.isNotBlank(activeProjectId)) {
        URI activeProjectIdUri = URI.create(activeProjectId);
        String tenantId = Models.currentAdminTenant();
        List<ProjectRestRep> projects = getProjects(tenantId);
        for (ProjectRestRep project : projects) {
            if (project.getId().equals(activeProjectIdUri)) {
                return true;
            }
        }
    }
    return false;
}
Also used : ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) AppSupportUtil(util.AppSupportUtil) Util(play.mvc.Util)

Example 8 with ProjectRestRep

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

the class VirtualNasServers method getVirtualNasServers.

private static List<VirtualNasServerInfo> getVirtualNasServers(String projectId) {
    if (projectId == null) {
        return Collections.EMPTY_LIST;
    }
    List<VirtualNasServerInfo> vNasServers = Lists.newArrayList();
    ProjectRestRep projRestRep = getViprClient().projects().get(uri(projectId));
    Set<String> vNasIds = projRestRep.getAssignedVNasServers();
    List<URI> vNasUris = Lists.newArrayList();
    if (vNasIds != null) {
        for (String id : vNasIds) {
            vNasUris.add(uri(id));
        }
        if (!vNasUris.isEmpty()) {
            List<VirtualNASRestRep> vNas = getViprClient().virtualNasServers().getByIds(vNasUris);
            for (VirtualNASRestRep vNasServer : vNas) {
                vNasServers.add(new VirtualNasServerInfo(vNasServer, true));
            }
        }
    }
    return vNasServers;
}
Also used : VirtualNasServerInfo(models.datatable.VirtualNasServerDataTable.VirtualNasServerInfo) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) URI(java.net.URI) VirtualNASRestRep(com.emc.storageos.model.vnas.VirtualNASRestRep)

Example 9 with ProjectRestRep

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

the class Projects method delete.

@FlashException("list")
public static void delete(@As(",") String[] ids) {
    String tenantId = null;
    if (ids != null && ids.length > 0) {
        ProjectRestRep project = ProjectUtils.getProject(ids[0]);
        if (project != null) {
            tenantId = project.getTenant().toString();
        }
        for (String id : ids) {
            ProjectUtils.deactivate(uri(id));
        }
        flash.success(MessagesUtils.get("projects.deleted"));
    }
    list();
}
Also used : ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 10 with ProjectRestRep

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

the class Projects method save.

@FlashException(keep = true, referrer = { "create", "edit" })
public static void save(ProjectForm project) {
    if (project == null) {
        Logger.error("No project parameters passed");
        badRequest("No project parameters passed");
        return;
    }
    project.validate("project");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    if (project.isNew()) {
        project.id = stringId(ProjectUtils.create(project.tenantId, new ProjectParam(project.name)));
        saveProjectQuota(project);
        saveProjectACLs(project.id, project.aclEntries);
    } else {
        ProjectRestRep currentProject = ProjectUtils.getProject(project.id);
        if (currentProject != null) {
            saveProjectQuota(project);
            saveProjectACLs(project.id, project.aclEntries);
            ProjectUtils.update(project.id, new ProjectUpdateParam(project.name, project.owner));
        }
    }
    flash.success(MessagesUtils.get("projects.saved", project.name));
    JsonObject jobject = getCookieAsJson(VIPR_START_GUIDE);
    if (jobject != null && jobject.get(GUIDE_COMPLETED_STEP) != null && jobject.get(GUIDE_VISIBLE) != null) {
        if (jobject.get("completedSteps").getAsInt() == 7 && jobject.get("guideVisible").getAsBoolean()) {
            JsonObject dataObject = getCookieAsJson(GUIDE_DATA);
            JsonArray projects = dataObject.getAsJsonArray("projects");
            if (projects == null) {
                projects = new JsonArray();
            }
            boolean addToCookie = true;
            for (Object projectObject : projects) {
                JsonObject projectjson = (JsonObject) projectObject;
                if (projectjson.get("id") != null) {
                    String projectId = projectjson.get("id").getAsString();
                    if (StringUtils.equals(projectId, project.id)) {
                        // update case, don't add in cookie
                        addToCookie = false;
                        break;
                    }
                }
            }
            if (addToCookie) {
                JsonObject projectObject = new JsonObject();
                projectObject.addProperty("id", project.id);
                projectObject.addProperty("name", project.name);
                projects.add(projectObject);
                dataObject.add("projects", projects);
                saveJsonAsCookie("GUIDE_DATA", dataObject);
            }
        }
    }
    if (StringUtils.isNotBlank(project.referrerUrl)) {
        redirect(project.referrerUrl);
    } else {
        list();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ProjectParam(com.emc.storageos.model.project.ProjectParam) ProjectUpdateParam(com.emc.storageos.model.project.ProjectUpdateParam) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Aggregations

ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)24 URI (java.net.URI)13 ArrayList (java.util.ArrayList)7 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 FlashException (controllers.util.FlashException)4 Test (org.junit.Test)4 Asset (com.emc.sa.asset.annotation.Asset)3 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)2 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)2 HostRestRep (com.emc.storageos.model.host.HostRestRep)2 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)2 ProjectUpdateParam (com.emc.storageos.model.project.ProjectUpdateParam)2 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)1