Ensures v4/v6 iptables filters are loaded
[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="6.el7.centos.x86_64.rpm"
26 # don't fail because of missing certificate
27 GETFLAG="--no-check-certificate"
28
29 # Locations of repos
30 ARTIFACTS_BAROM="artifacts.opnfv.org/barometer"
31 COLLECTD_OPENSTACK_REPO="https://github.com/openstack/collectd-ceilometer-plugin"
32 PUPPET_BAROMETER_REPO="https://github.com/opnfv/barometer.git"
33
34 # upload barometer packages tar, extract, and install
35
36 function barometer_pkgs {
37   OVERCLOUD_IMAGE=$1
38
39   # get collectd packages and upload to image
40   echo "adding barometer to " $1
41   rm -rf barometer
42   mkdir barometer
43   pushd barometer > /dev/null
44
45   # get version of barometer packages to download
46   wget $GETFLAG $ARTIFACTS_BAROM/latest.properties
47   BAROMETER_VER=$(grep OPNFV_ARTIFACT_VERSION ./latest.properties | cut -d'=' -f2)
48   echo "BAROMETER version = $BAROMETER_VER"
49
50   # get collectd version from HTML
51   wget $GETFLAG $ARTIFACTS_BAROM.html
52   COLLECTD_VER=$(grep "$BAROMETER_VER/collectd-debuginfo" ./barometer.html \
53     | cut -d'-' -f7)
54   SUFFIX=$COLLECTD_VER-$ARCH
55
56   # get intel_rdt version
57   INTEL_RDT_VER=$(grep "$BAROMETER_VER/intel-cmt-cat-devel" ./barometer.html \
58     | cut -d'-' -f9)
59   RDT_SUFFIX=$INTEL_RDT_VER-1.el7.centos.x86_64.rpm
60
61   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-$SUFFIX
62   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-devel-$SUFFIX
63   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-$SUFFIX
64   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-utils-$SUFFIX
65   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_events-$SUFFIX
66   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_stats-$SUFFIX
67   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-virt-$SUFFIX
68   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-$RDT_SUFFIX
69   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-devel-$RDT_SUFFIX
70   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-python-$SUFFIX
71   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-snmp-$SUFFIX
72   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-snmp_agent-$SUFFIX
73   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-intel_rdt-$SUFFIX
74   curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
75
76   tar cfz collectd.tar.gz *.rpm get-pip.py
77   cp collectd.tar.gz ${BUILD_DIR}
78   popd > /dev/null
79
80   # get collectd-openstack-plugins and tar it
81   rm -rf collectd-openstack-plugins
82   git clone $COLLECTD_OPENSTACK_REPO collectd-openstack-plugins
83   pushd collectd-openstack-plugins
84   git checkout $COLLECTD_OPENSTACK_PLUGINS_BRANCH
85   git archive --format=tar.gz HEAD > ${BUILD_DIR}/collectd-openstack-plugins.tar.gz
86   popd > /dev/null
87
88   # get the barometer puppet module and tar it
89   rm -rf puppet-barometer
90   git clone $PUPPET_BAROMETER_REPO puppet-barometer
91   cd puppet-barometer
92   pushd puppet-barometer/ > /dev/null
93   git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
94   popd > /dev/null
95
96   # get mibs for the snmp plugin
97   rm -rf barometer
98   git clone https://gerrit.opnfv.org/gerrit/barometer
99   pushd barometer/mibs > /dev/null
100   git archive --format=tar.gz HEAD > ${BUILD_DIR}/mibs.tar.gz
101   popd > /dev/null
102
103   # Upload tar files to image
104   # untar collectd packages
105   # install dependencies
106   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
107     --upload ${BUILD_DIR}/collectd.tar.gz:/opt/ \
108     --upload ${BUILD_DIR}/collectd-openstack-plugins.tar.gz:/opt/ \
109     --upload ${BUILD_DIR}/puppet-barometer.tar.gz:/etc/puppet/modules/ \
110     --run-command 'tar xfz /opt/collectd.tar.gz -C /opt' \
111     --install libstatgrab,log4cplus,rrdtool,rrdtool-devel \
112     --install mcelog,python34,python34-libs,python34-devel \
113     --install libvirt,libvirt-devel,gcc \
114     -a $OVERCLOUD_IMAGE
115
116   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
117     --run-command 'python3.4 /opt/get-pip.py' \
118     --run-command 'pip3 install requests libvirt-python pbr babel future six' \
119     -a $OVERCLOUD_IMAGE
120
121   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
122     --run-command "yum install -y \
123     /opt/libcollectdclient-${SUFFIX} \
124     /opt/libcollectdclient-devel-${SUFFIX} \
125     /opt/collectd-${SUFFIX} \
126     /opt/collectd-utils-${SUFFIX} \
127     /opt/collectd-python-${SUFFIX} \
128     /opt/collectd-ovs_events-${SUFFIX} \
129     /opt/collectd-ovs_stats-${SUFFIX} \
130     /opt/intel-cmt-cat-${RDT_SUFFIX} \
131     /opt/intel-cmt-cat-devel-${RDT_SUFFIX} \
132     /opt/collectd-intel_rdt-${SUFFIX} \
133     /opt/collectd-snmp-${SUFFIX} \
134     /opt/collectd-snmp_agent-${SUFFIX} \
135     /opt/collectd-virt-${SUFFIX}" \
136     -a $OVERCLOUD_IMAGE
137
138   # install collectd-openstack-plugins
139   # install puppet-barometer module
140   # make directories for config files and mibs
141   LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
142     --run-command 'mkdir /opt/stack/collectd-openstack' \
143     --run-command "tar xfz /opt/collectd-openstack-plugins.tar.gz -C /opt/stack/collectd-openstack" \
144     --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
145       tar xzf puppet-barometer.tar.gz -C barometer" \
146     --run-command 'mkdir /usr/share/mibs/' \
147     --upload ${BUILD_DIR}/mibs.tar.gz:/usr/share/snmp/mibs/ \
148     --run-command 'tar xfz /usr/share/snmp/mibs/mibs.tar.gz -C /usr/share/snmp/mibs/' \
149     --run-command 'ln -s /usr/share/snmp/mibs/ /usr/share/mibs/ietf' \
150     --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \
151     -a $OVERCLOUD_IMAGE
152 }
153