--- Begin Message ---
Signed-off-by: lou lecrivain <lou.lecriv...@wdz.de>
---
src/PVE/Network/SDN/Ipams/NautobotPlugin.pm | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/PVE/Network/SDN/Ipams/NautobotPlugin.pm
b/src/PVE/Network/SDN/Ipams/NautobotPlugin.pm
index 083ab20..53190bc 100644
--- a/src/PVE/Network/SDN/Ipams/NautobotPlugin.pm
+++ b/src/PVE/Network/SDN/Ipams/NautobotPlugin.pm
@@ -28,7 +28,12 @@ sub options {
};
}
+sub default_ip_status {
+ return 'Active';
+}
+
# implem
+
sub verify_api {
my ($class, $plugin_config) = @_;
@@ -37,13 +42,14 @@ sub verify_api {
my $namespace = $plugin_config->{namespace};
my $headers = [ 'Authorization' => "token $token", 'Accept' =>
"application/json; indent=4" ];
- # check that the namespace exists AND that we have
- # indeed API access
+ # check that the namespace exists AND that default IP active status
+ # exists AND that we have indeed API access
eval {
PVE::Network::SDN::Ipams::NautobotPlugin::get_namespace_id($url,
$namespace, $headers) // die "namespace $namespace does not exist";
+ PVE::Network::SDN::Ipams::NautobotPlugin::get_status_id($url,
default_ip_status(), $headers) // die "default IP status ". default_ip_status()
. " not found";
};
if ($@) {
- die "Can't connect to nautobot api: $@";
+ die "Can't use nautobot api: $@";
}
}
@@ -63,4 +69,13 @@ sub get_namespace_id {
return $internalid;
}
+sub get_status_id {
+ my ($url, $status, $headers) = @_;
+
+ my $result = PVE::Network::SDN::api_request("GET",
"$url/extra/statuses/?q=$status", $headers);
+ my $data = @{$result->{results}}[0];
+ my $internalid = $data->{id};
+ return $internalid;
+}
+
1;
--
2.39.5
--- End Message ---
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel