summaryrefslogtreecommitdiffstats
path: root/build/barometer-install.sh
blob: 2391b6b860882bac3c54376f9d966ef9ed45eeaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/usr/bin/env bash

# Copyright 2017 Intel Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Get and install packages needed for Barometer service.
# These are: collectd rpm's and dependencies, collectd-openstack-plugins,
# puppet-barometer module.
source ./variables.sh

# Versions/branches
COLLECTD_OPENSTACK_PLUGINS_BRANCH="stable/pike"

ARCH="8.el7.centos.x86_64.rpm"

# don't fail because of missing certificate
GETFLAG="--no-check-certificate"

# Locations of repos
ARTIFACTS_BAROM="artifacts.opnfv.org/barometer"
COLLECTD_OPENSTACK_REPO="https://github.com/openstack/collectd-ceilometer-plugin"
PUPPET_BAROMETER_REPO="https://github.com/opnfv/barometer.git"

# upload barometer packages tar, extract, and install

function barometer_pkgs {
  OVERCLOUD_IMAGE=$1

  # get collectd packages and upload to image
  echo "adding barometer to " $1
  rm -rf barometer
  mkdir barometer
  pushd barometer > /dev/null

  # get version of barometer packages to download
  wget $GETFLAG $ARTIFACTS_BAROM/latest.properties
  BAROMETER_VER=$(grep OPNFV_ARTIFACT_VERSION ./latest.properties | cut -d'=' -f2)
  echo "BAROMETER version = $BAROMETER_VER"

  # get collectd version from HTML
  wget $GETFLAG $ARTIFACTS_BAROM.html
  COLLECTD_VER=$(grep "$BAROMETER_VER/collectd-debuginfo" ./barometer.html \
    | cut -d'-' -f7)
  SUFFIX=$COLLECTD_VER-$ARCH

  # get intel_rdt version
  INTEL_RDT_VER=$(grep "$BAROMETER_VER/intel-cmt-cat-devel" ./barometer.html \
    | cut -d'-' -f9)
  RDT_SUFFIX=$INTEL_RDT_VER-1.el7.centos.x86_64.rpm

  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/libcollectdclient-devel-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-utils-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-python-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_events-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ovs_stats-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-${RDT_SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/intel-cmt-cat-devel-${RDT_SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-intel_rdt-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-snmp-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-snmp_agent-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-virt-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-sensors-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ceph-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-curl_json-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-apache-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-write_http-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-mysql-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ping-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-smart-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-curl_xml-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-disk-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-rrdcached-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-iptables-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-curl-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-ipmi-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-netlink-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-rrdtool-${SUFFIX}
  wget $GETFLAG $ARTIFACTS_BAROM/$BAROMETER_VER/collectd-lvm-${SUFFIX}
  curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

  tar cfz collectd.tar.gz *.rpm get-pip.py
  cp collectd.tar.gz ${BUILD_DIR}
  popd > /dev/null

  # get collectd-openstack-plugins and tar it
  rm -rf collectd-openstack-plugins
  git clone $COLLECTD_OPENSTACK_REPO collectd-openstack-plugins
  pushd collectd-openstack-plugins
  git checkout $COLLECTD_OPENSTACK_PLUGINS_BRANCH
  git archive --format=tar.gz HEAD > ${BUILD_DIR}/collectd-openstack-plugins.tar.gz
  popd > /dev/null

  # get the barometer puppet module and tar it
  rm -rf puppet-barometer
  git clone $PUPPET_BAROMETER_REPO puppet-barometer
  pushd puppet-barometer/puppet-barometer/ > /dev/null
  git archive --format=tar.gz HEAD > ${BUILD_DIR}/puppet-barometer.tar.gz
  popd > /dev/null

  # get mibs for the snmp plugin
  rm -rf barometer
  git clone https://gerrit.opnfv.org/gerrit/barometer
  pushd barometer/mibs > /dev/null
  git archive --format=tar.gz HEAD > ${BUILD_DIR}/mibs.tar.gz
  popd > /dev/null

  # Upload tar files to image
  # untar collectd packages
  # install dependencies
  LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
    --upload ${BUILD_DIR}/collectd.tar.gz:/opt/ \
    --upload ${BUILD_DIR}/collectd-openstack-plugins.tar.gz:/opt/ \
    --upload ${BUILD_DIR}/puppet-barometer.tar.gz:/etc/puppet/modules/ \
    --run-command 'tar xfz /opt/collectd.tar.gz -C /opt' \
    --install libstatgrab,log4cplus,rrdtool,rrdtool-devel \
    --install mcelog,python34,python34-libs,python34-devel \
    --install libvirt,libvirt-devel,gcc \
    -a $OVERCLOUD_IMAGE

  LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
    --run-command 'python3.4 /opt/get-pip.py' \
    --run-command 'pip3 install requests libvirt-python pbr babel future six' \
    -a $OVERCLOUD_IMAGE

  LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
    --run-command 'yum remove -y collectd-write_sensu-5.8.0-2.el7.x86_64' \
    -a $OVERCLOUD_IMAGE

  LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
    --run-command "yum install -y \
    /opt/libcollectdclient-${SUFFIX} \
    /opt/libcollectdclient-devel-${SUFFIX} \
    /opt/collectd-${SUFFIX} \
    /opt/collectd-utils-${SUFFIX} \
    /opt/collectd-python-${SUFFIX} \
    /opt/collectd-ovs_events-${SUFFIX} \
    /opt/collectd-ovs_stats-${SUFFIX} \
    /opt/intel-cmt-cat-${RDT_SUFFIX} \
    /opt/intel-cmt-cat-devel-${RDT_SUFFIX} \
    /opt/collectd-intel_rdt-${SUFFIX} \
    /opt/collectd-snmp-${SUFFIX} \
    /opt/collectd-snmp_agent-${SUFFIX} \
    /opt/collectd-virt-${SUFFIX} \
    /opt/collectd-sensors-${SUFFIX} \
    /opt/collectd-ceph-${SUFFIX} \
    /opt/collectd-curl_json-${SUFFIX} \
    /opt/collectd-apache-${SUFFIX} \
    /opt/collectd-write_http-${SUFFIX} \
    /opt/collectd-mysql-${SUFFIX} \
    /opt/collectd-ping-${SUFFIX} \
    /opt/collectd-smart-${SUFFIX} \
    /opt/collectd-curl_xml-${SUFFIX} \
    /opt/collectd-disk-${SUFFIX} \
    /opt/collectd-rrdcached-${SUFFIX} \
    /opt/collectd-iptables-${SUFFIX} \
    /opt/collectd-curl-${SUFFIX} \
    /opt/collectd-ipmi-${SUFFIX} \
    /opt/collectd-netlink-${SUFFIX} \
    /opt/collectd-rrdtool-${SUFFIX} \
    /opt/collectd-lvm-${SUFFIX}" \
    -a $OVERCLOUD_IMAGE

  # install collectd-openstack-plugins
  # install puppet-barometer module
  # make directories for config files and mibs
  LIBGUESTFS_BACKEND=direct $VIRT_CUSTOMIZE \
    --run-command 'mkdir /opt/stack/collectd-openstack' \
    --run-command "tar xfz /opt/collectd-openstack-plugins.tar.gz -C /opt/stack/collectd-openstack" \
    --run-command "cd /etc/puppet/modules/ && mkdir barometer && \
      tar xzf puppet-barometer.tar.gz -C barometer" \
    --run-command 'mkdir /usr/share/mibs/' \
    --upload ${BUILD_DIR}/mibs.tar.gz:/usr/share/snmp/mibs/ \
    --run-command 'tar xfz /usr/share/snmp/mibs/mibs.tar.gz -C /usr/share/snmp/mibs/' \
    --run-command 'ln -s /usr/share/snmp/mibs/ /usr/share/mibs/ietf' \
    --run-command 'mkdir -p /etc/collectd/collectd.conf.d' \
    -a $OVERCLOUD_IMAGE
}
ass="s">EOI fi # ensure stack user on Undercloud machine has an ssh key ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "if [ ! -e ~/.ssh/id_rsa.pub ]; then ssh-keygen -t rsa -N '' -f ~/.ssh/id_rsa; fi" if [ "$virtual" == "TRUE" ]; then # copy the Undercloud VM's stack user's pub key to # root's auth keys so that Undercloud can control # vm power on the hypervisor ssh ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" "cat /home/stack/.ssh/id_rsa.pub" >> /root/.ssh/authorized_keys INSTACKENV=$CONFIG/instackenv-virt.json # upload instackenv file to Undercloud for virtual deployment scp ${SSH_OPTIONS[@]} $INSTACKENV "stack@$UNDERCLOUD":instackenv.json fi # allow stack to control power management on the hypervisor via sshkey # only if this is a virtual deployment if [ "$virtual" == "TRUE" ]; then ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" <<EOI while read -r line; do stack_key=\${stack_key}\\\\\\\\n\${line} done < <(cat ~/.ssh/id_rsa) stack_key=\$(echo \$stack_key | sed 's/\\\\\\\\n//') sed -i 's~INSERT_STACK_USER_PRIV_KEY~'"\$stack_key"'~' instackenv.json EOI fi # copy stack's ssh key to this users authorized keys ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "cat /home/stack/.ssh/id_rsa.pub" >> ~/.ssh/authorized_keys # disable requiretty for sudo ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" "sed -i 's/Defaults\s*requiretty//'" /etc/sudoers # configure undercloud on Undercloud VM echo "Running undercloud configuration." echo "Logging undercloud configuration to undercloud:/home/stack/apex-undercloud-install.log" ssh -T ${SSH_OPTIONS[@]} "stack@$UNDERCLOUD" << EOI if [[ "$net_isolation_enabled" == "TRUE" ]]; then sed -i 's/#local_ip/local_ip/' undercloud.conf sed -i 's/#network_gateway/network_gateway/' undercloud.conf sed -i 's/#network_cidr/network_cidr/' undercloud.conf sed -i 's/#dhcp_start/dhcp_start/' undercloud.conf sed -i 's/#dhcp_end/dhcp_end/' undercloud.conf sed -i 's/#inspection_iprange/inspection_iprange/' undercloud.conf sed -i 's/#undercloud_debug/undercloud_debug/' undercloud.conf openstack-config --set undercloud.conf DEFAULT local_ip ${admin_network_provisioner_ip}/${admin_network_cidr##*/} openstack-config --set undercloud.conf DEFAULT network_gateway ${admin_network_provisioner_ip} openstack-config --set undercloud.conf DEFAULT network_cidr ${admin_network_cidr} openstack-config --set undercloud.conf DEFAULT dhcp_start ${admin_network_dhcp_range%%,*} openstack-config --set undercloud.conf DEFAULT dhcp_end ${admin_network_dhcp_range##*,} openstack-config --set undercloud.conf DEFAULT inspection_iprange ${admin_network_introspection_range} openstack-config --set undercloud.conf DEFAULT undercloud_debug false openstack-config --set undercloud.conf DEFAULT undercloud_hostname "undercloud.${domain_name}" sudo openstack-config --set /etc/ironic/ironic.conf disk_utils iscsi_verify_attempts 30 sudo openstack-config --set /etc/ironic/ironic.conf disk_partitioner check_device_max_retries 40 fi sudo sed -i '/CephClusterFSID:/c\\ CephClusterFSID: \\x27$(cat /proc/sys/kernel/random/uuid)\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml sudo sed -i '/CephMonKey:/c\\ CephMonKey: \\x27'"\$(ceph-authtool --gen-print-key)"'\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml sudo sed -i '/CephAdminKey:/c\\ CephAdminKey: \\x27'"\$(ceph-authtool --gen-print-key)"'\\x27' /usr/share/openstack-tripleo-heat-templates/environments/storage-environment.yaml # we assume that packages will not need to be updated with undercloud install # and that it will be used only to configure the undercloud # packages updates would need to be handled manually with yum update sudo cp -f /usr/share/diskimage-builder/elements/yum/bin/install-packages /usr/share/diskimage-builder/elements/yum/bin/install-packages.bak cat << 'EOF' | sudo tee /usr/share/diskimage-builder/elements/yum/bin/install-packages > /dev/null #!/bin/sh exit 0 EOF openstack undercloud install &> apex-undercloud-install.log || { # cat the undercloud install log incase it fails echo "ERROR: openstack undercloud install has failed. Dumping Log:" cat apex-undercloud-install.log exit 1 } sleep 30 sudo systemctl restart openstack-glance-api # Set nova domain name sudo openstack-config --set /etc/nova/nova.conf DEFAULT dns_domain ${domain_name} sudo openstack-config --set /etc/nova/nova.conf DEFAULT dhcp_domain ${domain_name} sudo systemctl restart openstack-nova-conductor sudo systemctl restart openstack-nova-compute sudo systemctl restart openstack-nova-api sudo systemctl restart openstack-nova-scheduler # Set neutron domain name sudo openstack-config --set /etc/neutron/neutron.conf DEFAULT dns_domain ${domain_name} sudo systemctl restart neutron-server sudo systemctl restart neutron-dhcp-agent sudo sed -i '/num_engine_workers/c\num_engine_workers = 2' /etc/heat/heat.conf sudo sed -i '/#workers\s=/c\workers = 2' /etc/heat/heat.conf sudo systemctl restart openstack-heat-engine sudo systemctl restart openstack-heat-api EOI # configure external network ssh -T ${SSH_OPTIONS[@]} "root@$UNDERCLOUD" << EOI if [[ "$public_network_vlan" != "native" ]]; then cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-vlan${public_network_vlan} DEVICE=vlan${public_network_vlan} ONBOOT=yes DEVICETYPE=ovs TYPE=OVSIntPort BOOTPROTO=static IPADDR=${public_network_provisioner_ip} PREFIX=${public_network_cidr##*/} OVS_BRIDGE=br-ctlplane OVS_OPTIONS="tag=${public_network_vlan}" EOF ifup vlan${public_network_vlan} else if ! ip a s eth2 | grep ${public_network_provisioner_ip} > /dev/null; then ip a a ${public_network_provisioner_ip}/${public_network_cidr##*/} dev eth2 ip link set up dev eth2 fi fi EOI # WORKAROUND: must restart the above services to fix sync problem with nova compute manager # TODO: revisit and file a bug if necessary. This should eventually be removed # as well as glance api problem echo -e "${blue}INFO: Sleeping 15 seconds while services come back from restart${reset}" sleep 15 }