Show available option values in separate section after options display. In cases where Options can be taken from elsewhere in the application, do that instead of hard coding the options. This allows burstable-1 and burstable-2 to show up as VM/PG size options, and show more available VM/PG storage sizes. This doesn't show which storage sizes are valid for a given VM/PG size. That's possible but would clutter the display. Update to a later rodish checkout, which moved some of the features UbiCli uses to plugins, and load those plugins.
34 lines
1.3 KiB
Ruby
34 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
UbiCli.on("lb").run_on("create") do
|
|
desc "Create a load balancer"
|
|
|
|
options("ubi lb location/lb-name create [options] ps-id src-port dst-port", key: :lb_create) do
|
|
on("-a", "--algorithm=alg", "set the algorithm to use")
|
|
on("-e", "--check-endpoint=path", "set the health check endpoint (default: #{Prog::Vnet::LoadBalancerNexus::DEFAULT_HEALTH_CHECK_ENDPOINT})")
|
|
on("-p", "--check-protocol=proto", "set the health check protocol")
|
|
on("-s", "--stack=stack", "set the stack")
|
|
end
|
|
help_option_values("Algorithm:", %w[round_robin hash_based])
|
|
help_option_values("Health Check Protocol:", %w[http https tcp])
|
|
help_option_values("Stack:", %w[dual ipv4 ipv6])
|
|
|
|
args 3
|
|
|
|
run do |private_subnet_id, src_port, dst_port, opts|
|
|
params = underscore_keys(opts[:lb_create])
|
|
params["algorithm"] ||= "round_robin"
|
|
if (endpoint = params.delete("check_endpoint"))
|
|
params["health_check_endpoint"] = endpoint
|
|
end
|
|
params["health_check_protocol"] = params.delete("check_protocol") || "http"
|
|
params["stack"] ||= "dual"
|
|
params["private_subnet_id"] = private_subnet_id
|
|
params["src_port"] = src_port
|
|
params["dst_port"] = dst_port
|
|
post(lb_path, params) do |data|
|
|
["Load balancer created with id: #{data["id"]}"]
|
|
end
|
|
end
|
|
end
|