Skip to content

Commit a7952d5

Browse files
committed
hyperstack pricing, done correctly
1 parent f887cc3 commit a7952d5

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

src/packages/next/components/landing/live-demo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function liveDemoUrl(context) {
77
return getSupportUrl({
88
subject: "Contact Us!",
99
type: "question",
10-
body: `I would like to chat with a Sales Representative!\n\nWHEN IS A GOOD TIME (include timezone!): [REQUIRED]\n\nYOUR ORGANIZATION: [REQUIRED]\n\n(Only requests filled out in good faith will receive a response.)\n`,
10+
body: `I would like to chat with a CoCalc Representative!\n\nWHEN IS A GOOD TIME (include timezone!): [REQUIRED]\n\nYOUR ORGANIZATION: [REQUIRED]\n\n(Only requests filled out in good faith will receive a response.)\n`,
1111
hideExtra: true,
1212
context,
1313
url: "",

src/packages/server/compute/cloud/hyperstack/pricing-data.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ util/compute/cloud/hyperstack/pricing.ts
88
We of course include not-available options so that we can compute
99
the current price of any VM.
1010
11+
VERY IMPORTANT!!! The pricebook that Hyperstack returns to us has (see [1])
12+
two fields "value" and "original_value". We signed a contract with Hyperstack
13+
stating that we will not divulge the "value" field. Thus below in creating
14+
the version of this data that should be sent to customers, be very careful to
15+
only access and use the "original_value" field!
16+
17+
[1] https://infrahub-doc.nexgencloud.com/docs/api-reference/pricebook-resources/pricebook
1118
*/
1219

1320
import type {
@@ -107,10 +114,15 @@ export default async function getPricingData(
107114
}
108115
}
109116

110-
const { compute_servers_markup_percentage: markup } =
111-
await getServerSettings();
112-
const external_ip_cost_per_hour = Number(priceMap["PublicIP"].value);
113-
const ssd_cost_per_hour = Number(priceMap["Cloud-SSD"].value);
117+
const {
118+
compute_servers_markup_percentage: global_markup,
119+
hyperstack_compute_servers_markup_percentage: hyperstack_markup,
120+
} = await getServerSettings();
121+
const markup = hyperstack_markup
122+
? parseFloat(hyperstack_markup)
123+
: global_markup;
124+
const external_ip_cost_per_hour = Number(priceMap["PublicIP"].original_value);
125+
const ssd_cost_per_hour = Number(priceMap["Cloud-SSD"].original_value);
114126
const x = { options, markup, external_ip_cost_per_hour, ssd_cost_per_hour };
115127

116128
ttlCache.set("x", x);
@@ -127,17 +139,17 @@ function computeCost({
127139
gpu_count,
128140
}): number | string {
129141
let cost =
130-
Number(priceMap["Cloud-SSD"].value) * disk +
131-
Number(priceMap["PublicIP"].value);
142+
Number(priceMap["Cloud-SSD"].original_value) * disk +
143+
Number(priceMap["PublicIP"].original_value);
132144
if (gpu) {
133145
// for machines with GPU's, the cost seems to be the internal disk (which we do not use at all)
134146
// plus the cost of an ip address, plus the gpu cost.
135-
cost += Number(priceMap[gpu].value) * gpu_count;
147+
cost += Number(priceMap[gpu].original_value) * gpu_count;
136148
} else {
137149
// for NON-GPU machines (cpu only) the cost is a function of the number of cpu's and the amount of ram.
138150
cost +=
139-
Number(priceMap["vCPU (cpu-only-flavors)"].value) * cpu +
140-
Number(priceMap["RAM (cpu-only-flavors)"].value) * ram;
151+
Number(priceMap["vCPU (cpu-only-flavors)"].original_value) * cpu +
152+
Number(priceMap["RAM (cpu-only-flavors)"].original_value) * ram;
141153
}
142154
return cost;
143155
}

src/packages/util/db-schema/site-defaults.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const TAGS = [
3434
"GitHub",
3535
"Pay as you Go",
3636
"Compute Servers",
37+
"Google Cloud",
38+
"Hyperstack",
3739
"AI LLM",
3840
"Theme",
3941
"On-Prem",

src/packages/util/db-schema/site-settings-extras.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export type SiteSettingsExtrasKeys =
247247
// | "lambda_cloud_api_key"
248248
| "hyperstack_api_key"
249249
| "hyperstack_compute_servers_prefix"
250+
| "hyperstack_compute_servers_markup_percentage"
250251
| "hyperstack_ssh_public_key"
251252
| "hyperstack_balance_alert_thresh"
252253
| "hyperstack_balance_alert_emails"
@@ -757,8 +758,8 @@ export const EXTRAS: SettingsExtras = {
757758
tags: ["Compute Servers"],
758759
},
759760
compute_servers_markup_percentage: {
760-
name: "Compute Servers -- Markup Percentage",
761-
desc: "The markup percentage that we add to the cost we pay to the cloud service providers. This accounts for maintenance, dev, servers, and *bandwidth* (which can be massive). For example, '30' would mean we add 30% to the price that the cloud service provides charge us for compute, and we currently gamble regarding bandwidth costs.",
761+
name: "Compute Servers - Markup Percentage",
762+
desc: "The default markup percentage that we add to the cost we pay to the cloud service providers. This accounts for maintenance, dev, servers, and *bandwidth* (which can be massive). For example, '30' would mean we add 30% to the price that the cloud service provides charge us for compute, and we currently gamble regarding bandwidth costs. There may be more customized pricing and markups for specific providers configured elsewhere.",
762763
default: "30",
763764
show: (conf) => only_commercial(conf) && compute_servers_enabled(conf),
764765
to_val: toFloat,
@@ -771,38 +772,47 @@ export const EXTRAS: SettingsExtras = {
771772
default: "",
772773
password: true,
773774
show: compute_servers_hyperstack_enabled,
774-
tags: ["Compute Servers"],
775+
tags: ["Compute Servers", "Hyperstack"],
775776
},
776777
hyperstack_compute_servers_prefix: {
777778
name: "Compute Servers: Hyperstack - Resource Prefix",
778779
desc: "Prepend this string to all Hyperstack resources that are created, e.g., VM names, disks, etc. If the prefix is 'cocalc', then the compute server with id 17 will be called 'cocalc-17'. REQUIRED or Hyperstack will not work.",
779780
default: "cocalc",
780781
to_val: to_trimmed_str,
781782
show: compute_servers_hyperstack_enabled,
782-
tags: ["Compute Servers"],
783+
tags: ["Compute Servers", "Hyperstack"],
784+
},
785+
hyperstack_compute_servers_markup_percentage: {
786+
name: "Compute Servers: Hyperstack - Markup Percentage",
787+
desc: "Markup percentage specifically for hyperstack. If not given (i.e., empty string), the global compute server markup is used. This is always the markup on the public list price, and has nothing to do with negotiated wholesale pricing.",
788+
default: "",
789+
show: compute_servers_hyperstack_enabled,
790+
to_val: to_trimmed_str,
791+
valid: () => true,
792+
tags: ["Compute Servers", "Hyperstack"],
783793
},
784794
hyperstack_ssh_public_key: {
785795
name: "Compute Servers: Hyperstack - Public SSH Key",
786796
desc: "A public SSH key that grants access to all Hyperstack VM's for admin and debugging purposes. REQUIRED or Hyperstack will not work.",
787797
default: "",
788798
password: true,
789799
show: compute_servers_hyperstack_enabled,
790-
tags: ["Compute Servers"],
800+
tags: ["Compute Servers", "Hyperstack"],
791801
},
792802
hyperstack_balance_alert_thresh: {
793803
name: "Compute Servers: Hyperstack - Balance Alert Threshold",
794804
desc: "If your credit balance goes below this amount on the Hyperstack site, then you will be emailed (assuming email is configured).",
795805
default: "25",
796806
to_val: to_int,
797807
show: compute_servers_hyperstack_enabled,
798-
tags: ["Compute Servers"],
808+
tags: ["Compute Servers", "Hyperstack"],
799809
},
800810
hyperstack_balance_alert_emails: {
801811
name: "Compute Servers: Hyperstack - Balance Email Addresses",
802812
desc: "If your credit balance goes below your configured threshold, then these email addresses will get an alert message. Separate addresses by commas.",
803813
default: "",
804814
show: compute_servers_hyperstack_enabled,
805-
tags: ["Compute Servers"],
815+
tags: ["Compute Servers", "Hyperstack"],
806816
},
807817

808818
// lambda_cloud_api_key: {
@@ -827,7 +837,7 @@ export const EXTRAS: SettingsExtras = {
827837
multiline: 5,
828838
password: true,
829839
show: compute_servers_google_enabled,
830-
tags: ["Compute Servers"],
840+
tags: ["Compute Servers", "Google Cloud"],
831841
},
832842
google_cloud_bigquery_billing_service_account_json: {
833843
name: "Compute Servers: Google Cloud BigQuery Service Account Json",
@@ -836,7 +846,7 @@ export const EXTRAS: SettingsExtras = {
836846
multiline: 5,
837847
password: true,
838848
show: compute_servers_google_enabled,
839-
tags: ["Compute Servers"],
849+
tags: ["Compute Servers", "Google Cloud"],
840850
},
841851
google_cloud_bigquery_detailed_billing_table: {
842852
name: "Compute Servers: Google Cloud Detailed Billing BigQuery Table Name",
@@ -845,15 +855,15 @@ export const EXTRAS: SettingsExtras = {
845855
to_val: to_trimmed_str,
846856
show: compute_servers_google_enabled,
847857
valid: (x) => !x || x.includes(".detailed_billing."),
848-
tags: ["Compute Servers"],
858+
tags: ["Compute Servers", "Google Cloud"],
849859
},
850860
google_cloud_compute_servers_prefix: {
851861
name: "Compute Servers: Google Cloud - Resource Prefix",
852862
desc: "Prepend this string to all Google cloud resources that are created, e.g., VM names, etc. This is useful if you are using a single Google cloud project for more than just this one cocalc server. KEEP THIS SHORT! If the prefix is 'comput', then the compute server with id 17 will be called 'compute-17'. You very likely want to change this, especially if you have several servers in the same Google cloud project; it must be different between different servers.",
853863
default: "compute",
854864
to_val: to_trimmed_str,
855865
show: compute_servers_google_enabled,
856-
tags: ["Compute Servers"],
866+
tags: ["Compute Servers", "Google Cloud"],
857867
valid: () => true,
858868
},
859869
google_cloud_compute_servers_image_prefix: {
@@ -862,7 +872,7 @@ export const EXTRAS: SettingsExtras = {
862872
default: "cocalc",
863873
to_val: to_trimmed_str,
864874
show: compute_servers_google_enabled,
865-
tags: ["Compute Servers"],
875+
tags: ["Compute Servers", "Google Cloud"],
866876
valid: () => true,
867877
},
868878

0 commit comments

Comments
 (0)