blob: 0c18fd4ee7be9a54b69c3ad28f90ecb52871eae7 [file] [log] [blame]
Matteo Scandolo0810f062021-11-04 16:42:56 -07001def call(Map config) {
2
3 def defaultConfig = [
4 onosNamespace: "infra",
Matteo Scandolo857376b2021-11-05 14:53:22 -07005 apps: ['org.opencord.dhcpl2relay', 'org.opencord.olt', 'org.opencord.aaa'],
Matteo Scandolo0810f062021-11-04 16:42:56 -07006 logLevel: "DEBUG",
7 ]
8
9 if (!config) {
10 config = [:]
11 }
12
13 def cfg = defaultConfig + config
14
Matteo Scandolo857376b2021-11-05 14:53:22 -070015 def onosInstances = sh (
16 script: "kubectl get pods -n ${cfg.onosNamespace} -l app=onos-classic --no-headers | awk '{print \$1}'",
17 returnStdout: true
18 ).trim()
Matteo Scandolo0810f062021-11-04 16:42:56 -070019
20 for(int i = 0;i<onosInstances.split( '\n' ).size();i++) {
21 def instance = onosInstances.split('\n')[i]
Matteo Scandolo857376b2021-11-05 14:53:22 -070022 println "Setting log levels on ${instance}"
Matteo Scandolo0810f062021-11-04 16:42:56 -070023 sh """
24 _TAG="onos-pf" bash -c "while true; do kubectl port-forward -n ${cfg.onosNamespace} ${instance} 8101; done"&
Matteo Scandolo5de13192021-11-22 11:24:12 -080025 ps aux | grep port-forward
Matteo Scandolo0810f062021-11-04 16:42:56 -070026 """
27
Matteo Scandolo857376b2021-11-05 14:53:22 -070028 for (int j = 0; j < cfg.apps.size(); j++) {
29 def app = cfg.apps[j]
Matteo Scandolo0810f062021-11-04 16:42:56 -070030 sh """
31 sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost log:set ${cfg.logLevel} ${app}
32 """
33 }
Matteo Scandolo857376b2021-11-05 14:53:22 -070034 sh """
Matteo Scandolo857376b2021-11-05 14:53:22 -070035 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 -080036 ps aux | grep port-forward
Matteo Scandolo857376b2021-11-05 14:53:22 -070037 """
38 }
Matteo Scandolo0810f062021-11-04 16:42:56 -070039}