mock: clean up todos
This commit is contained in:
parent
ba86368591
commit
ece1f9a089
|
@ -10,7 +10,7 @@ use futures::{future, StreamExt};
|
|||
use tokio::{sync::RwLock, task::JoinHandle};
|
||||
|
||||
use crate::{
|
||||
error::ApiError,
|
||||
error::{ApiError, ErrorType},
|
||||
model,
|
||||
net::{cidr::CidrV4, mac::MacAddr},
|
||||
InstanceQuery, Nazrin, NazrinClient,
|
||||
|
@ -241,27 +241,32 @@ impl Nazrin for MockServer {
|
|||
interface: String,
|
||||
) -> Result<(), ApiError> {
|
||||
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
|
||||
.subnets
|
||||
.iter_mut()
|
||||
.find(|net| net.as_ref().filter(|n| n.name == interface).is_some())
|
||||
else {
|
||||
return Err("Subnet doesn't exist".into());
|
||||
return Err(ErrorType::NotFound.into());
|
||||
};
|
||||
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(())
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
Loading…
Reference in a new issue