Increase memory size for virt-customize
[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/ocata"
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/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 \
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 -b $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
91   pushd puppet-barometer/ > /dev/null
92   git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
93   popd > /dev/null
94
95   # get mibs for the snmp plugin
96   rm -rf barometer
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
100   popd > /dev/null
101
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 \
113     -a $OVERCLOUD_IMAGE
114
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' \
118     -a $OVERCLOUD_IMAGE
119
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}" \
135     -a $OVERCLOUD_IMAGE
136
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' \
150     -a $OVERCLOUD_IMAGE
151 }
152