diff options
author | 2021-09-02 09:39:44 +0200 | |
---|---|---|
committer | 2021-10-01 14:23:46 +0000 | |
commit | 5522f4473bc6f0256744b10f76a3ac3e06b8e654 (patch) | |
tree | bc1d029718672c0b60c2d8ab1bb0b6ff012f3181 /external-schema-repo-generator/generator/bin_packing.awk | |
parent | 1898455d2fdd4c4f1f4914119e123babed60ce61 (diff) |
[UTILS] Fix and resolve remote references in standard defined domain
Add functionality to scripts that:
- Looks in cloned schema file for remote refs.
- Downloads remote refs to schema directory
- Splits schema directory directories less than 1mb
- Replace remote and local refs locations with local locations
and current directory structure
- Creates for each directory separate configmap less than 1mb
Signed-off-by: Krzysztof Kuzmicki <krzysztof.kuzmicki@nokia.com>
Issue-ID: DCAEGEN2-2893 DCAEGEN2-2894 DCAEGEN2-2895
Change-Id: Ia55e2fb29eb2fa6575821f12af5e22f0f1d8ff5a
Diffstat (limited to 'external-schema-repo-generator/generator/bin_packing.awk')
-rw-r--r-- | external-schema-repo-generator/generator/bin_packing.awk | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/external-schema-repo-generator/generator/bin_packing.awk b/external-schema-repo-generator/generator/bin_packing.awk new file mode 100644 index 0000000..5e82ceb --- /dev/null +++ b/external-schema-repo-generator/generator/bin_packing.awk @@ -0,0 +1,48 @@ +# ============LICENSE_START======================================================= +# OOM +# ================================================================================ +# Copyright (C) 2020-2021 Nokia. 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========================================================= + +function first_fit(v, file) { + # find first bin that can accomodate the volume + for (i=1; i<=n; ++i) { + if (b[i] > v) { + b[i] -= v + bc[i]++ + cmd="mkdir -p "tmpLocation"/"schema"-subdir-"i"/OpenAPI" + system(cmd) + cmd="mv "file" " tmpLocation"/"schema "-subdir-" i "/OpenAPI" + system(cmd) + return + } + } + # no bin found, create new bin + if (i > n) { + b[++n] = c - v + bc[n]++ + cmd="mkdir -p "tmpLocation"/"schema"-subdir-"n"/OpenAPI" + system(cmd) + cmd="mv "file" " tmpLocation"/"schema "-subdir-"n"/OpenAPI" + system(cmd) + } + return +} +BEGIN{ if( (c+0) == 0) exit } +{ first_fit($1,$2) } +END { print "REPORT:" + print "Created",n,"directories" + for(i=1;i<=n;++i) { + print "- "tmpLocation"/"schema"-subdir-"i,":", c-b[i],"bytes",bc[i],"files" + } +} |