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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations