Skip to content

Commit

Permalink
proxmox: use noop provider if no configdrive
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
  • Loading branch information
tormath1 committed Nov 6, 2024
1 parent e6824a2 commit fce6d96
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use crate::providers::openstack;
use crate::providers::openstack::network::OpenstackProviderNetwork;
use crate::providers::packet::PacketProvider;
use crate::providers::powervs::PowerVSProvider;
use crate::providers::proxmoxve::ProxmoxVEConfigDrive;
use crate::providers::proxmoxve;
use crate::providers::scaleway::ScalewayProvider;
use crate::providers::vmware::VmwareProvider;
use crate::providers::vultr::VultrProvider;
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn fetch_metadata(provider: &str) -> Result<Box<dyn providers::MetadataProvi
"openstack-metadata" => box_result!(OpenstackProviderNetwork::try_new()?),
"packet" => box_result!(PacketProvider::try_new()?),
"powervs" => box_result!(PowerVSProvider::try_new()?),
"proxmoxve" => box_result!(ProxmoxVEConfigDrive::try_new()?),
"proxmoxve" => proxmoxve::try_config_drive_else_leave(),
"scaleway" => box_result!(ScalewayProvider::try_new()?),
"vmware" => box_result!(VmwareProvider::try_new()?),
"vultr" => box_result!(VultrProvider::try_new()?),
Expand Down
1 change: 1 addition & 0 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub mod ibmcloud;
pub mod ibmcloud_classic;
pub mod kubevirt;
pub mod microsoft;
pub mod noop;
pub mod openstack;
pub mod packet;
pub mod powervs;
Expand Down
14 changes: 14 additions & 0 deletions src/providers/proxmoxve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use anyhow::Result;
use crate::providers;
use crate::providers::noop::NoopProvider;
use slog_scope::warn;

mod configdrive;
pub use configdrive::*;

Expand All @@ -20,3 +25,12 @@ pub use cloudconfig::*;

#[cfg(test)]
mod tests;

pub fn try_config_drive_else_leave() -> Result<Box<dyn providers::MetadataProvider>> {
if let Ok(config_drive) = ProxmoxVEConfigDrive::try_new() {
Ok(Box::new(config_drive))
} else {
warn!("failed to locate config-drive - aborting ProxmoxVE provider");
Ok(Box::new(NoopProvider::try_new()?))
}
}

0 comments on commit fce6d96

Please sign in to comment.