build: remove barometer missing deps
[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.0.1-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/collectd-python-$SUFFIX
63   curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
64
65   tar cfz collectd.tar.gz *.rpm get-pip.py
66   cp collectd.tar.gz ${BUILD_DIR}
67   popd > /dev/null
68
69   # get collectd-ceilometer-plugin and tar it
70   rm -rf collectd-ceilometer-plugin
71   git clone https://github.com/openstack/collectd-ceilometer-plugin
72   pushd collectd-ceilometer-plugin
73   git checkout -b $COLLECTD_CEILOMETER_PLUGIN_BRANCH
74   git archive --format=tar.gz HEAD > ${BUILD_DIR}/collectd-ceilometer-plugin.tar.gz
75   popd > /dev/null
76
77   # get the barometer puppet module and tar it
78   rm -rf puppet-barometer
79   git clone $PUPPET_BAROMETER_REPO
80   pushd puppet-barometer/ > /dev/null
81   git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
82   popd > /dev/null
83
84   # Upload tar files to image
85   # untar collectd packages
86   # install dependencies
87   LIBGUESTFS_BACKEND=direct virt-customize \
88     --upload ${BUILD_DIR}/collectd.tar.gz:/opt/ \
89     --upload ${BUILD_DIR}/collectd-ceilometer-plugin.tar.gz:/opt/ \
90     --upload ${BUILD_DIR}/puppet-barometer.tar.gz:/etc/puppet/modules/ \
91     --run-command 'tar xfz /opt/collectd.tar.gz -C /opt' \
92     --install libstatgrab,log4cplus,rrdtool,rrdtool-devel \
93     --install mcelog,python34,python34-libs,python34-devel \
94     --install libvirt,libvirt-devel,gcc \
95     -a $OVERCLOUD_IMAGE
96
97   LIBGUESTFS_BACKEND=direct virt-customize \
98     --run-command 'python3.4 /opt/get-pip.py' \
99     --run-command 'pip3 install requests libvirt-python pbr babel future six' \
100     -a $OVERCLOUD_IMAGE
101
102   LIBGUESTFS_BACKEND=direct virt-customize \
103     --run-command "yum install -y \
104     /opt/libcollectdclient-${SUFFIX} \
105     /opt/libcollectdclient-devel-${SUFFIX} \
106     /opt/collectd-${SUFFIX} \
107     /opt/collectd-utils-${SUFFIX} \
108     /opt/collectd-python-${SUFFIX} \
109     /opt/collectd-ovs_events-${SUFFIX} \
110     /opt/collectd-ovs_stats-${SUFFIX} \
111     /opt/collectd-virt-${SUFFIX}" \
112     -a $OVERCLOUD_IMAGE
113
114   # install collectd-ceilometer plugin
115   # install puppet-barometer module
116   # make directory for config files
117   LIBGUESTFS_BACKEND=direct virt-customize \
118     --run-command 'mkdir /opt/collectd-ceilometer' \
119     --run-command "tar xfz /opt/collectd-ceilometer-plugin.tar.gz -C /opt/collectd-ceilometer" \
120     --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
121       tar xzf puppet-barometer.tar.gz -C barometer" \
122     --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \
123     -a $OVERCLOUD_IMAGE
124 }
125