Add dsmode cloud-init metadata
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -2,6 +2,15 @@ use crate::app_config::AppConfig;
 | 
			
		||||
use crate::constants;
 | 
			
		||||
use std::process::Command;
 | 
			
		||||
 | 
			
		||||
/// Cloud init DS Mode
 | 
			
		||||
#[derive(Copy, Clone, Debug, serde::Serialize, serde::Deserialize)]
 | 
			
		||||
pub enum CloudInitDSMode {
 | 
			
		||||
    /// Networking is required
 | 
			
		||||
    Net,
 | 
			
		||||
    /// Does not require networking to be up before user-data actions are run
 | 
			
		||||
    Local,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// VM Cloud Init configuration
 | 
			
		||||
///
 | 
			
		||||
/// RedHat documentation: https://docs.redhat.com/fr/documentation/red_hat_enterprise_linux/9/html/configuring_and_managing_cloud-init_for_rhel_9/configuring-cloud-init_cloud-content
 | 
			
		||||
@@ -17,6 +26,9 @@ pub struct CloudInitConfig {
 | 
			
		||||
    /// Local hostname, set in metadata file
 | 
			
		||||
    #[serde(skip_serializing_if = "Option::is_none")]
 | 
			
		||||
    pub local_hostname: Option<String>,
 | 
			
		||||
    /// Data source mode
 | 
			
		||||
    #[serde(skip_serializing_if = "Option::is_none")]
 | 
			
		||||
    pub dsmode: Option<CloudInitDSMode>,
 | 
			
		||||
    /// Network configuration
 | 
			
		||||
    #[serde(skip_serializing_if = "Option::is_none")]
 | 
			
		||||
    pub network_configuration: Option<String>,
 | 
			
		||||
@@ -53,6 +65,15 @@ impl CloudInitConfig {
 | 
			
		||||
        if let Some(local_hostname) = &self.local_hostname {
 | 
			
		||||
            metadatas.push(format!("local-hostname: {}", local_hostname));
 | 
			
		||||
        }
 | 
			
		||||
        if let Some(dsmode) = &self.dsmode {
 | 
			
		||||
            metadatas.push(format!(
 | 
			
		||||
                "dsmode: {}",
 | 
			
		||||
                match dsmode {
 | 
			
		||||
                    CloudInitDSMode::Net => "net",
 | 
			
		||||
                    CloudInitDSMode::Local => "local",
 | 
			
		||||
                }
 | 
			
		||||
            ));
 | 
			
		||||
        }
 | 
			
		||||
        let meta_data_path = temp_path.path().join("meta-data");
 | 
			
		||||
        std::fs::write(&meta_data_path, metadatas.join("\n"))?;
 | 
			
		||||
        cmd.arg(meta_data_path);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user