Matteo Scandolo | 7781b5b | 2017-08-08 13:05:26 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 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. |
| 15 | |
| 16 | |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 17 | --- |
| 18 | - hosts: 127.0.0.1 |
| 19 | connection: local |
| 20 | vars: |
| 21 | appname: {{ appname }} |
| 22 | dependencies: {{ dependencies }} |
| 23 | {% if component_configs %} |
| 24 | component_configs: |
| 25 | {% for component_config in component_configs %} |
| 26 | - component: {{ component_config.component }} |
| 27 | config_params: {{ component_config.config_params }} |
| 28 | {% endfor %} |
| 29 | {% endif %} |
| 30 | {% if rest_configs %} |
Sapan Bhatia | f14cf23 | 2017-02-04 08:44:37 -0800 | [diff] [blame] | 31 | var_rest_configs: |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 32 | {% for rest_config in rest_configs %} |
| 33 | - endpoint: {{ rest_config.endpoint }} |
| 34 | body: "{{ '{{' }} lookup('file', '{{ files_dir }}/{{ rest_config.fn }}') {{ '}}' }}" |
| 35 | {% endfor %} |
| 36 | {% endif %} |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 37 | rest_hostname: {{ rest_hostname }} |
| 38 | rest_port: {{ rest_port }} |
| 39 | |
| 40 | tasks: |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 41 | {% if install_dependencies %} |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 42 | - name: Install ONOS apps by URL |
Scott Baker | 726bfce | 2017-10-04 16:43:39 -0700 | [diff] [blame] | 43 | uri: |
| 44 | url: "http://{{ rest_hostname }}:{{ rest_port }}/{{ '{{' }} item.endpoint {{ '}}' }}" |
| 45 | body: "{{ '{{' }} item.body | to_json {{ '}}' }}" |
Scott Baker | 0c62dfa | 2017-11-21 09:15:43 -0800 | [diff] [blame] | 46 | user: {{ rest_username }} |
| 47 | password: {{ rest_password }} |
Scott Baker | 726bfce | 2017-10-04 16:43:39 -0700 | [diff] [blame] | 48 | body_format: json |
| 49 | method: POST |
Scott Baker | 25cb3e9 | 2017-10-09 22:16:52 -0700 | [diff] [blame] | 50 | status_code: 200, 409 |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 51 | with_items: |
| 52 | {% for install_dependency in install_dependencies %} |
| 53 | - endpoint: "onos/v1/applications" |
| 54 | body: |
| 55 | url: "{{ install_dependency }}" |
| 56 | activate: "true" |
| 57 | {% endfor %} |
| 58 | {% endif %} |
| 59 | |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 60 | {% if dependencies %} |
| 61 | - name: Add dependencies to ONOS |
| 62 | uri: |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 63 | url: http://{{ rest_hostname }}:{{ rest_port }}/onos/v1/applications/{{ '{{' }} item {{ '}}' }}/active |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 64 | method: POST |
| 65 | user: karaf |
| 66 | password: karaf |
| 67 | with_items: |
| 68 | {% for dependency in dependencies %} |
| 69 | - {{ dependency }} |
| 70 | {% endfor %} |
| 71 | {% endif %} |
| 72 | |
Scott Baker | d84abe8 | 2017-10-19 09:51:10 -0700 | [diff] [blame] | 73 | {% if component_configs %} |
| 74 | - name: Add ONOS component configuration values |
| 75 | uri: |
| 76 | url: http://{{ rest_hostname }}:{{ rest_port }}/onos/v1/configuration/{{ '{{' }} item.component {{ '}}' }} #http://localhost:8181/onos/v1/configuration/ |
| 77 | body: "{{ '{{' }} item.config_params {{ '}}' }}" |
| 78 | body_format: json |
| 79 | method: POST |
| 80 | user: karaf |
| 81 | password: karaf |
| 82 | with_items: "{{ '{{' }} component_configs {{ '}}' }}" |
| 83 | {% endif %} |
| 84 | |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 85 | {% if rest_configs %} |
| 86 | # Do this after services have been activated, or it will cause an exception. |
| 87 | # vOLT will re-read its net config; vbng may not. |
| 88 | - name: Add ONOS configuration values |
| 89 | uri: |
Andy Bavier | 4a503b1 | 2016-06-21 11:41:29 -0400 | [diff] [blame] | 90 | url: http://{{ rest_hostname }}:{{ rest_port }}/{{ '{{' }} item.endpoint {{ '}}' }} #http://localhost:8181/onos/v1/network/configuration/ |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 91 | body: "{{ '{{' }} item.body {{ '}}' }}" |
Zack Williams | d60c773 | 2016-06-27 13:15:21 -0700 | [diff] [blame] | 92 | body_format: json |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 93 | method: POST |
| 94 | user: karaf |
| 95 | password: karaf |
Sapan Bhatia | f14cf23 | 2017-02-04 08:44:37 -0800 | [diff] [blame] | 96 | with_items: "{{ '{{' }} var_rest_configs {{ '}}' }}" |
Scott Baker | 7a32759 | 2016-06-20 17:34:06 -0700 | [diff] [blame] | 97 | {% endif %} |