blob: a24b02917b0d3453e758f2ff42fc41e0292bffee [file] [log] [blame]
Joey Armstrong96158a92022-11-25 10:36:06 -05001#!/usr/bin/env groovy
2
Matteo Scandolo0810f062021-11-04 16:42:56 -07003def call(Map config) {
4
Joey Armstrong96158a92022-11-25 10:36:06 -05005 String iam = 'vars/setOnosLogLevels.groovy'
6 println("** ${iam}: ENTER")
7
Matteo Scandolo0810f062021-11-04 16:42:56 -07008 def defaultConfig = [
9 onosNamespace: "infra",
Matteo Scandolo857376b2021-11-05 14:53:22 -070010 apps: ['org.opencord.dhcpl2relay', 'org.opencord.olt', 'org.opencord.aaa'],
Matteo Scandolo0810f062021-11-04 16:42:56 -070011 logLevel: "DEBUG",
12 ]
13
14 if (!config) {
15 config = [:]
16 }
17
18 def cfg = defaultConfig + config
19
Matteo Scandolo857376b2021-11-05 14:53:22 -070020 def onosInstances = sh (
21 script: "kubectl get pods -n ${cfg.onosNamespace} -l app=onos-classic --no-headers | awk '{print \$1}'",
22 returnStdout: true
23 ).trim()
Matteo Scandolo0810f062021-11-04 16:42:56 -070024
25 for(int i = 0;i<onosInstances.split( '\n' ).size();i++) {
26 def instance = onosInstances.split('\n')[i]
Matteo Scandolo857376b2021-11-05 14:53:22 -070027 println "Setting log levels on ${instance}"
Matteo Scandolo0810f062021-11-04 16:42:56 -070028 sh """
29 _TAG="onos-pf" bash -c "while true; do kubectl port-forward -n ${cfg.onosNamespace} ${instance} 8101; done"&
Matteo Scandolo5de13192021-11-22 11:24:12 -080030 ps aux | grep port-forward
Matteo Scandolo0810f062021-11-04 16:42:56 -070031 """
32
Matteo Scandolo857376b2021-11-05 14:53:22 -070033 for (int j = 0; j < cfg.apps.size(); j++) {
34 def app = cfg.apps[j]
Matteo Scandolo0810f062021-11-04 16:42:56 -070035 sh """
Matteo Scandolo64deaa92022-02-04 14:46:46 -080036 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 -070037 """
38 }
Matteo Scandolo857376b2021-11-05 14:53:22 -070039 sh """
Matteo Scandolo857376b2021-11-05 14:53:22 -070040 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 -080041 ps aux | grep port-forward
Matteo Scandolo857376b2021-11-05 14:53:22 -070042 """
43 }
Joey Armstrong96158a92022-11-25 10:36:06 -050044
45 println("** ${iam}: LEAVE")
Matteo Scandolo0810f062021-11-04 16:42:56 -070046}