aboutsummaryrefslogtreecommitdiffstats
path: root/deployment/heat/onap-rke/scripts
diff options
context:
space:
mode:
authorBrian Freeman <bf1936@att.com>2019-10-28 14:28:31 -0500
committerMarco Platania <platania@research.att.com>2019-10-30 19:35:32 +0000
commit26fc5ccfd75501997f53464461d21354d7860e6d (patch)
tree11226468bca8f155b69b98861927d6b377c5b95e /deployment/heat/onap-rke/scripts
parent519c758ae5e18310ef8e5b20c4d13f04bfa8d8f9 (diff)
Frankfurt Staging override
Add script to automatically generate the file as a test Issue-ID: INT-1217 Change-Id: I9e1dc9b4b2d409ce162e098c90786e3ddce72146 Signed-off-by: Brian Freeman <bf1936@att.com>
Diffstat (limited to 'deployment/heat/onap-rke/scripts')
-rwxr-xr-xdeployment/heat/onap-rke/scripts/createStagingOverride.pl106
1 files changed, 106 insertions, 0 deletions
diff --git a/deployment/heat/onap-rke/scripts/createStagingOverride.pl b/deployment/heat/onap-rke/scripts/createStagingOverride.pl
new file mode 100755
index 000000000..f609f2d3b
--- /dev/null
+++ b/deployment/heat/onap-rke/scripts/createStagingOverride.pl
@@ -0,0 +1,106 @@
+#! /usr/bin/perl
+# ============LICENSE_START====================================================
+# =============================================================================
+# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END======================================================
+
+
+use LWP::Simple;
+use JSON;
+
+my $browser = LWP::UserAgent->new;
+if(defined $ENV{'HTTPS_PROXY'}) {
+ $browser->proxy('https', $ENV{'HTTPS_PROXY'});
+}
+elsif(defined $ENV{'http_proxy'}) {
+ $browser->proxy('https', $ENV{'https_proxy'});
+}
+
+
+
+#############################################################################################
+# Usage: createStagingOverride.yaml staging-image-override.yaml
+# generates staging-image-orveride.yaml.out which can be used as a -f override file
+#
+# script queries nexus3 docker.snapshot repository for the image tags
+# query is only for lines with "onap/" in the override.yaml file
+# ignores 2019/2010, v* tagged images to try to find the latest version numbered SNAPSHOT/STAGING:latest
+#
+#############################################################################################
+$infile=$ARGV[0];
+$outfile=">" . $infile . ".out";
+
+my %VERSIONS='' ;
+
+open (INFILE, $infile) or die "couldnt open INFILE $infile\n";
+open(OUTOVER,$outfile) or die "couldnt open OUTOVER $outfile\n";
+
+while ($line=<INFILE>) {
+ #image: onap/portal-app:2.6.0-STAGING-latest
+ if ($line=~/: onap\//) {
+ chomp($line);
+ ($imageJunk,$imagePath,$imageVersion) = split(':', $line);
+ $imagePath=~s/ //g;
+ $imageVersion=~s/ //g;
+ $stagingImageVersion=&getVersion($imagePath,$imageVersion);
+ $stagingImageVersion=~s/ //g;
+ print "$imagePath , $imageVersion, $stagingImageVersion\n";
+ $VERSIONS{$imagePath}=$stagingImageVersion;
+ $line=~s/$imageVersion/$VERSIONS{$imagePath}/;
+ print OUTOVER $line . "\n";
+ }
+ else {
+ print OUTOVER $line;
+ }
+}
+
+exit ;
+
+
+sub getVersion {
+ my ($path, $version) = @_;
+ #print $path , $version , "\n";
+ my $url = "https://nexus3.onap.org:10001/v2/$path/tags/list" ;
+ #print $url , "\n";
+ my $response = $browser->get( $url );
+ die "Can't get $url -- ", $response->status_line
+ unless $response->is_success;
+ #print $response->decoded_content;
+ # name , tag [ ]
+ $response_json=decode_json $response->decoded_content;
+ #print $response_json->{'name'} , "\n";
+ $latest_tag=$response_json->{'tags'}->[0] ;
+ $tags=$response_json->{'tags'};
+ foreach my $element (@$tags) {
+ if ($element=~/^v/) {
+ next ;
+ }
+ if ($element=~/2019/) {
+ next ;
+ }
+ if ($element=~/2020/) {
+ next ;
+ }
+ if ($element=~/\d\./) {
+ #print $element , "\n";
+ if($element gt $latest_tag) {
+ $latest_tag=$element;
+ }
+ }
+ }
+ return $latest_tag
+}
+
+