On 3/6/25 12:08, lou.lecriv...@orange.fr wrote:

[...]

+sub verify_api {
+    my ($class, $plugin_config) = @_;
+
+    my $url = $plugin_config->{url};
+    my $namespace = $plugin_config->{namespace};
+    my $headers = default_headers($plugin_config);
+
+    # check that the namespace exists AND that default IP active status
+    # exists AND that we have indeed API access
+    eval {
+       get_namespace_id($url, $namespace, $headers, 0)
+           // die "namespace $namespace does not exist";
+       get_status_id($url, default_ip_status(), $headers, 0)
+           // die "default IP status ". default_ip_status() . " not found";
+    };
+    if ($@) {
+       die "Can't use nautobot api: $@";
+    }
+}
+

[...]

+sub get_status_id {
+    my ($url, $status, $headers, $noerr) = @_;
+
+    my $result = eval {
+       return PVE::Network::SDN::api_request(
+           "GET", "$url/extras/statuses/?q=$status", $headers);
+    };
Unfortunately, I don't quite understand what this check actually does, or why we need this check.
The documentation [0] says:
`Nautobot provides the ability for custom statuses to be defined
within an organisation to be used on various objects to facilitate
business workflows around object statuses.`

And as I understand the API call, it checks whether the
status object ‘Active’ exists and gets its ID. But I don't
understand why this should be checked with `verify_api`?
In my opinion, we don't really need this check, unless I'm missing something here.

[0] https://docs.nautobot.com/projects/core/en/stable/user-guide/platform-functionality/status/
+    if ($@) {
+       die "error while querying for status $status id: $@" if !$noerr;
+    }
+
+    my $data = @{$result->{results}}[0];
+    my $internalid = $data->{id};
+    return $internalid;
+}


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to