From 12b75688366a49f00981f3e08d0e40e3e13f4ab5 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Thu, 20 Feb 2020 12:51:49 -0500 Subject: [PATCH] add sendMetrics flag, set ansible ctx vars depending on value --- .../src/main/java/bubble/model/bill/AccountPlan.java | 4 ++++ .../src/main/java/bubble/model/cloud/BubbleNetwork.java | 8 ++++++-- .../java/bubble/service/cloud/AnsiblePrepService.java | 6 ++++++ .../en_US/server/post_auth/ResourceMessages.properties | 3 +++ bubble-web | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/bubble-server/src/main/java/bubble/model/bill/AccountPlan.java b/bubble-server/src/main/java/bubble/model/bill/AccountPlan.java index e26fad74..e60a3aea 100644 --- a/bubble-server/src/main/java/bubble/model/bill/AccountPlan.java +++ b/bubble-server/src/main/java/bubble/model/bill/AccountPlan.java @@ -146,6 +146,9 @@ public class AccountPlan extends IdentifiableBase implements HasAccount { @Transient @Getter @Setter private transient String forkHost = null; public boolean hasForkHost () { return !empty(forkHost); } + @Transient @Getter @Setter private transient Boolean sendMetrics = null; + public boolean sendMetrics () { return bool(sendMetrics); } + public BubbleNetwork bubbleNetwork(Account account, BubbleDomain domain, BubblePlan plan, @@ -157,6 +160,7 @@ public class AccountPlan extends IdentifiableBase implements HasAccount { .setTimezone(getTimezone()) .setAccount(account.getUuid()) .setSshKey(getSshKey()) + .setSendMetrics(sendMetrics()) .setDomain(domain.getUuid()) .setDomainName(domain.getName()) .setFootprint(getFootprint()) diff --git a/bubble-server/src/main/java/bubble/model/cloud/BubbleNetwork.java b/bubble-server/src/main/java/bubble/model/cloud/BubbleNetwork.java index 94a91700..12211d49 100644 --- a/bubble-server/src/main/java/bubble/model/cloud/BubbleNetwork.java +++ b/bubble-server/src/main/java/bubble/model/cloud/BubbleNetwork.java @@ -34,8 +34,7 @@ import static bubble.ApiConstants.ROOT_NETWORK_UUID; import static bubble.model.cloud.BubbleDomain.DOMAIN_NAME_MAXLEN; import static bubble.model.cloud.BubbleNetworkState.created; import static bubble.server.BubbleConfiguration.getDEFAULT_LOCALE; -import static org.cobbzilla.util.daemon.ZillaRuntime.die; -import static org.cobbzilla.util.daemon.ZillaRuntime.empty; +import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.http.HttpSchemes.SCHEME_HTTPS; import static org.cobbzilla.util.reflect.ReflectionUtil.copy; import static org.cobbzilla.util.string.ValidationRegexes.HOST_PART_PATTERN; @@ -154,6 +153,11 @@ public class BubbleNetwork extends IdentifiableBase implements HasNetwork, HasBu @Type(type=ENCRYPTED_STRING) @Column(columnDefinition="varchar("+(100+ENC_PAD)+") NOT NULL") @Getter @Setter private String timezone = "America/New_York"; + @ECSearchable @ECField(index=140) + @Column(nullable=false) + @ECIndex @Getter @Setter private Boolean sendMetrics = false; + public boolean sendMetrics() { return bool(sendMetrics); } + @Embedded @Getter @Setter private BubbleTags tags; @Transient @Getter @Setter private transient String forkHost; diff --git a/bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java b/bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java index bd531ea7..b4de9887 100644 --- a/bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java +++ b/bubble-server/src/main/java/bubble/service/cloud/AnsiblePrepService.java @@ -80,6 +80,12 @@ public class AnsiblePrepService { ctx.put("sslPort", network.getSslPort()); ctx.put("publicBaseUri", network.getPublicUri()); + if (network.sendMetrics()) { + ctx.put("errbit_url", configuration.getErrorApi().getUrl()); + ctx.put("errbit_key", configuration.getErrorApi().getKey()); + ctx.put("errbit_env", node.getFqdn()); + } + ctx.put("network", network); ctx.put("node", node); ctx.put("roles", installRoles.stream().map(AnsibleRole::getRoleName).collect(Collectors.toList())); diff --git a/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties b/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties index 803a13c2..306b97ca 100644 --- a/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties +++ b/bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties @@ -202,12 +202,15 @@ field_label_network_fork_host=Fork Host field_description_network_fork_host=The current Sage Launcher will be forked onto this host. field_label_network_domain=Domain field_label_plan=Plan +message_plan_max_accounts=You can create up to {{max}} user accounts on this Bubble +message_plan_no_max_accounts=This plan supports an unlimited number of user accounts field_label_show_advanced_plan_options=Show All Options field_label_region=Location field_label_footprint=Footprint field_label_network_ssh_key=SSH Key field_description_network_ssh_key=You can SSH into the Bubble with this key message_network_ssh_key_do_not_install=Do not install any SSH key +field_label_send_metrics=Send error reports and usage statistics field_label_paymentMethod=Payment err_noPaymentMethods=No payment methods are configured. Contact the administrator of this system. msg_km_distance_away=km away diff --git a/bubble-web b/bubble-web index 77a70b6a..a268aa39 160000 --- a/bubble-web +++ b/bubble-web @@ -1 +1 @@ -Subproject commit 77a70b6af46b485843bce74a259d731090a6cf46 +Subproject commit a268aa39ec1f0373d15af7b52477c81e561137bd