blob: 346b5ef66fa01e0313c35f7abc12ead7e48512c2 [file] [log] [blame]
Joey Armstrong96158a92022-11-25 10:36:06 -05001#!/usr/bin/env groovy
Joey Armstrongaf679da2023-01-31 14:22:41 -05002// -----------------------------------------------------------------------
Joey Armstrong6a9013e2024-02-01 17:56:57 -05003// Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors
Joey Armstrongaf679da2023-01-31 14:22:41 -05004//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16// -----------------------------------------------------------------------
Joey Armstrong96158a92022-11-25 10:36:06 -050017
Matteo Scandolo0810f062021-11-04 16:42:56 -070018def call(Map config) {
19
Joey Armstrong96158a92022-11-25 10:36:06 -050020 String iam = 'vars/setOnosLogLevels.groovy'
21 println("** ${iam}: ENTER")
22
Matteo Scandolo0810f062021-11-04 16:42:56 -070023 def defaultConfig = [
24 onosNamespace: "infra",
Matteo Scandolo857376b2021-11-05 14:53:22 -070025 apps: ['org.opencord.dhcpl2relay', 'org.opencord.olt', 'org.opencord.aaa'],
Matteo Scandolo0810f062021-11-04 16:42:56 -070026 logLevel: "DEBUG",
27 ]
28
29 if (!config) {
30 config = [:]
31 }
32
33 def cfg = defaultConfig + config
34
Matteo Scandolo857376b2021-11-05 14:53:22 -070035 def onosInstances = sh (
36 script: "kubectl get pods -n ${cfg.onosNamespace} -l app=onos-classic --no-headers | awk '{print \$1}'",
37 returnStdout: true
38 ).trim()
Matteo Scandolo0810f062021-11-04 16:42:56 -070039
40 for(int i = 0;i<onosInstances.split( '\n' ).size();i++) {
41 def instance = onosInstances.split('\n')[i]
Matteo Scandolo857376b2021-11-05 14:53:22 -070042 println "Setting log levels on ${instance}"
Matteo Scandolo0810f062021-11-04 16:42:56 -070043 sh """
44 _TAG="onos-pf" bash -c "while true; do kubectl port-forward -n ${cfg.onosNamespace} ${instance} 8101; done"&
Matteo Scandolo5de13192021-11-22 11:24:12 -080045 ps aux | grep port-forward
Matteo Scandolo0810f062021-11-04 16:42:56 -070046 """
47
Matteo Scandolo857376b2021-11-05 14:53:22 -070048 for (int j = 0; j < cfg.apps.size(); j++) {
49 def app = cfg.apps[j]
Matteo Scandolo0810f062021-11-04 16:42:56 -070050 sh """
Matteo Scandolo64deaa92022-02-04 14:46:46 -080051 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost log:set ${cfg.logLevel} ${app} || true
Matteo Scandolo0810f062021-11-04 16:42:56 -070052 """
53 }
Matteo Scandolo857376b2021-11-05 14:53:22 -070054 sh """
Matteo Scandolo857376b2021-11-05 14:53:22 -070055 ps e -ww -A | grep _TAG="onos-pf" | grep -v grep | awk '{print \$1}' | xargs --no-run-if-empty kill -9
Matteo Scandolo5de13192021-11-22 11:24:12 -080056 ps aux | grep port-forward
Matteo Scandolo857376b2021-11-05 14:53:22 -070057 """
58 }
Joey Armstrong96158a92022-11-25 10:36:06 -050059
60 println("** ${iam}: LEAVE")
Matteo Scandolo0810f062021-11-04 16:42:56 -070061}
Joey Armstrongaf679da2023-01-31 14:22:41 -050062
63// [EOF]