Prevent default rules from being deleted
This commit is contained in:
parent
06ddf57b5c
commit
2b145ebeff
@ -100,6 +100,13 @@ pub async fn update(
|
|||||||
|
|
||||||
/// Delete a network filter
|
/// Delete a network filter
|
||||||
pub async fn delete(client: LibVirtReq, path: web::Path<NetworkFilterID>) -> HttpResult {
|
pub async fn delete(client: LibVirtReq, path: web::Path<NetworkFilterID>) -> HttpResult {
|
||||||
|
// Prevent deletion of default rules
|
||||||
|
let network = client.get_single_network_filter(path.uid).await?;
|
||||||
|
if constants::BUILTIN_NETWORK_FILTER_RULES.contains(&network.name.as_str()) {
|
||||||
|
return Ok(HttpResponse::ExpectationFailed()
|
||||||
|
.json("Builtin network filter rules shall not be deleted!"));
|
||||||
|
}
|
||||||
|
|
||||||
client.delete_network_filter(path.uid).await?;
|
client.delete_network_filter(path.uid).await?;
|
||||||
|
|
||||||
Ok(HttpResponse::Ok().json("Network deleted"))
|
Ok(HttpResponse::Ok().json("Network deleted"))
|
||||||
|
Loading…
Reference in New Issue
Block a user