119 lines
4.8 KiB
Ruby
119 lines
4.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "yaml"
|
|
|
|
module Option
|
|
ai_models = YAML.load_file("config/ai_models.yml")
|
|
AI_MODELS = ai_models.select { it["enabled"] }.freeze
|
|
|
|
def self.locations(only_visible: true, feature_flags: [])
|
|
Location.where(project_id: nil).all.select { |pl| !only_visible || (pl.visible || feature_flags.include?("location_#{pl.name.tr("-", "_")}")) }
|
|
end
|
|
|
|
def self.kubernetes_locations
|
|
Location.where(name: ["hetzner-fsn1", "leaseweb-wdc02"]).all
|
|
end
|
|
|
|
def self.kubernetes_versions
|
|
["v1.33", "v1.32"].freeze
|
|
end
|
|
|
|
def self.families
|
|
Option::VmFamilies.select { it.visible }
|
|
end
|
|
|
|
BootImage = Struct.new(:name, :display_name)
|
|
BootImages = [
|
|
["ubuntu-noble", "Ubuntu Noble 24.04 LTS"],
|
|
["ubuntu-jammy", "Ubuntu Jammy 22.04 LTS"],
|
|
["debian-12", "Debian 12"],
|
|
["almalinux-9", "AlmaLinux 9"]
|
|
].map { |args| BootImage.new(*args) }.freeze
|
|
|
|
VmFamily = Data.define(:name, :ui_descriptor, :visible, :require_shared_slice) do
|
|
def display_name
|
|
name.capitalize
|
|
end
|
|
end
|
|
|
|
VmFamilies = [
|
|
["standard", "Dedicated CPU", true, false],
|
|
["standard-gpu", "Dedicated GPU", false, false],
|
|
["premium", "Dedicated Premium CPU", false, false],
|
|
["burstable", "Shared CPU", true, true]
|
|
].map { |args| VmFamily.new(*args) }
|
|
|
|
IoLimits = Struct.new(:max_ios_per_sec, :max_read_mbytes_per_sec, :max_write_mbytes_per_sec)
|
|
NO_IO_LIMITS = IoLimits.new(nil, nil, nil).freeze
|
|
|
|
VmSize = Struct.new(:name, :family, :vcpus, :cpu_percent_limit, :cpu_burst_percent_limit, :memory_gib, :storage_size_options, :io_limits, :visible, :arch) do
|
|
alias_method :display_name, :name
|
|
end
|
|
VmSizes = [2, 4, 8, 16, 30, 60].map {
|
|
storage_size_options = [it * 20, it * 40]
|
|
VmSize.new("standard-#{it}", "standard", it, it * 100, 0, it * 4, storage_size_options, NO_IO_LIMITS, true, "x64")
|
|
}.concat([2, 4, 8, 16, 30, 60].map {
|
|
storage_size_options = [it * 20, it * 40]
|
|
VmSize.new("standard-#{it}", "standard", it, it * 100, 0, (it * 3.2).to_i, storage_size_options, NO_IO_LIMITS, false, "arm64")
|
|
}).concat([6].map {
|
|
VmSize.new("standard-gpu-#{it}", "standard-gpu", it, it * 100, 0, (it * 5.34).to_i, [it * 30], NO_IO_LIMITS, false, "x64")
|
|
}).concat([2, 4, 8, 16, 30].map {
|
|
storage_size_options = [it * 20, it * 40]
|
|
VmSize.new("premium-#{it}", "premium", it, it * 100, 0, it * 4, storage_size_options, NO_IO_LIMITS, false, "x64")
|
|
}).concat([1, 2].map {
|
|
storage_size_options = [it * 10, it * 20]
|
|
io_limits = IoLimits.new(nil, it * 50, it * 50)
|
|
VmSize.new("burstable-#{it}", "burstable", it, it * 50, it * 50, it * 2, storage_size_options, io_limits, true, "x64")
|
|
}).concat([1, 2].map {
|
|
storage_size_options = [it * 10, it * 20]
|
|
io_limits = IoLimits.new(nil, it * 50, it * 50)
|
|
VmSize.new("burstable-#{it}", "burstable", it, it * 50, it * 50, (it * 1.6).to_i, storage_size_options, io_limits, false, "arm64")
|
|
}).freeze
|
|
|
|
# Postgres Global Options
|
|
POSTGRES_FLAVOR_OPTIONS = [
|
|
PostgresResource::Flavor::STANDARD,
|
|
PostgresResource::Flavor::PARADEDB,
|
|
PostgresResource::Flavor::LANTERN
|
|
].freeze
|
|
|
|
POSTGRES_LOCATION_OPTIONS = Location.where(name: ["hetzner-fsn1", "leaseweb-wdc02"]).all.freeze
|
|
|
|
PostgresFamilyOption = Data.define(:name, :ui_description)
|
|
POSTGRES_FAMILY_OPTIONS = [
|
|
PostgresFamilyOption.new("standard", "Dedicated CPU"),
|
|
PostgresFamilyOption.new("burstable", "Shared CPU")
|
|
].freeze
|
|
|
|
PostgresSizeOption = Data.define(:name, :family, :vcpu_count, :memory_gib)
|
|
POSTGRES_SIZE_OPTIONS = [
|
|
PostgresSizeOption.new("standard-2", "standard", 2, 8),
|
|
PostgresSizeOption.new("standard-4", "standard", 4, 16),
|
|
PostgresSizeOption.new("standard-8", "standard", 8, 32),
|
|
PostgresSizeOption.new("standard-16", "standard", 16, 64),
|
|
PostgresSizeOption.new("standard-30", "standard", 30, 120),
|
|
PostgresSizeOption.new("standard-60", "standard", 60, 240),
|
|
PostgresSizeOption.new("burstable-1", "burstable", 1, 2),
|
|
PostgresSizeOption.new("burstable-2", "burstable", 2, 4)
|
|
].freeze
|
|
|
|
POSTGRES_STORAGE_SIZE_OPTIONS = ["16", "32", "64", "128", "256", "512", "1024", "2048", "4096"].freeze
|
|
|
|
POSTGRES_VERSION_OPTIONS = ["16", "17"].freeze
|
|
|
|
PostgresHaOption = Data.define(:name, :standby_count, :description)
|
|
POSTGRES_HA_OPTIONS = [
|
|
PostgresHaOption.new(PostgresResource::HaType::NONE, 0, "No Standbys"),
|
|
PostgresHaOption.new(PostgresResource::HaType::ASYNC, 1, "1 Standby"),
|
|
PostgresHaOption.new(PostgresResource::HaType::SYNC, 2, "2 Standbys")
|
|
].freeze
|
|
|
|
AWS_LOCATIONS = ["us-east-1"].freeze
|
|
|
|
KubernetesCPOption = Struct.new(:cp_node_count, :title, :explanation)
|
|
KubernetesCPOptions = [[1, "1 Node", "Single control plane node without resilience"],
|
|
[3, "3 Nodes", "Three control plane nodes with resilience"]].map {
|
|
KubernetesCPOption.new(*it)
|
|
}.freeze
|
|
end
|