VScaler: CIX Controller Node OpenStack Installation - Glance

From Define Wiki
Jump to navigation Jump to search

Glance Image Service

  • 4_vscaler-controller-glance.sh
#!/bin/bash

# System prep notes
# - selinux disabled
# - firewalld running and allowing internal forwarding of traffic (compute nodes can access repos)
# - headnode /etc/hosts added entry for headnode, make sure the name 'controller' resolves the headnode also[root@head ~]# vi /etc/hosts
#   [root@head ~]# ping -c 1 controller
#   PING head.ohpc.keele.net (10.10.10.1) 56(84) bytes of data.
#   64 bytes from head.ohpc.keele.net (10.10.10.1): icmp_seq=1 ttl=64 time=0.082 ms
# - enable ntpd on compute nodes; systemctl enable  ntpd ; systemctl start  ntpd
# - disable the epel and ohpc repo 
#   yum-config-manager --disable epel epel-testing OpenHPC_1.0
#   [root@node02 yum.repos.d]# grep enable epel* OpenHPC\:1.0.repo
#   epel-testing.repo:enabled=0                                                                     
#   epel-testing.repo:enabled=0                                                                    
#   epel-testing.repo:enabled=0                                              
#   epel.repo:enabled=0                                                                              
#   epel.repo:enabled=0                                                                              
#   epel.repo:enabled=0                                                                              
#   OpenHPC:1.0.repo:enabled=0

# source the vscaler installation vars 
. vscaler-env.sh

# disable repos that will muck stuff up
yum-config-manager --disable epel epel-testing OpenHPC_1.1

#–------------------------------
# setup the glance image service
#-------------------------------
echo "---------------------"
echo "   Creating the DB   "
echo "---------------------"

mysql -u root --password=$VS_PASS <<MYSQL_SCRIPT 
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '$GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '$GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'$HOSTNAME' IDENTIFIED BY '$GLANCE_DBPASS';
MYSQL_SCRIPT
source ~/admin-openrc.sh

echo "---------------------"
echo "  Setup the projects "
echo "---------------------"

#Create the service credentials, complete these steps
openstack user create --domain default --password $GLANCE_PASS glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "OpenStack Image service" image
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292

echo "---------------------"
echo "   Install Apps"
echo "---------------------"

yum -y install openstack-glance python-glance python-glanceclient

sleep 1;

echo "---------------------"
echo "   Edit the configuration files"
echo "---------------------"

crudini --set /etc/glance/glance-api.conf database connection mysql://glance:$GLANCE_DBPASS@controller/glance
crudini --del /etc/glance/glance-api.conf keystone_authtoken
crudini --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000
crudini --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:35357
crudini --set /etc/glance/glance-api.conf keystone_authtoken auth_plugin password
crudini --set /etc/glance/glance-api.conf keystone_authtoken project_domain_id default
crudini --set /etc/glance/glance-api.conf keystone_authtoken user_domain_id default
crudini --set /etc/glance/glance-api.conf keystone_authtoken project_name service
crudini --set /etc/glance/glance-api.conf keystone_authtoken username glance
crudini --set /etc/glance/glance-api.conf keystone_authtoken password $GLANCE_PASS
crudini --set /etc/glance/glance-api.conf paste_deploy flavor keystone
crudini --set /etc/glance/glance-api.conf glance_store default_store file
crudini --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
crudini --set /etc/glance/glance-api.conf DEFAULT notification_driver noop
crudini --set /etc/glance/glance-api.conf DEFAULT verbose True

crudini --set /etc/glance/glance-registry.conf database connection mysql://glance:$GLANCE_DBPASS@controller/glance
crudini --del /etc/glance/glance-registry.conf keystone_authtoken
crudini --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000
crudini --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:35357
crudini --set /etc/glance/glance-registry.conf keystone_authtoken auth_plugin password
crudini --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_id default
crudini --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_id default
crudini --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
crudini --set /etc/glance/glance-registry.conf keystone_authtoken username glance
crudini --set /etc/glance/glance-registry.conf keystone_authtoken password $GLANCE_PASS
crudini --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
crudini --set /etc/glance/glance-registry.conf DEFAULT notification_driver noop
crudini --set /etc/glance/glance-registry.conf DEFAULT verbose True

echo "---------------------"
echo "   Populate the glance DB"
echo "---------------------"

su -s /bin/sh -c "glance-manage db_sync" glance

echo "---------------------"
echo "   Enable Restart the services"
echo "---------------------"
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service

echo "---------------------"
echo "  Verify the glance service "
echo "---------------------"
sleep 1;

# verify the glance operation 
echo "export OS_IMAGE_API_VERSION=2"  | tee -a ~/admin-openrc.sh ~/vscaler-openrc.sh
source admin-openrc.sh
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
glance image-create --name "cirros" \
  --file cirros-0.3.4-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --visibility public --progress

glance image-list