]> git.proxmox.com Git - pve-network.git/blobdiff - PVE/Network/SDN/Ipams/NetboxPlugin.pm
ipams: add mac address
[pve-network.git] / PVE / Network / SDN / Ipams / NetboxPlugin.pm
index d696b0865d55a28116ff5cb093b97e2243d98d34..3c9921865b5177c2331b452c7a303652f1709d2e 100644 (file)
@@ -77,15 +77,16 @@ 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 $mask = $subnet->{mask};
     my $url = $plugin_config->{url};
     my $token = $plugin_config->{token};
     my $section = $plugin_config->{section};
     my $headers = ['Content-Type' => 'application/json; charset=UTF-8', 'Authorization' => "token $token"];
+    $description .= " mac:$mac" if $mac && $description;
 
-    my $params = { address => "$ip/$mask" };
+    my $params = { address => "$ip/$mask", dns_name => $hostname, description => $description };
 
     eval {
        PVE::Network::SDN::Ipams::Plugin::api_request("POST", "$url/ipam/ip-addresses/", $headers, $params);
@@ -97,7 +98,7 @@ sub add_ip {
 }
 
 sub add_next_freeip {
-    my ($class, $plugin_config, $subnetid, $subnet) = @_;
+    my ($class, $plugin_config, $subnetid, $subnet, $hostname, $mac, $description) = @_;
 
     my $cidr = $subnet->{cidr};
 
@@ -106,8 +107,9 @@ sub add_next_freeip {
     my $headers = ['Content-Type' => 'application/json; charset=UTF-8', 'Authorization' => "token $token"];
 
     my $internalid = get_prefix_id($url, $cidr, $headers);
+    $description .= " mac:$mac" if $mac && $description;
 
-    my $params = {};
+    my $params = { dns_name => $hostname, description => $description };
 
     my $ip = undef;
     eval {