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