Skip to content

Commit

Permalink
Migrate from facility to metro lingo
Browse files Browse the repository at this point in the history
The Equinix Metal API has deprecated¹ use of the facility² keyword back
in 2023-05 and now after 2024-03-30 it will be removed.

It has been replaced by the metro³ keyword, that serves a same purpose.

The `"any"` metro can be used to set no restriction on instance creation.

[1] https://feedback.equinixmetal.com/changelog/bye-facilities-hello-again-metros
[2] https://deploy.equinix.com/developers/docs/metal/locations/facilities/
[3] https://deploy.equinix.com/developers/docs/metal/locations/metros/
  • Loading branch information
mweinelt committed Mar 18, 2024
1 parent e78390e commit 673a926
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
7 changes: 5 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@

config = lib.mkOption {
type = lib.types.submodule {
options.facilities = lib.mkOption {
options.metros = lib.mkOption {
type = with lib.types; listOf str;
description = lib.mdDoc ''
The facilities the instances are allowed to be created in.
The metros the instances are allowed to be created in.
'';
example = [
"any"
];
};
options.tags = lib.mkOption {
type = with lib.types; listOf str;
Expand Down
6 changes: 3 additions & 3 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct Device {
#[derive(Serialize, Debug)]
struct CreateDeviceRequest {
always_pxe: bool,
facility: Vec<String>,
metro: Vec<String>,
hostname: String,
ipxe_script_url: String,
operating_system: String,
Expand All @@ -62,7 +62,7 @@ pub async fn create_device(
equinix_project_id: &str,
plan: HardwarePlan,
tags: &[String],
facilities: &[String],
metros: &[String],
) -> Result<Device> {
let raw = http_client
.post(format!(
Expand All @@ -78,7 +78,7 @@ pub async fn create_device(
spot_instance: true,
spot_price_max: plan.bid,
tags: tags.to_vec(),
facility: facilities.to_vec(),
metro: metros.to_vec(),
})
.header(ACCEPT, "application/json")
.header(CONTENT_TYPE, "application/json")
Expand Down
10 changes: 5 additions & 5 deletions src/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ type CategoryMap = HashMap<System, HashMap<JobSize, HardwareCategory>>;
pub struct Config {
categories: CategoryMap,
tags: Vec<String>,
facilities: Vec<String>,
metros: Vec<String>,
}

pub struct DesiredHardwareConfig {
pub plans: Vec<HardwarePlan>,
pub tags: Vec<String>,
pub facilities: Vec<String>,
pub metros: Vec<String>,
}

pub fn parse_config_file(file: &Path) -> Result<Config> {
Expand Down Expand Up @@ -119,12 +119,12 @@ pub async fn get_desired_hardware(

let mut tags = config.tags;
tags.dedup();
let mut facilities = config.facilities;
facilities.dedup();
let mut metros = config.metros;
metros.dedup();

Ok(DesiredHardwareConfig {
plans: desired_hardware,
tags,
facilities,
metros,
})
}
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Cli {
prometheus_root: String,

/// A JSON description of machines and their Nix system types and job sizes, and the tags and
/// facilities with which to create the machines.
/// metros with which to create the machines.
#[clap(long, required = true)]
config_file: PathBuf,
}
Expand Down Expand Up @@ -111,7 +111,7 @@ async fn real_main(
&equinix_project_id,
desired.clone(),
&desired_hardware.tags,
&desired_hardware.facilities,
&desired_hardware.metros,
)
.await?;
}
Expand Down

0 comments on commit 673a926

Please sign in to comment.