]> git.proxmox.com Git - pve-network.git/blame - PVE/Network/SDN/Controllers/Plugin.pm
bump version to 0.6.2
[pve-network.git] / PVE / Network / SDN / Controllers / Plugin.pm
CommitLineData
f5eabba0 1package PVE::Network::SDN::Controllers::Plugin;
6939693f
AD
2
3use strict;
4use warnings;
5
6use PVE::Tools;
7use PVE::JSONSchema;
8use PVE::Cluster;
9
10use Data::Dumper;
eec580bf 11use PVE::JSONSchema qw(get_standard_option);
6939693f
AD
12use base qw(PVE::SectionConfig);
13
f5eabba0 14PVE::Cluster::cfs_register_file('sdn/controllers.cfg',
6939693f
AD
15 sub { __PACKAGE__->parse_config(@_); },
16 sub { __PACKAGE__->write_config(@_); });
17
f5eabba0
AD
18PVE::JSONSchema::register_standard_option('pve-sdn-controller-id', {
19 description => "The SDN controller object identifier.",
20 type => 'string', format => 'pve-sdn-controller-id',
fe61b14c
AD
21});
22
f5eabba0
AD
23PVE::JSONSchema::register_format('pve-sdn-controller-id', \&parse_sdn_controller_id);
24sub parse_sdn_controller_id {
25 my ($id, $noerr) = @_;
fe61b14c 26
7c5b0f6d 27 if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
fe61b14c 28 return undef if $noerr;
7c5b0f6d 29 die "controller ID '$id' contains illegal characters\n";
fe61b14c 30 }
c08eeb0f 31 die "controller ID '$id' can't be more length than 64 characters\n" if length($id) > 64;
f5eabba0 32 return $id;
fe61b14c
AD
33}
34
6939693f
AD
35my $defaultData = {
36
37 propertyList => {
7d35eaf5 38 type => {
6939693f
AD
39 description => "Plugin type.",
40 type => 'string', format => 'pve-configid',
41 type => 'string',
42 },
f5eabba0
AD
43 controller => get_standard_option('pve-sdn-controller-id',
44 { completion => \&PVE::Network::SDN::complete_sdn_controller }),
6939693f
AD
45 },
46};
47
48sub private {
49 return $defaultData;
50}
51
52sub parse_section_header {
53 my ($class, $line) = @_;
54
55 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
f5eabba0 56 my ($type, $id) = (lc($1), $2);
6939693f
AD
57 my $errmsg = undef; # set if you want to skip whole section
58 eval { PVE::JSONSchema::pve_verify_configid($type); };
59 $errmsg = $@ if $@;
60 my $config = {}; # to return additional attributes
f5eabba0 61 return ($type, $id, $errmsg, $config);
6939693f
AD
62 }
63 return undef;
64}
65
6bffe819 66sub generate_sdn_config {
6939693f
AD
67 my ($class, $plugin_config, $node, $data, $ctime) = @_;
68
69 die "please implement inside plugin";
70}
71
8fb1ee7f 72sub generate_controller_config {
f23633dc
AD
73 my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_;
74
75 die "please implement inside plugin";
76}
77
78
79sub generate_controller_zone_config {
80 my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
32602a38
AD
81
82 die "please implement inside plugin";
83}
84
ad03c543 85sub generate_controller_vnet_config {
56cdcac9 86 my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
ad03c543
AD
87
88}
89
9cef13e9
AD
90sub generate_controller_rawconfig {
91 my ($class, $plugin_config, $config) = @_;
92
93 die "please implement inside plugin";
94}
95
8fb1ee7f
AD
96sub write_controller_config {
97 my ($class, $plugin_config, $config) = @_;
98
99 die "please implement inside plugin";
100}
101
fa609bdd
AD
102sub controller_reload {
103 my ($class) = @_;
104
105 die "please implement inside plugin";
106}
107
fe0c6b9e 108sub on_delete_hook {
56cdcac9 109 my ($class, $controllerid, $zone_cfg) = @_;
e8d5906e
AD
110
111 # do nothing by default
112}
113
114sub on_update_hook {
56cdcac9 115 my ($class, $controllerid, $controller_cfg) = @_;
fe0c6b9e
AD
116
117 # do nothing by default
118}
119
6939693f 1201;