]>
git.proxmox.com Git - pve-network.git/blob - PVE/Network/Network/VnetPlugin.pm
1 package PVE
::Network
::Network
::VnetPlugin
;
5 use PVE
::Network
::Network
::Plugin
;
7 use base
('PVE::Network::Network::Plugin');
25 description
=> "transportzone id",
29 description
=> "vlan or vxlan id",
33 description
=> "alias name of the vnet",
42 description
=> "Anycast router ipv4 address.",
43 type
=> 'string', format
=> 'ipv4',
47 description
=> "Anycast router ipv6 address.",
48 type
=> 'string', format
=> 'ipv6',
53 description
=> "Anycast router mac address",
61 transportzone
=> { optional
=> 0},
62 tag
=> { optional
=> 0},
63 alias
=> { optional
=> 1 },
64 ipv4
=> { optional
=> 1 },
65 ipv6
=> { optional
=> 1 },
66 mtu
=> { optional
=> 1 },
71 my ($class, $networkid, $scfg) = @_;
73 # verify than no vm or ct have interfaces in this bridge
74 my $vmdata = read_local_vm_config
();
76 foreach my $vmid (sort keys %{$vmdata->{qemu
}}) {
77 my $conf = $vmdata->{qemu
}->{$vmid};
78 foreach my $netid (sort keys %$conf) {
79 next if $netid !~ m/^net(\d+)$/;
80 my $net = PVE
::QemuServer
::parse_net
($conf->{$netid});
81 die "vnet $networkid is used by vm $vmid" if $net->{bridge
} eq $networkid;
85 foreach my $vmid (sort keys %{$vmdata->{lxc
}}) {
86 my $conf = $vmdata->{lxc
}->{$vmid};
87 foreach my $netid (sort keys %$conf) {
88 next if $netid !~ m/^net(\d+)$/;
89 my $net = PVE
::LXC
::Config-
>parse_lxc_network($conf->{$netid});
90 die "vnet $networkid is used by ct $vmid" if $net->{bridge
} eq $networkid;
97 my ($class, $networkid, $scfg) = @_;
99 # verify that tag is not already defined in another vnet
103 sub read_local_vm_config
{
108 my $vmdata = { qemu
=> $qemu, lxc
=> $lxc };
110 my $vmlist = PVE
::Cluster
::get_vmlist
();
111 return $vmdata if !$vmlist || !$vmlist->{ids
};
112 my $ids = $vmlist->{ids
};
114 foreach my $vmid (keys %$ids) {
116 my $d = $ids->{$vmid};
119 if ($d->{type
} eq 'qemu') {
120 my $cfspath = PVE
::QemuConfig-
>cfs_config_path($vmid);
121 if (my $conf = PVE
::Cluster
::cfs_read_file
($cfspath)) {
122 $qemu->{$vmid} = $conf;
124 } elsif ($d->{type
} eq 'lxc') {
125 my $cfspath = PVE
::LXC
::Config-
>cfs_config_path($vmid);
126 if (my $conf = PVE
::Cluster
::cfs_read_file
($cfspath)) {
127 $lxc->{$vmid} = $conf;