Skip to content

Commit

Permalink
openstack: Add Nutanix AHV support
Browse files Browse the repository at this point in the history
It provides only OpenStack metadata without EC metadata

Signed-off-by: Olli Janatuinen <[email protected]>
  • Loading branch information
olljanat committed Jan 10, 2025
1 parent 1a58f96 commit bdf9b71
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/providers/openstack/configdrive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,29 @@ impl OpenstackConfigDrive {
impl MetadataProvider for OpenstackConfigDrive {
fn attributes(&self) -> Result<HashMap<String, String>> {
let mut out = HashMap::with_capacity(6);
let metadata_ec2: MetadataEc2JSON = self.read_metadata_ec2()?;

let metadata_openstack: MetadataOpenstackJSON = self.read_metadata_openstack()?;
if let Some(hostname) = metadata_openstack.hostname {
out.insert("OPENSTACK_HOSTNAME".to_string(), hostname);
}
if let Some(instance_id) = metadata_ec2.instance_id {
out.insert("OPENSTACK_INSTANCE_ID".to_string(), instance_id);
}
if let Some(uuid) = metadata_openstack.uuid {
out.insert("OPENSTACK_INSTANCE_UUID".to_string(), uuid);
}
if let Some(instance_type) = metadata_ec2.instance_type {
out.insert("OPENSTACK_INSTANCE_TYPE".to_string(), instance_type);
}
if let Some(local_ipv4) = metadata_ec2.local_ipv4 {
out.insert("OPENSTACK_IPV4_LOCAL".to_string(), local_ipv4);
}
if let Some(public_ipv4) = metadata_ec2.public_ipv4 {
out.insert("OPENSTACK_IPV4_PUBLIC".to_string(), public_ipv4);

let ec2_result = self.read_metadata_ec2();
if let Ok(metadata_ec2) = ec2_result {
if let Some(instance_id) = metadata_ec2.instance_id {
out.insert("OPENSTACK_INSTANCE_ID".to_string(), instance_id);
}
if let Some(instance_type) = metadata_ec2.instance_type {
out.insert("OPENSTACK_INSTANCE_TYPE".to_string(), instance_type);
}
if let Some(local_ipv4) = metadata_ec2.local_ipv4 {
out.insert("OPENSTACK_IPV4_LOCAL".to_string(), local_ipv4);
}
if let Some(public_ipv4) = metadata_ec2.public_ipv4 {
out.insert("OPENSTACK_IPV4_PUBLIC".to_string(), public_ipv4);
}
}
Ok(out)
}
Expand Down

0 comments on commit bdf9b71

Please sign in to comment.