3 # Copyright 2017 Intel Corporation.
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Get and install packages needed for Barometer service.
18 # These are: collectd rpm's and dependencies, collectd-ceilometer-plugin,
19 # puppet-barometer module.
22 COLLECTD_CEILOMETER_PLUGIN_BRANCH="stable/ocata"
23 INTEL_CMT_CAT_VER="1.0.1-1.el7.centos.x86_64.rpm"
25 ARCH="6.el7.centos.x86_64.rpm"
26 # don't fail because of missing certificate
27 GETFLAG="--no-check-certificate"
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"
34 # upload barometer packages tar, extract, and install
36 function barometer_pkgs {
39 # get collectd packages and upload to image
40 echo "adding barometer to " $1
43 pushd barometer > /dev/null
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"
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
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"
67 tar cfz collectd.tar.gz *.rpm get-pip.py
68 cp collectd.tar.gz ${BUILD_DIR}
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
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
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 \
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' \
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}" \
118 # install collectd-ceilometer plugin
119 # install puppet-barometer module
120 # make directory for config files
121 LIBGUESTFS_BACKEND=direct virt-customize \
122 --run-command 'mkdir /opt/collectd-ceilometer' \
123 --run-command "tar xfz /opt/collectd-ceilometer-plugin.tar.gz -C /opt/collectd-ceilometer" \
124 --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
125 tar xzf puppet-barometer.tar.gz -C barometer" \
126 --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \