1 package PVE
::Network
::SDN
::Controllers
::Plugin
;
11 use PVE
::JSONSchema
qw(get_standard_option);
12 use base
qw(PVE::SectionConfig);
14 PVE
::Cluster
::cfs_register_file
('sdn/controllers.cfg',
15 sub { __PACKAGE__-
>parse_config(@_); },
16 sub { __PACKAGE__-
>write_config(@_); }
19 PVE
::JSONSchema
::register_standard_option
('pve-sdn-controller-id', {
20 description
=> "The SDN controller object identifier.",
21 type
=> 'string', format
=> 'pve-sdn-controller-id',
24 PVE
::JSONSchema
::register_format
('pve-sdn-controller-id', \
&parse_sdn_controller_id
);
25 sub parse_sdn_controller_id
{
26 my ($id, $noerr) = @_;
28 if ($id !~ m/^[a-z][a-z0-9_-]*[a-z0-9]$/i) {
29 return undef if $noerr;
30 die "controller ID '$id' contains illegal characters\n";
32 die "controller ID '$id' can't be more length than 64 characters\n" if length($id) > 64;
40 description
=> "Plugin type.",
41 type
=> 'string', format
=> 'pve-configid',
44 controller
=> get_standard_option
('pve-sdn-controller-id',
45 { completion
=> \
&PVE
::Network
::SDN
::complete_sdn_controller
}),
53 sub parse_section_header
{
54 my ($class, $line) = @_;
56 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
57 my ($type, $id) = (lc($1), $2);
58 my $errmsg = undef; # set if you want to skip whole section
59 eval { PVE
::JSONSchema
::pve_verify_configid
($type); };
61 my $config = {}; # to return additional attributes
62 return ($type, $id, $errmsg, $config);
67 sub generate_sdn_config
{
68 my ($class, $plugin_config, $node, $data, $ctime) = @_;
70 die "please implement inside plugin";
73 sub generate_controller_config
{
74 my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_;
76 die "please implement inside plugin";
80 sub generate_controller_zone_config
{
81 my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
83 die "please implement inside plugin";
86 sub generate_controller_vnet_config
{
87 my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
91 sub generate_controller_rawconfig
{
92 my ($class, $plugin_config, $config) = @_;
94 die "please implement inside plugin";
97 sub write_controller_config
{
98 my ($class, $plugin_config, $config) = @_;
100 die "please implement inside plugin";
103 sub controller_reload
{
106 die "please implement inside plugin";
110 my ($class, $controllerid, $zone_cfg) = @_;
112 # do nothing by default
116 my ($class, $controllerid, $controller_cfg) = @_;
118 # do nothing by default