]> git.proxmox.com Git - pve-network.git/blob - PVE/Network/SDN/VnetPlugin.pm
rename $network to $sdn everywhere
[pve-network.git] / PVE / Network / SDN / VnetPlugin.pm
1 package PVE::Network::SDN::VnetPlugin;
2
3 use strict;
4 use warnings;
5 use PVE::Network::SDN::Plugin;
6
7 use base('PVE::Network::SDN::Plugin');
8
9 use PVE::Cluster;
10
11 sub type {
12 return 'vnet';
13 }
14
15 sub properties {
16 return {
17 transportzone => {
18 type => 'string',
19 description => "transportzone id",
20 },
21 tag => {
22 type => 'integer',
23 description => "vlan or vxlan id",
24 },
25 alias => {
26 type => 'string',
27 description => "alias name of the vnet",
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 }
50 };
51 }
52
53 sub options {
54 return {
55 transportzone => { optional => 0},
56 tag => { optional => 0},
57 alias => { optional => 1 },
58 ipv4 => { optional => 1 },
59 ipv6 => { optional => 1 },
60 mtu => { optional => 1 },
61 };
62 }
63
64 sub on_delete_hook {
65 my ($class, $sdnid, $sdn_cfg) = @_;
66
67 return;
68 }
69
70 sub on_update_hook {
71 my ($class, $sdnid, $sdn_cfg) = @_;
72 # verify that tag is not already defined in another vnet
73 if (defined($sdn_cfg->{ids}->{$sdnid}->{tag})) {
74 my $tag = $sdn_cfg->{ids}->{$sdnid}->{tag};
75 foreach my $id (keys %{$sdn_cfg->{ids}}) {
76 next if $id eq $sdnid;
77 my $sdn = $sdn_cfg->{ids}->{$id};
78 if ($sdn->{type} eq 'vnet' && defined($sdn->{tag})) {
79 die "tag $tag already exist in vnet $id" if $tag eq $sdn->{tag};
80 }
81 }
82 }
83 }
84
85 1;