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-openstack-plugins,
19 # puppet-barometer module.
23 COLLECTD_OPENSTACK_PLUGINS_BRANCH="stable/ocata"
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_OPENSTACK_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 \
54 SUFFIX=$COLLECTD_VER-$ARCH
56 # get intel_rdt version
57 INTEL_RDT_VER=$(grep "$BAROMETER_VER/intel-cmt-cat-devel" ./barometer.html \
59 RDT_SUFFIX=$INTEL_RDT_VER-1.el7.centos.x86_64.rpm
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"
76 tar cfz collectd.tar.gz *.rpm get-pip.py
77 cp collectd.tar.gz ${BUILD_DIR}
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 -b $COLLECTD_OPENSTACK_PLUGINS_BRANCH
85 git archive --format=tar.gz HEAD > ${BUILD_DIR}/collectd-openstack-plugins.tar.gz
88 # get the barometer puppet module and tar it
89 rm -rf puppet-barometer
90 git clone $PUPPET_BAROMETER_REPO
91 pushd puppet-barometer/ > /dev/null
92 git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
95 # get mibs for the snmp plugin
97 git clone https://gerrit.opnfv.org/gerrit/barometer
98 pushd barometer/mibs > /dev/null
99 git archive --format=tar.gz HEAD > ${BUILD_DIR}/mibs.tar.gz
102 # Upload tar files to image
103 # untar collectd packages
104 # install dependencies
105 LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
106 --upload ${BUILD_DIR}/collectd.tar.gz:/opt/ \
107 --upload ${BUILD_DIR}/collectd-openstack-plugins.tar.gz:/opt/ \
108 --upload ${BUILD_DIR}/puppet-barometer.tar.gz:/etc/puppet/modules/ \
109 --run-command 'tar xfz /opt/collectd.tar.gz -C /opt' \
110 --install libstatgrab,log4cplus,rrdtool,rrdtool-devel \
111 --install mcelog,python34,python34-libs,python34-devel \
112 --install libvirt,libvirt-devel,gcc \
115 LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
116 --run-command 'python3.4 /opt/get-pip.py' \
117 --run-command 'pip3 install requests libvirt-python pbr babel future six' \
120 LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
121 --run-command "yum install -y \
122 /opt/libcollectdclient-${SUFFIX} \
123 /opt/libcollectdclient-devel-${SUFFIX} \
124 /opt/collectd-${SUFFIX} \
125 /opt/collectd-utils-${SUFFIX} \
126 /opt/collectd-python-${SUFFIX} \
127 /opt/collectd-ovs_events-${SUFFIX} \
128 /opt/collectd-ovs_stats-${SUFFIX} \
129 /opt/intel-cmt-cat-${RDT_SUFFIX} \
130 /opt/intel-cmt-cat-devel-${RDT_SUFFIX} \
131 /opt/collectd-intel_rdt-${SUFFIX} \
132 /opt/collectd-snmp-${SUFFIX} \
133 /opt/collectd-snmp_agent-${SUFFIX} \
134 /opt/collectd-virt-${SUFFIX}" \
137 # install collectd-openstack-plugins
138 # install puppet-barometer module
139 # make directories for config files and mibs
140 LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
141 --run-command 'mkdir /opt/stack/collectd-openstack' \
142 --run-command "tar xfz /opt/collectd-openstack-plugins.tar.gz -C /opt/stack/collectd-openstack" \
143 --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
144 tar xzf puppet-barometer.tar.gz -C barometer" \
145 --run-command 'mkdir /usr/share/mibs/' \
146 --upload ${BUILD_DIR}/mibs.tar.gz:/usr/share/snmp/mibs/ \
147 --run-command 'tar xfz /usr/share/snmp/mibs/mibs.tar.gz -C /usr/share/snmp/mibs/' \
148 --run-command 'ln -s /usr/share/snmp/mibs/ /usr/share/mibs/ietf' \
149 --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \