Search in sources :

Example 16 with NamedRelatedResourceRep

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

the class ComputeMapper method map.

public static ComputeImageRestRep map(ComputeImage from) {
    if (from == null) {
        return null;
    }
    ComputeImageRestRep to = new ComputeImageRestRep();
    mapDataObjectFields(from, to);
    to.setImageName(from.getImageName());
    to.setImageUrl(ImageServerControllerImpl.maskImageURLPassword(from.getImageUrl()));
    to.setImageType(from.getImageType());
    to.setComputeImageStatus(from.getComputeImageStatus());
    to.setLastImportStatusMessage(from.getLastImportStatusMessage());
    List<NamedRelatedResourceRep> availableServersList = new ArrayList<NamedRelatedResourceRep>();
    List<NamedRelatedResourceRep> failedServersList = new ArrayList<NamedRelatedResourceRep>();
    to.setAvailableImageServers(availableServersList);
    to.setFailedImageServers(failedServersList);
    return to;
}
Also used : ComputeImageRestRep(com.emc.storageos.model.compute.ComputeImageRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 17 with NamedRelatedResourceRep

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

the class WorkflowBuilder method updateWorkflowInventoryFiles.

private static boolean updateWorkflowInventoryFiles(final String localAnsiblePrimitiveId) {
    boolean updatedWorkflows = false;
    final CustomServicesWorkflowList customServicesWorkflowList = getCatalogClient().customServicesPrimitives().getWorkflows(localAnsiblePrimitiveId);
    if (customServicesWorkflowList != null && CollectionUtils.isNotEmpty(customServicesWorkflowList.getWorkflows())) {
        for (final NamedRelatedResourceRep resourceRep : customServicesWorkflowList.getWorkflows()) {
            final URI workflowId = resourceRep.getId();
            final CustomServicesWorkflowRestRep customServicesWorkflowRestRep = getCatalogClient().customServicesPrimitives().getWorkflow(workflowId);
            if (null != customServicesWorkflowRestRep) {
                Logger.info("Updating workflow {} with new host inventory files", workflowId);
                final CustomServicesWorkflowUpdateParam param = new CustomServicesWorkflowUpdateParam();
                for (final CustomServicesWorkflowDocument.Step step : customServicesWorkflowRestRep.getDocument().getSteps()) {
                    addInventoryFileInputs(step);
                }
                param.setDocument(customServicesWorkflowRestRep.getDocument());
                getCatalogClient().customServicesPrimitives().editWorkflow(workflowId, param);
                updatedWorkflows = true;
            }
        }
    }
    return updatedWorkflows;
}
Also used : CustomServicesWorkflowDocument(com.emc.storageos.model.customservices.CustomServicesWorkflowDocument) CustomServicesWorkflowList(com.emc.storageos.model.customservices.CustomServicesWorkflowList) CustomServicesWorkflowRestRep(com.emc.storageos.model.customservices.CustomServicesWorkflowRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI) CustomServicesWorkflowUpdateParam(com.emc.storageos.model.customservices.CustomServicesWorkflowUpdateParam)

Example 18 with NamedRelatedResourceRep

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

the class WorkflowBuilder method getWFDirectories.

public static void getWFDirectories() {
    final List<Node> topLevelNodes = new ArrayList<Node>();
    prepareRootNodes(topLevelNodes);
    // get workflow directories and prepare nodes
    final WFBulkRep wfBulkRep = getCatalogClient().wfDirectories().getAll();
    String nodeParent;
    final Map<URI, WFDirectoryRestRep> fileParents = new HashMap<URI, WFDirectoryRestRep>();
    for (WFDirectoryRestRep wfDirectoryRestRep : wfBulkRep.getWfDirectories()) {
        if (null == wfDirectoryRestRep.getParent()) {
            nodeParent = MY_LIBRARY_ROOT;
        } else {
            nodeParent = wfDirectoryRestRep.getParent().getId().toString();
        }
        final Node node = new Node(wfDirectoryRestRep.getId().toString(), wfDirectoryRestRep.getName(), nodeParent, WFBuilderNodeTypes.FOLDER.toString());
        // add workflows that are under this node
        if (null != wfDirectoryRestRep.getWorkflows()) {
            for (URI u : wfDirectoryRestRep.getWorkflows()) {
                fileParents.put(u, wfDirectoryRestRep);
            }
        }
        topLevelNodes.add(node);
    }
    // Add primitives
    addPrimitivesByType(topLevelNodes, StepType.LOCAL_ANSIBLE.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.REMOTE_ANSIBLE.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.SHELL_SCRIPT.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.REST.toString(), MY_LIBRARY_ROOT, fileParents);
    addPrimitivesByType(topLevelNodes, StepType.VIPR_REST.toString(), VIPR_PRIMITIVE_ROOT, null);
    // Add workflows
    final CustomServicesWorkflowList customServicesWorkflowList = getCatalogClient().customServicesPrimitives().getWorkflows();
    if (null != customServicesWorkflowList && null != customServicesWorkflowList.getWorkflows()) {
        for (NamedRelatedResourceRep o : customServicesWorkflowList.getWorkflows()) {
            final String parent = fileParents.containsKey(o.getId()) ? fileParents.get(o.getId()).getId().toString() : MY_LIBRARY_ROOT;
            topLevelNodes.add(new Node(o.getId().toString(), o.getName(), parent, StepType.WORKFLOW.toString()));
        }
    }
    renderJSON(topLevelNodes);
}
Also used : HashMap(java.util.HashMap) WFBulkRep(com.emc.vipr.model.catalog.WFBulkRep) ArrayList(java.util.ArrayList) WFDirectoryRestRep(com.emc.vipr.model.catalog.WFDirectoryRestRep) CustomServicesWorkflowList(com.emc.storageos.model.customservices.CustomServicesWorkflowList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 19 with NamedRelatedResourceRep

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

the class WorkflowBuilder method updateInventoryFiles.

// Keep only newInventoryFileNames - get existing and remove the ones that are not there in the newly sent list
private static boolean updateInventoryFiles(final URI packageId, final String newInventoryFileNames) {
    boolean updateDone = false;
    if (null == packageId) {
        return updateDone;
    }
    final Map<String, URI> inventoryFiles = new HashMap<String, URI>();
    final CustomServicesPrimitiveResourceList customServicesPrimitiveResourceList = getCatalogClient().customServicesPrimitives().getPrimitiveResourcesByType(CustomServicesConstants.ANSIBLE_INVENTORY_TYPE, packageId);
    if (null != customServicesPrimitiveResourceList.getResources()) {
        for (NamedRelatedResourceRep inventoryResource : customServicesPrimitiveResourceList.getResources()) {
            inventoryFiles.put(inventoryResource.getName(), inventoryResource.getId());
        }
    }
    final String[] fileNames = null != newInventoryFileNames ? newInventoryFileNames.split(",") : new String[0];
    final List<String> newInventoryFileNamesList = Arrays.asList(fileNames);
    inventoryFiles.keySet().removeAll(newInventoryFileNamesList);
    for (final URI inventoryId : inventoryFiles.values()) {
        getCatalogClient().customServicesPrimitives().deletePrimitiveResource(inventoryId);
        updateDone = true;
    }
    return updateDone;
}
Also used : CustomServicesPrimitiveResourceList(com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceList) HashMap(java.util.HashMap) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URI(java.net.URI)

Example 20 with NamedRelatedResourceRep

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

the class ComputeVirtualPools method getServiceProfileTemplates.

public static void getServiceProfileTemplates(ComputeVirtualPoolsForm computeVirtualPool) {
    List<ComputeSystemRestRep> allComputes = Lists.newArrayList();
    List<StringOption> templateList = Lists.newArrayList();
    List<String> temps = Lists.newArrayList();
    if (computeVirtualPool.id != null) {
        ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(computeVirtualPool.id);
        for (NamedRelatedResourceRep tmp : computePool.getServiceProfileTemplates()) {
            temps.add(tmp.getId().toString());
        }
    }
    Map<String, Set<String>> csTemplatesMap = new HashMap<String, Set<String>>();
    Map<String, String> computeSystemsMap = new HashMap<String, String>();
    Map<String, String> templatesMap = new HashMap<String, String>();
    if (computeVirtualPool.virtualArrays != null) {
        for (String arrayId : computeVirtualPool.virtualArrays) {
            List<ComputeSystemRestRep> arrayComputes = VirtualArrayUtils.getComputeSystems(uri(arrayId));
            for (ComputeSystemRestRep acomp : arrayComputes) {
                String compId = acomp.getId().toString();
                if (!computeSystemsMap.containsKey(compId)) {
                    computeSystemsMap.put(compId, acomp.getName());
                }
                Set<String> spts = csTemplatesMap.get(compId);
                if (spts == null) {
                    spts = new HashSet<String>();
                }
                for (NamedRelatedResourceRep spt : acomp.getServiceProfileTemplates()) {
                    spts.add(spt.getId().toString());
                    if (!templatesMap.containsKey(spt.getId().toString())) {
                        templatesMap.put(spt.getId().toString(), spt.getName());
                    }
                }
                csTemplatesMap.put(compId, spts);
            }
        }
        for (Entry<String, Set<String>> comp : csTemplatesMap.entrySet()) {
            Set<String> compTemplates = comp.getValue();
            if (compTemplates != null && !compTemplates.isEmpty()) {
                String systemName = ComputeSystemTypes.getDisplayValue(ComputeSystemTypes.UCS) + " " + computeSystemsMap.get(comp.getKey());
                computeVirtualPool.systems.add(new StringOption(comp.getKey(), systemName));
                List<StringOption> templateOptions = Lists.newArrayList();
                templateOptions.add(new StringOption("NONE", ""));
                for (String template : compTemplates) {
                    templateOptions.add(new StringOption(template, templatesMap.get(template)));
                    if (!temps.isEmpty()) {
                        for (String templateId : temps) {
                            if (templateId.contains(template)) {
                                templateList.add(new StringOption(comp.getKey(), template));
                            }
                        }
                    }
                }
                computeVirtualPool.systemOptions.put(comp.getKey(), templateOptions);
            }
        }
        computeVirtualPool.selectedTemplates = "{}";
        if (!templateList.isEmpty()) {
            String jsonString = "{\"";
            for (int index = 0; index < templateList.size(); index++) {
                if (jsonString.indexOf("urn") > 0) {
                    jsonString = jsonString + ",\"";
                }
                jsonString = jsonString + templateList.get(index).id + "\":\"" + templateList.get(index).name + "\"";
            }
            jsonString = jsonString + "}";
            computeVirtualPool.selectedTemplates = jsonString;
        }
    } else {
        computeVirtualPool.selectedTemplates = "{}";
    }
    render("@templates", computeVirtualPool);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) StringOption(util.StringOption) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Aggregations

NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)111 URI (java.net.URI)47 ArrayList (java.util.ArrayList)28 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)22 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)18 Asset (com.emc.sa.asset.annotation.Asset)11 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)11 AssetOption (com.emc.vipr.model.catalog.AssetOption)9 HashMap (java.util.HashMap)8 GET (javax.ws.rs.GET)8 Produces (javax.ws.rs.Produces)8 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)7 Path (javax.ws.rs.Path)7 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)6 NamedURI (com.emc.storageos.db.client.model.NamedURI)5 SnapshotList (com.emc.storageos.model.SnapshotList)5 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)5 StorageSystemRestRep (com.emc.storageos.model.systems.StorageSystemRestRep)5 HashSet (java.util.HashSet)5 List (java.util.List)5