Matteo Scandolo | 0810f06 | 2021-11-04 16:42:56 -0700 | [diff] [blame^] | 1 | def call(Map config) { |
| 2 | |
| 3 | def defaultConfig = [ |
| 4 | onosNamespace: "infra", |
| 5 | apps: ['org.opencord.dhcpl2relay', 'org.opencord.olt', 'org.opencord.olt'], |
| 6 | logLevel: "DEBUG", |
| 7 | ] |
| 8 | |
| 9 | if (!config) { |
| 10 | config = [:] |
| 11 | } |
| 12 | |
| 13 | def cfg = defaultConfig + config |
| 14 | |
| 15 | def onosInstances = sh """ |
| 16 | kubectl get pods -n ${cfg.onosNamespace} -l app=onos-classic --no-headers | awk '{print $1}' |
| 17 | """ |
| 18 | |
| 19 | for(int i = 0;i<onosInstances.split( '\n' ).size();i++) { |
| 20 | def instance = onosInstances.split('\n')[i] |
| 21 | |
| 22 | sh """ |
| 23 | _TAG="onos-pf" bash -c "while true; do kubectl port-forward -n ${cfg.onosNamespace} ${instance} 8101; done"& |
| 24 | """ |
| 25 | |
| 26 | for (int j = 0; j < apps.size(); j++) { |
| 27 | def app = apps[i] |
| 28 | sh """ |
| 29 | sshpass -p karaf ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 8101 karaf@localhost log:set ${cfg.logLevel} ${app} |
| 30 | """ |
| 31 | } |
| 32 | |
| 33 | }) |
| 34 | |
| 35 | sh """ |
| 36 | set +x |
| 37 | ps -ef | grep _TAG="onos-pf" | grep -v grep | awk '{print \$2}' | xargs --no-run-if-empty kill -9 |
| 38 | """ |
| 39 | } |