use of com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceList 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.customservices.CustomServicesPrimitiveResourceList in project coprhd-controller by CoprHD.
the class WorkflowBuilder method getInventoryFilesForPackage.
public static void getInventoryFilesForPackage(final URI packageId) {
final List<String> inventoryFileNames = new ArrayList<String>();
if (null != packageId) {
final CustomServicesPrimitiveResourceList customServicesPrimitiveResourceList = getCatalogClient().customServicesPrimitives().getPrimitiveResourcesByType(CustomServicesConstants.ANSIBLE_INVENTORY_TYPE, packageId);
if (null != customServicesPrimitiveResourceList.getResources()) {
for (NamedRelatedResourceRep inventoryResource : customServicesPrimitiveResourceList.getResources()) {
inventoryFileNames.add(inventoryResource.getName());
}
}
}
renderJSON(inventoryFileNames);
}
use of com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceList in project coprhd-controller by CoprHD.
the class WorkflowBuilder method setAnsibleResources.
private static void setAnsibleResources() {
final CustomServicesPrimitiveResourceList customServicesPrimitiveResourceList = getCatalogClient().customServicesPrimitives().getPrimitiveResourcesByType(StepType.LOCAL_ANSIBLE.toString(), null);
final List<StringOption> ansibleResourceNames = new ArrayList<StringOption>();
if (null != customServicesPrimitiveResourceList.getResources()) {
for (final NamedRelatedResourceRep resourceRep : customServicesPrimitiveResourceList.getResources()) {
ansibleResourceNames.add(new StringOption(resourceRep.getId().toString(), resourceRep.getName()));
}
}
renderArgs.put("ansibleResourceNames", ansibleResourceNames);
}
use of com.emc.storageos.model.customservices.CustomServicesPrimitiveResourceList in project coprhd-controller by CoprHD.
the class WorkflowBuilder method addInventoryFileInputs.
// For each ansible step in workflow this method will look for host_file input and set the options to <hostid, hostname>
private static void addInventoryFileInputs(final CustomServicesWorkflowDocument.Step step) {
if (StringUtils.isNotEmpty(step.getType()) && StepType.LOCAL_ANSIBLE.toString().equals(step.getType())) {
CustomServicesWorkflowDocument.InputGroup inputGroup = step.getInputGroups().get(CustomServicesConstants.ANSIBLE_OPTIONS);
for (final CustomServicesWorkflowDocument.Input input : inputGroup.getInputGroup()) {
if (StringUtils.equals(CustomServicesConstants.ANSIBLE_HOST_FILE, input.getName())) {
// Setting type and options for host_file
input.setType(CustomServicesConstants.InputType.FROM_USER_MULTI.toString());
final CustomServicesPrimitiveRestRep primitiveRestRep = getCatalogClient().customServicesPrimitives().getPrimitive(step.getOperation());
final CustomServicesPrimitiveResourceList customServicesPrimitiveResourceList = getCatalogClient().customServicesPrimitives().getPrimitiveResourcesByType(CustomServicesConstants.ANSIBLE_INVENTORY_TYPE, primitiveRestRep.getResource().getId());
if (customServicesPrimitiveResourceList != null && CollectionUtils.isNotEmpty(customServicesPrimitiveResourceList.getResources())) {
final Map<String, String> options = new HashMap<String, String>();
for (NamedRelatedResourceRep n : customServicesPrimitiveResourceList.getResources()) {
options.put(n.getId().toString(), n.getName());
}
Logger.debug("Adding inventory file options {}", options);
input.setOptions(options);
} else {
// remove inventory files that have been set previously but deleted.
Logger.debug("Removing all the inventory files");
input.setOptions(new HashMap<String, String>());
}
break;
}
}
}
}
Aggregations