Merge "Adds OS_REGION_NAME into overcloudrc files"
[apex.git] / build / barometer-install.sh
1 #!/usr/bin/env bash
2
3 # Copyright 2017 Intel Corporation.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #   http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Get and install packages needed for Barometer service.
18 # These are: collectd rpm's and dependencies, collectd-openstack-plugins,
19 # puppet-barometer module.
20 source ./variables.sh
21
22 # Versions/branches
23 COLLECTD_OPENSTACK_PLUGINS_BRANCH="stable/pike"
24
25 ARCH="8.el7.centos.x86_64.rpm"
26
27 # don't fail because of missing certificate
28 GETFLAG="--no-check-certificate"
29
30 # Locations of repos
31 ARTIFACTS_BAROM="artifacts.opnfv.org/barometer"
32 COLLECTD_OPENSTACK_REPO="https://github.com/openstack/collectd-ceilometer-plugin"
33 PUPPET_BAROMETER_REPO="https://github.com/opnfv/barometer.git"
34
35 # upload barometer packages tar, extract, and install
36
37 function barometer_pkgs {
38   OVERCLOUD_IMAGE=$1
39
40   # get collectd packages and upload to image
41   echo "adding barometer to " $1
42   rm -rf barometer
43   mkdir barometer
44   pushd barometer > /dev/null
45
46   # get version of barometer packages to download
47   wget $GETFLAG $ARTIFACTS_BAROM/latest.properties
48   BAROMETER_VER=$(grep OPNFV_ARTIFACT_VERSION ./latest.properties | cut -d'=' -f2)
49   echo "BAROMETER version = $BAROMETER_VER"
50
51   # get collectd version from HTML
52   wget $GETFLAG $ARTIFACTS_BAROM.html
53   COLLECTD_VER=$(grep "$BAROMETER_VER/collectd-debuginfo" ./barometer.html \
54     | cut -d'-' -f7)
55   SUFFIX=$COLLECTD_VER-$ARCH
56
57   # get intel_rdt version
58   INTEL_RDT_VER=$(grep "$BAROMETER_VER/intel-cmt-cat-devel" ./barometer.html \
59     | cut -d'-' -f9)
60   RDT_SUFFIX=$INTEL_RDT_VER-1.el7.centos.x86_64.rpm
61
62   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-${SUFFIX}
63   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-devel-${SUFFIX}
64   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-${SUFFIX}
65   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-utils-${SUFFIX}
66   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-python-${SUFFIX}
67   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_events-${SUFFIX}
68   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_stats-${SUFFIX}
69   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-${RDT_SUFFIX}
70   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-devel-${RDT_SUFFIX}
71   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-intel_rdt-${SUFFIX}
72   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-snmp-${SUFFIX}
73   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-snmp_agent-${SUFFIX}
74   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-virt-${SUFFIX}
75   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-sensors-${SUFFIX}
76   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ceph-${SUFFIX}
77   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-curl_json-${SUFFIX}
78   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-apache-${SUFFIX}
79   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-write_http-${SUFFIX}
80   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-mysql-${SUFFIX}
81   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ping-${SUFFIX}
82   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-smart-${SUFFIX}
83   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-curl_xml-${SUFFIX}
84   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-disk-${SUFFIX}
85   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-rrdcached-${SUFFIX}
86   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-iptables-${SUFFIX}
87   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-curl-${SUFFIX}
88   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ipmi-${SUFFIX}
89   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-netlink-${SUFFIX}
90   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-rrdtool-${SUFFIX}
91   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-lvm-${SUFFIX}
92   curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
93
94   tar cfz collectd.tar.gz *.rpm get-pip.py
95   cp collectd.tar.gz ${BUILD_DIR}
96   popd > /dev/null
97
98   # get collectd-openstack-plugins and tar it
99   rm -rf collectd-openstack-plugins
100   git clone $COLLECTD_OPENSTACK_REPO collectd-openstack-plugins
101   pushd collectd-openstack-plugins
102   git checkout $COLLECTD_OPENSTACK_PLUGINS_BRANCH
103   git archive --format=tar.gz HEAD > ${BUILD_DIR}/collectd-openstack-plugins.tar.gz
104   popd > /dev/null
105
106   # get the barometer puppet module and tar it
107   rm -rf puppet-barometer
108   git clone $PUPPET_BAROMETER_REPO puppet-barometer
109   pushd puppet-barometer/puppet-barometer/ > /dev/null
110   git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
111   popd > /dev/null
112
113   # get mibs for the snmp plugin
114   rm -rf barometer
115   git clone https://gerrit.opnfv.org/gerrit/barometer
116   pushd barometer/mibs > /dev/null
117   git archive --format=tar.gz HEAD > ${BUILD_DIR}/mibs.tar.gz
118   popd > /dev/null
119
120   # Upload tar files to image
121   # untar collectd packages
122   # install dependencies
123   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
124     --upload ${BUILD_DIR}/collectd.tar.gz:/opt/ \
125     --upload ${BUILD_DIR}/collectd-openstack-plugins.tar.gz:/opt/ \
126     --upload ${BUILD_DIR}/puppet-barometer.tar.gz:/etc/puppet/modules/ \
127     --run-command 'tar xfz /opt/collectd.tar.gz -C /opt' \
128     --install libstatgrab,log4cplus,rrdtool,rrdtool-devel \
129     --install mcelog,python34,python34-libs,python34-devel \
130     --install libvirt,libvirt-devel,gcc \
131     -a $OVERCLOUD_IMAGE
132
133   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
134     --run-command 'python3.4 /opt/get-pip.py' \
135     --run-command 'pip3 install requests libvirt-python pbr babel future six' \
136     -a $OVERCLOUD_IMAGE
137
138   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
139     --run-command 'yum remove -y collectd-write_sensu-5.8.0-2.el7.x86_64' \
140     -a $OVERCLOUD_IMAGE
141
142   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
143     --run-command "yum install -y \
144     /opt/libcollectdclient-${SUFFIX} \
145     /opt/libcollectdclient-devel-${SUFFIX} \
146     /opt/collectd-${SUFFIX} \
147     /opt/collectd-utils-${SUFFIX} \
148     /opt/collectd-python-${SUFFIX} \
149     /opt/collectd-ovs_events-${SUFFIX} \
150     /opt/collectd-ovs_stats-${SUFFIX} \
151     /opt/intel-cmt-cat-${RDT_SUFFIX} \
152     /opt/intel-cmt-cat-devel-${RDT_SUFFIX} \
153     /opt/collectd-intel_rdt-${SUFFIX} \
154     /opt/collectd-snmp-${SUFFIX} \
155     /opt/collectd-snmp_agent-${SUFFIX} \
156     /opt/collectd-virt-${SUFFIX} \
157     /opt/collectd-sensors-${SUFFIX} \
158     /opt/collectd-ceph-${SUFFIX} \
159     /opt/collectd-curl_json-${SUFFIX} \
160     /opt/collectd-apache-${SUFFIX} \
161     /opt/collectd-write_http-${SUFFIX} \
162     /opt/collectd-mysql-${SUFFIX} \
163     /opt/collectd-ping-${SUFFIX} \
164     /opt/collectd-smart-${SUFFIX} \
165     /opt/collectd-curl_xml-${SUFFIX} \
166     /opt/collectd-disk-${SUFFIX} \
167     /opt/collectd-rrdcached-${SUFFIX} \
168     /opt/collectd-iptables-${SUFFIX} \
169     /opt/collectd-curl-${SUFFIX} \
170     /opt/collectd-ipmi-${SUFFIX} \
171     /opt/collectd-netlink-${SUFFIX} \
172     /opt/collectd-rrdtool-${SUFFIX} \
173     /opt/collectd-lvm-${SUFFIX}" \
174     -a $OVERCLOUD_IMAGE
175
176   # install collectd-openstack-plugins
177   # install puppet-barometer module
178   # make directories for config files and mibs
179   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
180     --run-command 'mkdir /opt/stack/collectd-openstack' \
181     --run-command "tar xfz /opt/collectd-openstack-plugins.tar.gz -C /opt/stack/collectd-openstack" \
182     --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
183       tar xzf puppet-barometer.tar.gz -C barometer" \
184     --run-command 'mkdir /usr/share/mibs/' \
185     --upload ${BUILD_DIR}/mibs.tar.gz:/usr/share/snmp/mibs/ \
186     --run-command 'tar xfz /usr/share/snmp/mibs/mibs.tar.gz -C /usr/share/snmp/mibs/' \
187     --run-command 'ln -s /usr/share/snmp/mibs/ /usr/share/mibs/ietf' \
188     --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \
189     -a $OVERCLOUD_IMAGE
190 }