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(@_); });
18 PVE
::JSONSchema
::register_standard_option
('pve-sdn-controller-id', {
19 description
=> "The SDN controller object identifier.",
20 type
=> 'string', format
=> 'pve-sdn-controller-id',
23 PVE
::JSONSchema
::register_format
('pve-sdn-controller-id', \
&parse_sdn_controller_id
);
24 sub parse_sdn_controller_id
{
25 my ($id, $noerr) = @_;
27 if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
28 return undef if $noerr;
29 die "controller ID '$id' contains illegal characters\n";
31 die "controller ID '$id' can't be more length than 64 characters\n" if length($id) > 64;
39 description
=> "Plugin type.",
40 type
=> 'string', format
=> 'pve-configid',
43 controller
=> get_standard_option
('pve-sdn-controller-id',
44 { completion
=> \
&PVE
::Network
::SDN
::complete_sdn_controller
}),
52 sub parse_section_header
{
53 my ($class, $line) = @_;
55 if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
56 my ($type, $id) = (lc($1), $2);
57 my $errmsg = undef; # set if you want to skip whole section
58 eval { PVE
::JSONSchema
::pve_verify_configid
($type); };
60 my $config = {}; # to return additional attributes
61 return ($type, $id, $errmsg, $config);
66 sub generate_sdn_config
{
67 my ($class, $plugin_config, $node, $data, $ctime) = @_;
69 die "please implement inside plugin";
72 sub generate_controller_config
{
73 my ($class, $plugin_config, $controller_cfg, $id, $uplinks, $config) = @_;
75 die "please implement inside plugin";
79 sub generate_controller_zone_config
{
80 my ($class, $plugin_config, $controller, $controller_cfg, $id, $uplinks, $config) = @_;
82 die "please implement inside plugin";
85 sub generate_controller_vnet_config
{
86 my ($class, $plugin_config, $controller, $zoneid, $vnetid, $config) = @_;
90 sub generate_controller_rawconfig
{
91 my ($class, $plugin_config, $config) = @_;
93 die "please implement inside plugin";
96 sub write_controller_config
{
97 my ($class, $plugin_config, $config) = @_;
99 die "please implement inside plugin";
102 sub controller_reload
{
105 die "please implement inside plugin";
109 my ($class, $controllerid, $zone_cfg) = @_;
111 # do nothing by default
115 my ($class, $controllerid, $controller_cfg) = @_;
117 # do nothing by default