nzrd: declare cloud-init metadata via smbios
This commit is contained in:
		
							parent
							
								
									b350e73b8a
								
							
						
					
					
						commit
						48bff395ca
					
				
					 2 changed files with 15 additions and 1 deletions
				
			
		|  | @ -49,6 +49,7 @@ pub struct DHCPConfig { | |||
| pub struct CloudConfig { | ||||
|     pub listen_addr: String, | ||||
|     pub port: u16, | ||||
|     pub http_addr: String, | ||||
|     pub admin_user: String, | ||||
| } | ||||
| 
 | ||||
|  | @ -113,6 +114,7 @@ impl Default for Config { | |||
|             cloud: CloudConfig { | ||||
|                 listen_addr: "0.0.0.0".to_owned(), | ||||
|                 port: 80, | ||||
|                 http_addr: "http://192.0.2.1/".to_owned(), | ||||
|                 admin_user: "admin".to_owned(), | ||||
|             }, | ||||
|         } | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| use nzr_api::net::cidr::CidrV4; | ||||
| use nzr_virt::error::DomainError; | ||||
| use nzr_virt::xml::build::DomainBuilder; | ||||
| use nzr_virt::xml::{self, SerialType}; | ||||
| use nzr_virt::xml::{self, InfoMap, SerialType, Sysinfo}; | ||||
| use nzr_virt::{datasize, dom, vol}; | ||||
| use tokio::sync::RwLock; | ||||
| 
 | ||||
|  | @ -121,6 +121,17 @@ pub async fn new_instance( | |||
|             let pri_name = &ctx.config.storage.primary_pool; | ||||
|             let sec_name = &ctx.config.storage.secondary_pool; | ||||
| 
 | ||||
|             let smbios_info = { | ||||
|                 let mut sysinfo = Sysinfo::new(); | ||||
|                 let mut system_map = InfoMap::new(); | ||||
|                 system_map.push( | ||||
|                     "serial", | ||||
|                     format!("ds=nocloud;s={}", ctx.config.cloud.http_addr), | ||||
|                 ); | ||||
|                 sysinfo.system(system_map); | ||||
|                 sysinfo | ||||
|             }; | ||||
| 
 | ||||
|             let mut instdata = DomainBuilder::default() | ||||
|                 .name(&args.name) | ||||
|                 .memory(datasize!((args.memory) MiB)) | ||||
|  | @ -136,6 +147,7 @@ pub async fn new_instance( | |||
|                         .qcow2() | ||||
|                         .boot_order(1) | ||||
|                 }) | ||||
|                 .smbios(smbios_info) | ||||
|                 .serial_device(SerialType::Pty); | ||||
| 
 | ||||
|             // add desription, if provided
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue