Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 1 | /* |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 2 | * Copyright 2012 the original author or authors. |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 3 | * |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 17 | ext { |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 18 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 19 | // Target registry to be used to publish docker images needed for deployment |
| 20 | targetReg = project.hasProperty('targetReg') ? project.getProperty('targetReg') : 'localhost:5000' |
| 21 | |
| 22 | // The tag used to tag the docker images push to the target registry |
| 23 | targetTag = project.hasProperty('targetTag') ? project.getProperty('targetTag') : 'candidate' |
| 24 | |
ChetanGaonker | 5979e21 | 2016-06-03 09:30:49 -0700 | [diff] [blame] | 25 | cordTesterPath = project.hasProperty('cordTesterPath') ? project.getProperty('cordTesterPath') : './src/test/setup' |
| 26 | |
| 27 | dockerPath = project.hasProperty('dockerPath') ? project.getProperty('dockerPath') : '/usr/bin' |
A R Karthick | 577520a | 2016-06-07 14:40:12 -0700 | [diff] [blame] | 28 | |
| 29 | cordTesterAptDeps = [ 'python', 'python-dev', 'python-pip', 'python-setuptools' ] |
| 30 | |
| 31 | cordTesterPipDeps = [ 'scapy', 'nose', 'monotonic', 'configObj', 'docker-py', 'pyyaml', 'nsenter', 'pyroute2', 'netaddr', 'scapy-ssl_tls' ] |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 34 | // ~~~~~~~~~~~~~~~~~~~ Global tasks ~~~~~~~~~~~~~~~~~~~~~~~ |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 35 | |
A R Karthick | 577520a | 2016-06-07 14:40:12 -0700 | [diff] [blame] | 36 | task aptFetch() { |
| 37 | // fetch the dependencies for cord tester |
| 38 | cordTesterAptDeps.each { |
| 39 | String pkg -> |
| 40 | exec { |
| 41 | executable 'apt-get' |
| 42 | args "install", "-y", pkg |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | task pipFetch() { |
| 48 | // fetch the dependencies for cord tester |
| 49 | dependsOn aptFetch |
| 50 | cordTesterPipDeps.each { |
| 51 | String pkg -> |
| 52 | exec { |
| 53 | executable 'pip' |
| 54 | args "install", "-U", pkg |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 59 | // To be used to fetch upstream binaries, clone repos, etc. |
ChetanGaonker | 5979e21 | 2016-06-03 09:30:49 -0700 | [diff] [blame] | 60 | task fetch (type: Exec) { |
A R Karthick | 577520a | 2016-06-07 14:40:12 -0700 | [diff] [blame] | 61 | dependsOn pipFetch |
ChetanGaonker | 5979e21 | 2016-06-03 09:30:49 -0700 | [diff] [blame] | 62 | commandLine "$cordTesterPath/onos_pull.sh", 'latest' |
Zsolt Haraszti | 56700cd | 2016-06-01 16:02:05 -0700 | [diff] [blame] | 63 | } |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 64 | |
| 65 | // To be used to generate all needed binaries that need to be present on the target |
| 66 | // as docker images in the local docker runner. |
ChetanGaonker | 5979e21 | 2016-06-03 09:30:49 -0700 | [diff] [blame] | 67 | task buildImages (type: Exec) { |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 68 | // ... |
ChetanGaonker | 5979e21 | 2016-06-03 09:30:49 -0700 | [diff] [blame] | 69 | commandLine "$cordTesterPath/cord-test.py", 'build', 'all' |
Zsolt Haraszti | d5fa9ed | 2016-06-01 16:07:16 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | // Publish image(s) built during the build step into targetReg registry using the targetTag |
| 73 | // tag. See maas subproject for examples on how to do this. |
| 74 | task publish { |
| 75 | println "$targetTag" |
| 76 | } |