]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/Zones/SimplePlugin.pm
zones: add bridge helpers
[pve-network.git] / PVE / Network / SDN / Zones / SimplePlugin.pm
index c0ab1fe0d2d050e855b8379981c6b68fcc1202a5..9f74f3e735ac45c0c692b2dc8cb8de52cb71f25b 100644 (file)
@@ -13,16 +13,37 @@ sub type {
     return 'simple';
 }
 
+sub properties {
+    return {
+       dns => {
+           type => 'string',
+           description => "dns api server",
+       },
+       reversedns => {
+           type => 'string',
+           description => "reverse dns api server",
+       },
+       dnszone => {
+           type => 'string', format => 'dns-name',
+           description => "dns domain zone  ex: mydomain.com",
+       }
+    };
+}
+
 sub options {
     return {
        nodes => { optional => 1},
-       mtu => { optional => 1 }
+       mtu => { optional => 1 },
+       dns => { optional => 1 },
+       reversedns => { optional => 1 },
+       dnszone => { optional => 1 },
+       ipam => { optional => 0 },
     };
 }
 
 # Plugin implementation
 sub generate_sdn_config {
-    my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $subnet_cfg, $interfaces_config, $config) = @_;
+    my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $controller_cfg, $subnet_cfg, $interfaces_config, $config) = @_;
 
     return $config if$config->{$vnetid}; # nothing to do
 
@@ -37,16 +58,18 @@ sub generate_sdn_config {
 
     my $address = {};
     my $subnets = PVE::Network::SDN::Vnets::get_subnets($vnetid, 1);
+
     foreach my $subnetid (sort keys %{$subnets}) {
        my $subnet = $subnets->{$subnetid};
-       my $cidr = $subnetid =~ s/-/\//r; 
+       my $cidr = $subnet->{cidr};
+       my $mask = $subnet->{mask};
+
        my $gateway = $subnet->{gateway};
        if ($gateway) {
-           push @iface_config, "address $gateway" if !defined($address->{$gateway});
+           push @iface_config, "address $gateway/$mask" if !defined($address->{$gateway});
            $address->{$gateway} = 1;
        }
        #add route for /32 pointtopoint
-       my ($ip, $mask) = split(/\//, $cidr);
        push @iface_config, "up ip route add $cidr dev $vnetid" if $mask == 32;
        if ($subnet->{snat}) {
            #find outgoing interface
@@ -96,9 +119,12 @@ sub status {
 
 
 sub vnet_update_hook {
-    my ($class, $vnet) = @_;
+    my ($class, $vnet_cfg, $vnetid, $zone_cfg) = @_;
+
+    my $vnet = $vnet_cfg->{ids}->{$vnetid};
+    my $tag = $vnet->{tag};
 
-    raise_param_exc({ tag => "vlan tag is not allowed on simple bridge"}) if defined($vnet->{tag});
+    raise_param_exc({ tag => "vlan tag is not allowed on simple zone"}) if defined($tag);
 
     if (!defined($vnet->{mac})) {
         my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');