|
|
@@ -45,10 +45,13 @@ import static org.cobbzilla.util.io.FileUtil.abs; |
|
|
|
import static org.cobbzilla.util.io.FileUtil.mkdirOrDie; |
|
|
|
import static org.cobbzilla.util.io.StreamUtil.copyClasspathDirectory; |
|
|
|
import static org.cobbzilla.util.json.JsonUtil.json; |
|
|
|
import static org.cobbzilla.wizard.server.config.OpenApiConfiguration.OPENAPI_DISABLED; |
|
|
|
|
|
|
|
@Service @Slf4j |
|
|
|
public class AnsiblePrepService { |
|
|
|
|
|
|
|
private static final int MIN_OPEN_API_MEMORY = 4096; |
|
|
|
|
|
|
|
@Autowired private DatabaseFilterService dbFilter; |
|
|
|
@Autowired private BubbleConfiguration configuration; |
|
|
|
@Autowired private AccountPlanDAO accountPlanDAO; |
|
|
@@ -92,6 +95,12 @@ public class AnsiblePrepService { |
|
|
|
ctx.put("support", configuration.getSupport()); |
|
|
|
ctx.put("appLinks", configuration.getAppLinks()); |
|
|
|
|
|
|
|
if (shouldEnableOpenApi(installType, nodeSize)) { |
|
|
|
ctx.put("openapi_contact_email", configuration.getOpenApi().getContactEmail()); |
|
|
|
} else { |
|
|
|
ctx.put("openapi_contact_email", OPENAPI_DISABLED); |
|
|
|
} |
|
|
|
|
|
|
|
if (network.sendErrors() && configuration.hasErrorApi()) { |
|
|
|
final ErrorApiConfiguration errorApi = configuration.getErrorApi(); |
|
|
|
ctx.put("error_url", errorApi.getUrl()); |
|
|
@@ -168,4 +177,12 @@ public class AnsiblePrepService { |
|
|
|
return (int) (((double) memoryMB) * 0.19d); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean shouldEnableOpenApi(AnsibleInstallType installType, ComputeNodeSize nodeSize) { |
|
|
|
// to enable OpenAPI on a deployed node: |
|
|
|
// - it must already be enabled on the current bubble |
|
|
|
// - the bubble being launched must be a sage or have 4GB+ memory |
|
|
|
return configuration.hasOpenApi() && |
|
|
|
(installType == AnsibleInstallType.sage || nodeSize.getMemoryMB() >= MIN_OPEN_API_MEMORY); |
|
|
|
} |
|
|
|
|
|
|
|
} |