]>
git.proxmox.com Git - pve-network.git/blob - PVE/Network/Network.pm
1 package PVE
::Network
::Network
;
6 use PVE
::Cluster
qw(cfs_read_file cfs_write_file cfs_lock_file);
7 use PVE
::Network
::Network
::Plugin
;
8 use PVE
::Network
::Network
::VnetPlugin
;
9 use PVE
::Network
::Network
::VlanPlugin
;
10 use PVE
::Network
::Network
::VxlanMulticastPlugin
;
12 PVE
::Network
::Network
::VnetPlugin-
>register();
13 PVE
::Network
::Network
::VlanPlugin-
>register();
14 PVE
::Network
::Network
::VxlanMulticastPlugin-
>register();
15 PVE
::Network
::Network
::Plugin-
>init();
19 my ($cfg, $networkid, $noerr) = @_;
21 die "no network ID specified\n" if !$networkid;
23 my $scfg = $cfg->{ids
}->{$networkid};
24 die "network '$networkid' does not exists\n" if (!$noerr && !$scfg);
30 my $config = cfs_read_file
("networks.cfg.new");
31 $config = cfs_read_file
("networks.cfg") if !keys %{$config->{ids
}};
38 cfs_write_file
("networks.cfg.new", $cfg);
41 sub lock_network_config
{
42 my ($code, $errmsg) = @_;
44 cfs_lock_file
("networks.cfg.new", undef, $code);
47 $errmsg ?
die "$errmsg: $err" : die $err;
54 return keys %{$cfg->{ids
}};
57 sub complete_network
{
58 my ($cmdname, $pname, $cvalue) = @_;
60 my $cfg = PVE
::Network
::Network
::config
();
62 return $cmdname eq 'add' ?
[] : [ PVE
::Network
::Network
::networks_ids
($cfg) ];