src/bin/proxmox-backup-manager.rs: implement netwerk revert

This commit is contained in:
Dietmar Maurer 2020-04-24 10:45:49 +02:00
parent c67bc9c35c
commit fd7c0979b4
2 changed files with 15 additions and 0 deletions

View File

@ -334,6 +334,19 @@ pub fn reload_network_config() -> Result<(), Error> {
Ok(()) Ok(())
} }
#[api(
access: {
permission: &Permission::Privilege(&[], PRIV_SYS_MODIFY, false),
},
)]
/// Revert network configuration (rm /etc/network/interfaces.new).
pub fn revert_network_config() -> Result<(), Error> {
let _ = std::fs::remove_file(network::NETWORK_INTERFACES_NEW_FILENAME);
Ok(())
}
const ITEM_ROUTER: Router = Router::new() const ITEM_ROUTER: Router = Router::new()
.get(&API_METHOD_READ_INTERFACE) .get(&API_METHOD_READ_INTERFACE)
.put(&API_METHOD_UPDATE_INTERFACE) .put(&API_METHOD_UPDATE_INTERFACE)
@ -342,4 +355,5 @@ const ITEM_ROUTER: Router = Router::new()
pub const ROUTER: Router = Router::new() pub const ROUTER: Router = Router::new()
.get(&API_METHOD_LIST_NETWORK_DEVICES) .get(&API_METHOD_LIST_NETWORK_DEVICES)
.put(&API_METHOD_RELOAD_NETWORK_CONFIG) .put(&API_METHOD_RELOAD_NETWORK_CONFIG)
.delete(&API_METHOD_REVERT_NETWORK_CONFIG)
.match_all("name", &ITEM_ROUTER); .match_all("name", &ITEM_ROUTER);

View File

@ -340,6 +340,7 @@ fn network_commands() -> CommandLineInterface {
.arg_param(&["name"]) .arg_param(&["name"])
.completion_cb("name", config::network::complete_interface_name) .completion_cb("name", config::network::complete_interface_name)
) )
.insert("revert", CliCommand::new(&api2::config::network::API_METHOD_REVERT_NETWORK_CONFIG))
.insert( .insert(
"reload", "reload",
CliCommand::new(&api2::config::network::API_METHOD_RELOAD_NETWORK_CONFIG) CliCommand::new(&api2::config::network::API_METHOD_RELOAD_NETWORK_CONFIG)