sdn: api: extract function that creates the sdn directory.

create_etc_interfaces_sdn_dir creates the /etc/pve/sdn directory.
This allows mocking in tests to prevent system fs access in tests

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
Stefan Lendl 2024-04-05 15:18:02 +02:00 committed by Thomas Lamprecht
parent 40f020660d
commit 11d2ac73ff

View file

@ -186,6 +186,10 @@ __PACKAGE__->register_method ({
return &$api_sdn_zones_config($cfg, $param->{zone});
}});
sub create_etc_interfaces_sdn_dir {
mkdir("/etc/pve/sdn");
}
__PACKAGE__->register_method ({
name => 'create',
protected => 1,
@ -207,7 +211,7 @@ __PACKAGE__->register_method ({
my $opts = $plugin->check_config($id, $param, 1, 1);
PVE::Cluster::check_cfs_quorum();
mkdir("/etc/pve/sdn");
create_etc_interfaces_sdn_dir();
PVE::Network::SDN::lock_sdn_config(sub {
my $zone_cfg = PVE::Network::SDN::Zones::config();