blob: 2a37f735e5ec74c71117978c94fea1c7c6ad7943 [file] [log] [blame]
Matteo Scandoloeb0d11c2017-08-08 13:05:26 -07001
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
rdudyala996d70b2016-10-13 17:40:55 +000017---
18- hosts: '{{ instance_name }}'
19 gather_facts: False
20 connection: ssh
21 user: ubuntu
22 sudo: yes
23
24 tasks:
25
26 - name: Installing python-dev
27 apt: name=python-dev state=present update_cache=yes
28
29 - name: Installing Flask
30 pip: name=Flask
31
32 - name: Verify if ([monitoring_agent] is to avoid capturing the shell process) is already running
33 shell: pgrep -f [m]onitoring_agent | wc -l
34 register: monitoringagent_job_pids_count
35
36 - name: DEBUG
37 debug: var=monitoringagent_job_pids_count.stdout
38
39 - name: stop /usr/local/share/monitoring_agent if already running
40 shell: pkill -f /usr/local/share/monitoring_agent/monitoring_agent.py
41 ignore_errors: True
42 when: monitoringagent_job_pids_count.stdout != "0"
43
44 - name: Deleting monitoring agent folder(if already exists)
45 file: path=/usr/local/share/monitoring_agent state=absent owner=root group=root
46
47 - name: make sure /usr/local/share/monitoring_agent exists
48 file: path=/usr/local/share/monitoring_agent state=directory owner=root group=root
49
Srikanth Vavilapallif2919002016-12-19 18:32:20 +000050 - name: Copying ONOS driver files
51 when : "'ceilometer' in instance_name"
52 copy: src=ceilometer-plugins/network/statistics/ dest=/usr/lib/python2.7/dist-packages/ceilometer/network/statistics/
53
54 - name: Enabling ONOS driver in /usr/lib/python2.7/dist-packages/ceilometer-2015.1.4.egg-info/entry_points.txt
55 when : "'ceilometer' in instance_name"
56 lineinfile:
57 dest: /usr/lib/python2.7/dist-packages/ceilometer-2015.1.4.egg-info/entry_points.txt
58 insertafter: '^\[network\.statistics\.drivers\]'
59 line: "onos = ceilometer.network.statistics.onos.driver:ONOSDriver"
60 state: present
61
rdudyala996d70b2016-10-13 17:40:55 +000062 - name: Copying monitoring agent conf file
63 when : "'ceilometer' in instance_name"
64 set_fact: ceilometer_services="ceilometer-agent-central,ceilometer-agent-notification,ceilometer-collector,ceilometer-api"
65
66 - name: Copying monitoring agent conf file
67 when : "'ceilometer' not in instance_name"
68 set_fact: ceilometer_services="ceilometer-agent-compute"
69
70 - name : DEBUG
71 debug: var=ceilometer_services
72
73 - name: Copying monitoring agent conf file
74 template: src=monitoring_agent.conf.j2 dest=/usr/local/share/monitoring_agent/monitoring_agent.conf mode=0777
75
76 - name: Copying file to /usr/local/share
77 copy: src=monitoring_agent.py dest=/usr/local/share/monitoring_agent/monitoring_agent.py mode=0777
78
79 - name: Copying file to /usr/local/share
80 copy: src=generate_pipeline.py dest=/usr/local/share/monitoring_agent/generate_pipeline.py mode=0777
81
82 - name: Copying file to /usr/local/share
83 copy: src=pipeline.yaml.j2 dest=/usr/local/share/monitoring_agent/pipeline.yaml.j2 mode=0777
84
85 - name: Copying file to /usr/local/share
86 copy: src=start_monitoring_agent.sh dest=/usr/local/share/monitoring_agent/start_monitoring_agent.sh mode=0777
87
88 - name: Starting monitoring agent
89 command: nohup python /usr/local/share/monitoring_agent/monitoring_agent.py &
90 args:
91 chdir: /usr/local/share/monitoring_agent/
92 async: 9999999999999999
93 poll: 0
94
95 - name: Configuring monitoring agent
96 shell: /usr/local/share/monitoring_agent/start_monitoring_agent.sh
97
98#TODO:
99#Copy ONOS notification handlers
100#from ~/xos_services/monitoring/xos/synchronizer/ceilometer/ceilometer-plugins/network/statistics/onos
101#to /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/onos in the headnode ceilometer node
102#Copy a file from ~/xos_services/monitoring/xos/synchronizer/ceilometer/ceilometer-plugins/network/statistics/__init__.py
103#to /usr/lib/python2.7/dist-packages/ceilometer/network/statistics/ folder
104#Also, update the entry_points.txt with the following changes:
105#[network.statistics.drivers]
106#....
107#onos = ceilometer.network.statistics.onos.driver:ONOSDriver