Sunday, February 14, 2016

Setup Swift as Glance backend on RDO Liberty (CentOS 7.2)

Post bellow presumes that your testing Swift storage is located  somewhere
on workstation (say /dev/sdb1) is about 25 GB (XFS) and before running packstack (AIO mode for testing)  following steps have been done :-


# yum install -y https://www.rdoproject.org/repos/rdo-release.rpm
# yum update -y
# yum install -y openstack-packstack

To get swift account installed preinstall packages, it does no harm to
packstack during runtime
# yum install -y \
openstack-swift-object openstack-swift-container \
openstack-swift-account openstack-swift-proxy openstack-utils \
rsync xfsprogs

mkfs.xfs /dev/sdb1
mkdir -p /srv/node/sdb1
echo "/dev/sdb1 /srv/node/sdb1 xfs defaults 1 2" >> /etc/fstab
mount -a
chown -R swift:swift /srv/node
restorecon -R /srv/node

*********************************************
Schema with 2 replicas on single host :-
*********************************************

mkfs.xfs /dev/sdb6
mkdir -p /srv/node/sdb6
echo "/dev/sdb6 /srv/node/sdb6 xfs defaults 1 2" >> /etc/fstab

mkfs.xfs /dev/sda6
mkdir -p /srv/node/sda6
echo "/dev/sda6 /srv/node/sda6 xfs defaults 1 2" >> /etc/fstab

mount -a
chown -R swift:swift /srv/node
restorecon -R /srv/node

*****************
Answer-file :-
*****************

CONFIG_SWIFT_INSTALL=y
CONFIG_SWIFT_KS_PW=7de571599d894b86
CONFIG_SWIFT_STORAGES=/dev/sdb6,/dev/sda6
CONFIG_SWIFT_STORAGE_ZONES=2
CONFIG_SWIFT_STORAGE_REPLICAS=2
CONFIG_SWIFT_STORAGE_FSTYPE=xfs
CONFIG_SWIFT_HASH=eb150786b84346dd
CONFIG_SWIFT_STORAGE_SIZE=50G


would work as well.

So , that  CONFIG_SWIFT_STORAGES=/dev/sdb1 was set before run packstack

When done update /etc/glance/glance-api.conf like it has been done bellow :-
192.168.1.47  is IP of my Controller (Keystone hosting Node )

[DEFAULT]
show_image_direct_url=False
bind_host=0.0.0.0
bind_port=9292
workers=4
backlog=4096
image_cache_dir=/var/lib/glance/image-cache
registry_host=0.0.0.0
registry_port=9191
registry_client_protocol=http
debug=False
verbose=True
log_file=/var/log/glance/api.log
log_dir=/var/log/glance
use_syslog=False
syslog_log_facility=LOG_USER
use_stderr=True
notification_driver =messaging
amqp_durable_queues=False
# default_store = swift
# swift_store_auth_address = http://192.168.1.47:5000/v2.0/
# swift_store_user = services:glance
# swift_store_key = 6bc67e33258c4228
# swift_store_create_container_on_put = True
# stores=glance.store.swift.Store
[database]
connection=mysql://glance:c6ce03f4464c45cc@192.168.1.47/glance
idle_timeout=3600

[glance_store]
default_store = swift
stores = glance.store.swift.Store
swift_store_auth_address = http://192.168.1.47:5000/v2.0/
swift_store_user = services:glance
swift_store_key = 6bc67e33258c4228
swift_store_create_container_on_put = True
os_region_name=RegionOne

[image_format]
[keystone_authtoken]
auth_uri=http://192.168.1.47:5000/v2.0
identity_uri=http://192.168.1.47:35357
admin_user=glance
admin_password=6bc67e33258c4228
admin_tenant_name=services
[matchmaker_redis]
[matchmaker_ring]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_qpid]
[oslo_messaging_rabbit]
rabbit_host=192.168.1.47
rabbit_port=5672
rabbit_hosts=192.168.1.47:5672
rabbit_use_ssl=False
rabbit_userid=guest
rabbit_password=guest
rabbit_virtual_host=/
rabbit_ha_queues=False
heartbeat_timeout_threshold=0
heartbeat_rate=2
rabbit_notification_exchange=glance
rabbit_notification_topic=notifications
[oslo_policy]
[paste_deploy]
flavor=keystone
[store_type_location_strategy]
[task]
[taskflow_executor]

Lines commented out are suggested by  [ 1 ], however to succeed finally
we would have follow [ 2 ].

Also  per [ 1 ] run as admin :-

# keystone user-role-add --tenant_id=$UUID_SERVICES_TENANT \
  --user=$UUID_GLANCE_USER --role=$UUID_ResellerAdmin_ROLE

In particular case :-

[root@ServerCentOS7 ~(keystone_admin)]# keystone tenant-list | grep services
 | 6bbac43abaf04cefb53c259a6afc285b |   services  |   True  |

[root@ServerCentOS7 ~(keystone_admin)]# keystone user-list | grep glance
| 99ed8b1fbd1c428f917f570d4cae75f4 |   glance   |   True  |   glance@localhost   |

[root@ServerCentOS7 ~(keystone_admin)]# keystone role-list | grep ResellerAdmin
| e229166b8ab24900933c23ea88c8b673 |  ResellerAdmin   |


# keystone user-role-add --tenant_id=6bbac43abaf04cefb53c259a6afc285b  \       
    --user=99ed8b1fbd1c428f917f570d4cae75f4  \
    --role=e229166b8ab24900933c23ea88c8b673


Value 6bc67e33258c4228  is corresponding CONFIG_GLANCE_KS_PW

***************
Next step is
***************

# openstack-service restart glance

# [root@ServerCentOS72 ~(keystone_admin)]# systemctl | grep glance
openstack-glance-api.service                                                        loaded active running   OpenStack Image Service (code-named Glance) API server
openstack-glance-registry.service                                                   loaded active running   OpenStack Image Service (code-named Glance) Registry server


what will result your swift storage to work as you glance back end on RDO Liberty (CentOS 7.2)

Verification of updates done to glance-api.conf

# wget https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
 
Then run as admin :-
 
# glance image-create --name ubuntu-trusty-x86_64 --disk-format=qcow2 \ 
  --container-format=bare --file trusty-server-cloudimg-amd64-disk1.img \
  --progress
 
Create keystonerc_glance as shown on snapshots to make sure,that now glance is
is uploading glance and sahara images to Swift Object Storage
 
# cat  keystonerc_glance
export OS_USERNAME=glance
export OS_PASSWORD=6bc67e33258c4228
export OS_TENANT_NAME=services
export OS_AUTH_URL=http://192.168.1.47:5000/v2.0
export PS1='[\u@\h \W(keystone_glance)]\$ '
export OS_REGION_NAME=RegionOne
 
 
 
 Same file sahara-liberty-vanilla-2.7.1-ubuntu-14.04.qcow2 uploaded via `glance image-create`
 on i7 4790,16 GB box doesn't get fragmented 
 
[root@ServerCentOS7 ~(keystone_glance)]# glance image-list
+--------------------------------------+--------------------------------------+
| ID                                   | Name                                 |
+--------------------------------------+--------------------------------------+
| 74f3460e-489f-4e5f-8f37-ada1db576c67 | sahara-liberty-vanilla271-ubuntu1404 |
+--------------------------------------+--------------------------------------+
[root@ServerCentOS7 ~(keystone_glance)]# swift list glance
74f3460e-489f-4e5f-8f37-ada1db576c67
 
You can force fragmentation via adding to 
 
[glance_store]
. . . . . . . 
 
swift_store_large_object_size = 5120
swift_store_large_object_chunk_size = 200
swift_enable_snet = False 
 
 
 
  References 
  1. https://www.rdoproject.org/storage/Swift/Liberty/using-swift-for-glance-with-rdo-liberty/ 
  2. http://magicalyak.org/2015/03/20/using-swift-backend-for-glance-on-ubuntu-openstack/