]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/Ipams/PhpIpamPlugin.pm
ipams: add mac address
[pve-network.git] / PVE / Network / SDN / Ipams / PhpIpamPlugin.pm
index f89ef297b337d5f9e4ff3e0d01edc57ed00faf58..ab06f7b5d80970fcb351290140a5e26530c14e49 100644 (file)
@@ -95,7 +95,7 @@ sub del_subnet {
 }
 
 sub add_ip {
-    my ($class, $plugin_config, $subnetid, $subnet, $ip, $is_gateway) = @_;
+    my ($class, $plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $description, $is_gateway) = @_;
 
     my $cidr = $subnet->{cidr};
     my $url = $plugin_config->{url};
@@ -108,7 +108,10 @@ sub add_ip {
     my $params = { ip => $ip,
                   subnetId => $internalid,
                   is_gateway => $is_gateway,
+                  hostname => $hostname,
+                  description => $description,
                  };
+    $params->{mac} = $mac if $mac;
 
     eval {
        PVE::Network::SDN::Ipams::Plugin::api_request("POST", "$url/addresses/", $headers, $params);
@@ -120,7 +123,7 @@ sub add_ip {
 }
 
 sub add_next_freeip {
-    my ($class, $plugin_config, $subnetid, $subnet, $internalid, $hostname) = @_;
+    my ($class, $plugin_config, $subnetid, $subnet, $hostname, $mac, $description) = @_;
 
     my $cidr = $subnet->{cidr};  
     my $mask = $subnet->{mask};  
@@ -129,9 +132,13 @@ sub add_next_freeip {
     my $section = $plugin_config->{section};
     my $headers = ['Content-Type' => 'application/json; charset=UTF-8', 'Token' => $token];
 
-    $internalid = get_internalid($url, $cidr, $headers) if !$internalid;
+    my $internalid = get_internalid($url, $cidr, $headers);
+
+    my $params = { hostname => $hostname,
+                  description => $description,
+                 };
 
-    my $params = {};
+    $params->{mac} = $mac if $mac;
 
     my $ip = undef;
     eval {