Skip to content

Commit ddc4385

Browse files
authored
*: add --instance-types (#295)
Signed-off-by: Gyuho Lee <[email protected]>
1 parent c7829e7 commit ddc4385

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

avalanche-ops/src/aws/spec.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ pub struct DefaultSpecOption {
303303
pub ingress_ipv4_cidr: String,
304304
pub instance_mode: String,
305305
pub instance_size: String,
306+
pub instance_types: Vec<String>,
306307
pub volume_size_in_gb: u32,
307308

308309
pub ip_mode: String,
@@ -671,9 +672,12 @@ impl Spec {
671672
}
672673
};
673674

674-
let instance_types =
675-
ec2::default_instance_types(&opts.region, &opts.arch_type, &opts.instance_size)
676-
.unwrap();
675+
let instance_types = if !opts.instance_types.is_empty() {
676+
opts.instance_types.clone()
677+
} else {
678+
ec2::default_instance_types(&opts.region, &opts.arch_type, &opts.instance_size).unwrap()
679+
};
680+
677681
let machine = Machine {
678682
anchor_nodes,
679683
non_anchor_nodes,

avalancheup-aws/src/default_spec/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ pub fn command() -> Command {
108108
.value_parser(["large", "xlarge", "2xlarge", "4xlarge", "8xlarge"])
109109
.default_value("xlarge"),
110110
)
111+
.arg(
112+
Arg::new("INSTANCE_TYPES")
113+
.long("instance-types")
114+
.help("Sets the comma-separated instance types (overwrites --instance-size)")
115+
.required(false)
116+
.num_args(1),
117+
)
111118
.arg(
112119
Arg::new("IP_MODE")
113120
.long("ip-mode")

avalancheup-aws/src/main.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ async fn main() -> io::Result<()> {
4545
}
4646
}
4747

48+
let s = sub_matches
49+
.get_one::<String>("INSTANCE_TYPES")
50+
.unwrap_or(&String::new())
51+
.clone();
52+
let ss: Vec<&str> = s.split(',').collect();
53+
let mut instance_types = Vec::new();
54+
for addr in ss.iter() {
55+
let trimmed = addr.trim().to_string();
56+
if !trimmed.is_empty() {
57+
instance_types.push(addr.trim().to_string());
58+
}
59+
}
60+
4861
let opt = avalanche_ops::aws::spec::DefaultSpecOption {
4962
log_level: sub_matches
5063
.get_one::<String>("LOG_LEVEL")
@@ -96,6 +109,7 @@ async fn main() -> io::Result<()> {
96109
.get_one::<String>("INSTANCE_SIZE")
97110
.unwrap_or(&String::from("large"))
98111
.clone(),
112+
instance_types,
99113

100114
volume_size_in_gb: sub_matches
101115
.get_one::<u32>("VOLUME_SIZE_IN_GB")

0 commit comments

Comments
 (0)