From 00db2e2f3454e6becc848dc2ca45938f1bb78a1a Mon Sep 17 00:00:00 2001 From: eimamagi Date: Thu, 20 Jan 2022 16:10:19 +0100 Subject: [PATCH] ARGO-2280 Integrate WEBAPI as topology source in argo-ncg --- src/modules/NCG/SiteInfo/WEBAPI.pm | 32 +++++++---------------------- src/modules/NCG/SiteSet/WEBAPI.pm | 33 +++++------------------------- 2 files changed, 12 insertions(+), 53 deletions(-) diff --git a/src/modules/NCG/SiteInfo/WEBAPI.pm b/src/modules/NCG/SiteInfo/WEBAPI.pm index 4dc3c58..3e2f6a5 100644 --- a/src/modules/NCG/SiteInfo/WEBAPI.pm +++ b/src/modules/NCG/SiteInfo/WEBAPI.pm @@ -40,10 +40,6 @@ sub new $self->{WEBAPI_ROOT_URL} = $DEFAULT_WEBAPI_ROOT_URL; } - if (! exists $self->{NODE_MONITORED}) { - $self->{NODE_MONITORED} = '1'; - } - if (! $self->{TOKEN}) { $self->error("Authentication token must be defined."); return; @@ -51,9 +47,6 @@ sub new if (! exists $self->{TIMEOUT}) { $self->{TIMEOUT} = $self->{DEFAULT_HTTP_TIMEOUT}; } - if (! exists $self->{TYPE}) { - $self->{TYPE} = 'SITES'; - } if (! exists $self->{VO}) { $self->{VO} = 'ops'; @@ -75,17 +68,13 @@ sub getData { my $ua = LWP::UserAgent->new( timeout=>$self->{TIMEOUT}, env_proxy=>1 ); $ua->agent("NCG::SiteInfo::WEBAPI"); $url = $self->{WEBAPI_ROOT_URL} . $DEFAULT_WEBAPI_ROOT_URL_SUFFIX; - $url .= '?type=' . $self->{TYPE} . '&group=' . $sitename; - my @tags; - if ($self->{NODE_MONITORED}) { - push @tags, 'monitored:' . $self->{NODE_MONITORED}; - } - if ($self->{SCOPE}) { - push @tags, 'scope:*'.$self->{SCOPE}.'*'; - } - if (@tags) { - $url .= '&tags='.join(',',@tags); + + if ($self->{FILTER}) { + $url .= '?' . $self->{FILTER} . '&group=' . $sitename; + } else { + $url .= '?group=' . $sitename; } + my $req = HTTP::Request->new(GET => $url); $req->header('x-api-key' => $self->{TOKEN}); $req->header('Accept' => 'application/json'); @@ -211,16 +200,9 @@ Module extracts list of sites from ARGO WEBAPI component. Creates new NCG::SiteInfo::WEBAPI instance. Argument $options is hash reference that can contain following elements: - NODE_MONITORED - filter only endpoints with tag monitored + FILTER - filter query that will be forwarded (default: ) - SCOPE - scope of sites - (default: ) - - TYPE - type of groups fetched from WEBAPI, EGI uses SITES, - most other tenants SERVICEGROUPS - (default: SITES) - TIMEOUT - HTTP timeout (default: DEFAULT_HTTP_TIMEOUT inherited from NCG) diff --git a/src/modules/NCG/SiteSet/WEBAPI.pm b/src/modules/NCG/SiteSet/WEBAPI.pm index be82a91..5d36ecd 100644 --- a/src/modules/NCG/SiteSet/WEBAPI.pm +++ b/src/modules/NCG/SiteSet/WEBAPI.pm @@ -39,10 +39,6 @@ sub new $self->{WEBAPI_ROOT_URL} = $DEFAULT_WEBAPI_ROOT_URL; } - if (! exists $self->{TYPE}) { - $self->{TYPE} = 'NGI'; - } - if (! $self->{TOKEN}) { $self->error("Authentication token must be defined."); return; @@ -61,20 +57,11 @@ sub getData { my $ua = LWP::UserAgent->new( timeout=>$self->{TIMEOUT}, env_proxy=>1 ); $ua->agent("NCG::SiteSet::WEBAPI"); $url = $self->{WEBAPI_ROOT_URL} . $DEFAULT_WEBAPI_ROOT_URL_SUFFIX; - $url .= '?type' . $self->{TYPE}; - my @tags; - if ($self->{CERT_STATUS}) { - push @tags, 'certification:' . $self->{CERT_STATUS}; - } - if ($self->{PROD_STATUS}) { - push @tags, 'infrastructure:' . $self->{PROD_STATUS}; - } - if ($self->{SCOPE}) { - push @tags, 'scope:*'.$self->{SCOPE}.'*'; - } - if (@tags) { - $url .= '&tags='.join(',',@tags); + + if ($self->{FILTER}) { + $url .= '?' . $self->{FILTER} . '&group=' . $sitename; } + my $req = HTTP::Request->new(GET => $url); $req->header('x-api-key' => $self->{TOKEN}); $req->header('Accept' => 'application/json'); @@ -161,19 +148,9 @@ Module extracts list of sites from ARGO WEBAPI component. Creates new NCG::SiteSet::WEBAPI instance. Argument $options is hash reference that can contain following elements: - CERT_STATUS - certification status of site - (default: ) - - PROD_STATUS - production status of site + FILTER - filter query that will be forwarded (default: ) - SCOPE - scope of sites - (default: ) - - TYPE - type of groups fetched from WEBAPI, EGI uses NGI, - most other tenants PROJECT - (default: NGI) - TIMEOUT - HTTP timeout (default: DEFAULT_HTTP_TIMEOUT inherited from NCG)