Can create NAT networks
This commit is contained in:
@ -107,17 +107,24 @@ impl Handler<DefineDomainReq> for LibVirtActor {
|
||||
type Result = anyhow::Result<XMLUuid>;
|
||||
|
||||
fn handle(&mut self, mut msg: DefineDomainReq, _ctx: &mut Self::Context) -> Self::Result {
|
||||
// A issue with the disks definition serialization needs them to be serialized aside
|
||||
let mut disks_xml = Vec::with_capacity(msg.0.devices.disks.len());
|
||||
// A issue with the disks & network interface definition serialization needs them to be serialized aside
|
||||
let mut devices_xml = Vec::with_capacity(msg.0.devices.disks.len());
|
||||
for disk in msg.0.devices.disks {
|
||||
let disk_xml = serde_xml_rs::to_string(&disk)?;
|
||||
let start_offset = disk_xml.find("<disk").unwrap();
|
||||
disks_xml.push(disk_xml[start_offset..].to_string());
|
||||
devices_xml.push(disk_xml[start_offset..].to_string());
|
||||
}
|
||||
for network in msg.0.devices.net_interfaces {
|
||||
let network_xml = serde_xml_rs::to_string(&network)?;
|
||||
let start_offset = network_xml.find("<interface").unwrap();
|
||||
devices_xml.push(network_xml[start_offset..].to_string());
|
||||
}
|
||||
|
||||
msg.0.devices.disks = vec![];
|
||||
msg.0.devices.net_interfaces = vec![];
|
||||
|
||||
let mut xml = serde_xml_rs::to_string(&msg.0)?;
|
||||
let disks_xml = disks_xml.join("\n");
|
||||
let disks_xml = devices_xml.join("\n");
|
||||
xml = xml.replacen("<devices>", &format!("<devices>{disks_xml}"), 1);
|
||||
|
||||
log::debug!("Define domain:\n{}", xml);
|
||||
|
Reference in New Issue
Block a user