private String getToscaTemplateId(EntitySpec<?> entitySpec) { return String.valueOf(entitySpec.getFlags().get(ApplicationSpecsBuilder.TOSCA_TEMPLATE_ID)); } }
private boolean isKeyConfigured(EntitySpec<?> spec, ConfigKey<?> key) { return spec.getConfig().containsKey(key) || spec.getFlags().containsKey(key.getName()); }
@Override public void apply(EntitySpec<?> entitySpec, String nodeId, ToscaApplication toscaApplication) { String computeName = toscaApplication.getNodeName(nodeId).or(String.valueOf(entitySpec.getFlags().get(ApplicationSpecsBuilder.TOSCA_TEMPLATE_ID))); Map<String, Object> templatePropertyObjects = getToscaFacade().getTemplatePropertyObjects(nodeId, toscaApplication, computeName); configureConfigKeysSpec(entitySpec, ConfigBag.newInstance(templatePropertyObjects)); } }
private <T extends Entity> T createEntityAndDescendantsUninitialized(EntitySpec<T> spec, Optional<String> entityId, Map<String,Entity> entitiesByEntityId, Map<String,EntitySpec<?>> specsByEntityId) { if (spec.getFlags().containsKey("parent") || spec.getFlags().containsKey("owner")) { throw new IllegalArgumentException("Spec's flags must not contain parent or owner; use spec.parent() instead for "+spec); if (spec.getFlags().containsKey("id")) { throw new IllegalArgumentException("Spec's flags must not contain id; use spec.id() instead for "+spec);
@Override public void apply(EntitySpec<?> entitySpec, String nodeId, ToscaApplication toscaApplication) { if (!entitySpec.getType().isAssignableFrom(VanillaSoftwareProcess.class)) { return; } // If the entity spec is of type VanillaSoftwareProcess, we assume that it's running. The operations should // then take care of setting up the correct scripts. // We add .getName to these ConfigKeys to use them as Flags because later we will potentially // override the configured value with a BrooklynDslDeferredSupplier object. This overridden // value would not have been used since it would be treated as a Flag while the ConfigKey would // take precedence. entitySpec.configure(VanillaSoftwareProcess.LAUNCH_COMMAND.getName(), "true"); entitySpec.configure(VanillaSoftwareProcess.STOP_COMMAND.getName(), "true"); entitySpec.configure(VanillaSoftwareProcess.CHECK_RUNNING_COMMAND.getName(), "true"); // Applying operations final Iterable<String> operations = getToscaFacade().getInterfaceOperations(nodeId, toscaApplication); for (String opKey : operations) { String computeName = toscaApplication.getNodeName(nodeId).or(String.valueOf(entitySpec.getFlags().get(ApplicationSpecsBuilder.TOSCA_TEMPLATE_ID))); final Optional<Object> script = getToscaFacade().getScript(opKey, nodeId, toscaApplication, computeName, EXPANDED_FOLDER); if (script.isPresent()) { entitySpec.configure(getToscaFacade().getLifeCycle(opKey).getName(), script.get()); } } } }
if (script.isPresent()) { String lifecycle = getToscaFacade().getLifeCycle(opKey).getName(); Object existingScript = entitySpec.getFlags().get(lifecycle); Object newScript = script.get(); if (existingScript != null && !Strings.isBlank(String.valueOf(existingScript))) {
Predicates.not(Predicates.<ConfigKey<?>>equalTo(EntityManagementUtils.WRAPPER_APP_MARKER))); wrappedChild.configure(configWithoutWrapperMarker); wrappedChild.configure(wrapperParent.getFlags());
addSpecParameters(spec, theEntity.getMutableEntityType()); theEntity.configure(MutableMap.copyOf(spec.getFlags())); for (Map.Entry<ConfigKey<?>, Object> entry : spec.getConfig().entrySet()) { entity.config().set((ConfigKey)entry.getKey(), entry.getValue());
webClusterSpec = EntitySpec.create(DynamicWebAppCluster.class); boolean hasMemberSpec = webClusterSpec.getConfig().containsKey(DynamicWebAppCluster.MEMBER_SPEC) || webClusterSpec.getFlags().containsKey("memberSpec"); if (!hasMemberSpec) { webClusterSpec.configure(webClusterFlags);