]> git.proxmox.com Git - pve-network.git/blame - PVE/Network/Network/VnetPlugin.pm
remove vnet bridge delete hook
[pve-network.git] / PVE / Network / Network / VnetPlugin.pm
CommitLineData
6bad73d0 1package PVE::Network::Network::VnetPlugin;
e7939454
AD
2
3use strict;
4use warnings;
6bad73d0 5use PVE::Network::Network::Plugin;
e7939454 6
6bad73d0 7use base('PVE::Network::Network::Plugin');
e7939454 8
aa38ba46 9use PVE::Cluster;
46cd4e06 10
6bad73d0
AD
11sub type {
12 return 'vnet';
13}
e7939454 14
6bad73d0 15sub properties {
e7939454 16 return {
e7939454
AD
17 transportzone => {
18 type => 'string',
19 description => "transportzone id",
e7939454
AD
20 },
21 tag => {
22 type => 'integer',
23 description => "vlan or vxlan id",
e7939454 24 },
dc7e431e 25 alias => {
e7939454 26 type => 'string',
dc7e431e 27 description => "alias name of the vnet",
e7939454
AD
28 optional => 1,
29 },
30 mtu => {
31 type => 'integer',
32 description => "mtu",
33 optional => 1,
34 },
35 ipv4 => {
36 description => "Anycast router ipv4 address.",
37 type => 'string', format => 'ipv4',
38 optional => 1,
39 },
40 ipv6 => {
41 description => "Anycast router ipv6 address.",
42 type => 'string', format => 'ipv6',
43 optional => 1,
44 },
45 mac => {
46 type => 'boolean',
47 description => "Anycast router mac address",
48 optional => 1,
49 }
6bad73d0 50 };
e7939454
AD
51}
52
6bad73d0
AD
53sub options {
54 return {
205e9166
AD
55 transportzone => { optional => 0},
56 tag => { optional => 0},
dc7e431e 57 alias => { optional => 1 },
6bad73d0
AD
58 ipv4 => { optional => 1 },
59 ipv6 => { optional => 1 },
6bad73d0
AD
60 mtu => { optional => 1 },
61 };
e7939454
AD
62}
63
fe0c6b9e 64sub on_delete_hook {
a8ad2789 65 my ($class, $networkid, $network_cfg) = @_;
fe0c6b9e 66
cf5816ef 67 return;
fe0c6b9e
AD
68}
69
e8d5906e 70sub on_update_hook {
6a2db30a 71 my ($class, $networkid, $network_cfg) = @_;
e8d5906e 72 # verify that tag is not already defined in another vnet
6a2db30a
AD
73 if (defined($network_cfg->{ids}->{$networkid}->{tag})) {
74 my $tag = $network_cfg->{ids}->{$networkid}->{tag};
75 foreach my $id (keys %{$network_cfg->{ids}}) {
76 next if $id eq $networkid;
77 my $network = $network_cfg->{ids}->{$id};
78 if ($network->{type} eq 'vnet' && defined($network->{tag})) {
79 die "tag $tag already exist in vnet $id" if $tag eq $network->{tag};
80 }
81 }
82 }
e8d5906e 83}
e7939454
AD
84
851;