Merge "build: added intel_cmt_cat rpm"
[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-ceilometer-plugin,
19 # puppet-barometer module.
20
21 # Versions/branches
22 COLLECTD_CEILOMETER_PLUGIN_BRANCH="stable/ocata"
23 INTEL_CMT_CAT_VER="1.1.0-1.el7.centos.x86_64.rpm"
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_CEILOMETER_REPO="https://github.com/openstack/collectd-ceilometer-plugin"
32 PUPPET_BAROMETER_REPO="https://github.com/johnhinman/puppet-barometer"
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 | cut -d'-' -f7)
53   SUFFIX=$COLLECTD_VER-$ARCH
54
55   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-$SUFFIX
56   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-devel-$SUFFIX
57   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-$SUFFIX
58   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-utils-$SUFFIX
59   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_events-$SUFFIX
60   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_stats-$SUFFIX
61   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-virt-$SUFFIX
62   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-$INTEL_CMT_CAT_VER
63   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-devel-$INTEL_CMT_CAT_VER
64   wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-python-$SUFFIX
65   curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
66
67   tar cfz collectd.tar.gz *.rpm get-pip.py
68   cp collectd.tar.gz ${BUILD_DIR}
69   popd > /dev/null
70
71   # get collectd-ceilometer-plugin and tar it
72   rm -rf collectd-ceilometer-plugin
73   git clone https://github.com/openstack/collectd-ceilometer-plugin
74   pushd collectd-ceilometer-plugin
75   git checkout -b $COLLECTD_CEILOMETER_PLUGIN_BRANCH
76   git archive --format=tar.gz HEAD > ${BUILD_DIR}/collectd-ceilometer-plugin.tar.gz
77   popd > /dev/null
78
79   # get the barometer puppet module and tar it
80   rm -rf puppet-barometer
81   git clone $PUPPET_BAROMETER_REPO
82   pushd puppet-barometer/ > /dev/null
83   git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
84   popd > /dev/null
85
86   # Upload tar files to image
87   # untar collectd packages
88   # install dependencies
89   LIBGUESTFS_BACKEND=direct virt-customize \
90     --upload ${BUILD_DIR}/collectd.tar.gz:/opt/ \
91     --upload ${BUILD_DIR}/collectd-ceilometer-plugin.tar.gz:/opt/ \
92     --upload ${BUILD_DIR}/puppet-barometer.tar.gz:/etc/puppet/modules/ \
93     --run-command 'tar xfz /opt/collectd.tar.gz -C /opt' \
94     --install libstatgrab,log4cplus,rrdtool,rrdtool-devel \
95     --install mcelog,python34,python34-libs,python34-devel \
96     --install libvirt,libvirt-devel,gcc \
97     -a $OVERCLOUD_IMAGE
98
99   LIBGUESTFS_BACKEND=direct virt-customize \
100     --run-command 'python3.4 /opt/get-pip.py' \
101     --run-command 'pip3 install requests libvirt-python pbr babel future six' \
102     -a $OVERCLOUD_IMAGE
103
104   LIBGUESTFS_BACKEND=direct virt-customize \
105     --run-command "yum install -y \
106     /opt/libcollectdclient-${SUFFIX} \
107     /opt/libcollectdclient-devel-${SUFFIX} \
108     /opt/collectd-${SUFFIX} \
109     /opt/collectd-utils-${SUFFIX} \
110     /opt/collectd-python-${SUFFIX} \
111     /opt/collectd-ovs_events-${SUFFIX} \
112     /opt/collectd-ovs_stats-${SUFFIX} \
113     /opt/collectd-virt-${SUFFIX} \
114     /opt/intel-cmt-cat-${INTEL_CMT_CAT_VER} \
115     /opt/intel-cmt-cat-devel-${INTEL_CMT_CAT_VER} \
116     /opt/collectd-virt-${SUFFIX}" \
117     -a $OVERCLOUD_IMAGE
118
119   # install collectd-ceilometer plugin
120   # install puppet-barometer module
121   # make directory for config files
122   LIBGUESTFS_BACKEND=direct virt-customize \
123     --run-command 'mkdir /opt/collectd-ceilometer' \
124     --run-command "tar xfz /opt/collectd-ceilometer-plugin.tar.gz -C /opt/collectd-ceilometer" \
125     --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
126       tar xzf puppet-barometer.tar.gz -C barometer" \
127     --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \
128     -a $OVERCLOUD_IMAGE
129 }
130