mock: clean up todos

This commit is contained in:
snow flurry 2024-08-19 12:08:39 -07:00
parent ba86368591
commit ece1f9a089

View file

@ -10,7 +10,7 @@ use futures::{future, StreamExt};
use tokio::{sync::RwLock, task::JoinHandle}; use tokio::{sync::RwLock, task::JoinHandle};
use crate::{ use crate::{
error::ApiError, error::{ApiError, ErrorType},
model, model,
net::{cidr::CidrV4, mac::MacAddr}, net::{cidr::CidrV4, mac::MacAddr},
InstanceQuery, Nazrin, NazrinClient, InstanceQuery, Nazrin, NazrinClient,
@ -241,27 +241,32 @@ impl Nazrin for MockServer {
interface: String, interface: String,
) -> Result<(), ApiError> { ) -> Result<(), ApiError> {
let mut db = self.db.write().await; let mut db = self.db.write().await;
db.instances {
.iter()
.filter_map(|inst| inst.as_ref())
.for_each(|inst| {
if inst.lease.subnet == interface {
todo!("what now")
}
});
let Some(subnet) = db let Some(subnet) = db
.subnets .subnets
.iter_mut() .iter_mut()
.find(|net| net.as_ref().filter(|n| n.name == interface).is_some()) .find(|net| net.as_ref().filter(|n| n.name == interface).is_some())
else { else {
return Err("Subnet doesn't exist".into()); return Err(ErrorType::NotFound.into());
}; };
subnet.take(); subnet.take();
}
// Drop all instances that belong to this subnet
db.instances.iter_mut().for_each(|inst| {
if inst
.as_mut()
.filter(|inst| inst.lease.subnet != interface)
.is_some()
{
inst.take();
}
});
Ok(()) Ok(())
} }
async fn garbage_collect(self, _: tarpc::context::Context) -> Result<(), ApiError> { async fn garbage_collect(self, _: tarpc::context::Context) -> Result<(), ApiError> {
todo!() // no libvirt to compare against, no instances to GC
Ok(())
} }
async fn get_ssh_pubkeys( async fn get_ssh_pubkeys(