Commit c2fa0d37 authored by Cyril Plisko's avatar Cyril Plisko

Implement Affinity

parent 973e821b
Pipeline #81321610 failed with stage
in 6 minutes and 50 seconds
use serde::Serialize;
use crate::skip_serializing_if::SkipSerializingIf;
#[derive(Clone, Debug, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
pub(crate) enum Affinity {
Default,
Host,
}
impl Default for Affinity {
fn default() -> Self {
Self::Default
}
}
impl SkipSerializingIf for Affinity {
fn is_default(&self) -> bool {
*self == Self::default()
}
}
......@@ -2,6 +2,7 @@ use serde::Serialize;
use crate::skip_serializing_if::SkipSerializingIf;
use super::Affinity;
use super::BlockDeviceMapping;
use super::CpuOptions;
use super::CreditSpecification;
......@@ -52,7 +53,8 @@ use super::InstanceType;
#[serde(rename_all = "PascalCase")]
pub struct Instance {
additional_info: String,
affinity: String,
#[serde(skip_serializing_if = "Affinity::is_default")]
affinity: Affinity,
availability_zone: String,
block_device_mappings: Vec<BlockDeviceMapping>,
#[serde(skip_serializing_if = "CpuOptions::is_default")]
......@@ -99,6 +101,11 @@ impl Instance {
Self::default()
}
pub fn host_affinity(self) -> Self {
let affinity = Affinity::Host;
Self { affinity, ..self }
}
pub fn instance_type(self, r#type: impl AsRef<str>) -> Self {
let instance_type = InstanceType::from(r#type).expect("Invalid Instance Type");
Self {
......
......@@ -4,6 +4,9 @@ pub use credit_spec::CreditSpecification;
pub use instance::Instance;
pub use instance_type::InstanceType;
pub(crate) use affinity::Affinity;
mod affinity;
mod blockdevice;
mod cpu_options;
mod credit_spec;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment