Add support for CentOS

This change aims to add the foundations for CentOS support
on manila-image-elements.

In this patch-set, the following has been modified

- Added elements for manila-centos-minimal
- Added elements for centos-nfs
- Added elements for centos-cifs
- Renamed all elements for the different protocols to distro-protocol
to facilitate automation
- Modified the main script to take the distro param

Follow-up patches will add centos-based elements
for all other protocols supported.

Change-Id: Ie1469a8b3973b9a15c3fa27688df3b7e7e8da688
Partial-Bug: #1675538
changes/58/450458/4
Victoria Martinez de la Cruz 2017-03-27 22:17:01 +00:00
parent 264e7278e2
commit 375ddd1e9e
22 changed files with 123 additions and 13 deletions

View File

@ -25,6 +25,7 @@ MANILA_IMG_NAME=${MANILA_IMG_NAME:-"manila-service-image"}
# Manila image creation default
MANILA_SHARE_PROTO=${MANILA_SHARE_PROTO:-"default"}
MANILA_DISTRO=${MANILA_DISTRO:-"ubuntu"}
# Path to elements
SCRIPT_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@ -54,23 +55,32 @@ err() {
}
print_usage() {
echo "Usage: ${0##*/} [-s share-proto] [-h]"
echo "Usage: ${0##*/} [-s share-proto] [-d distro] [-h]"
echo "Options:"
echo " -s | --share-proto: name of the share protocol. \
Possible options are nfs, nfs-ganesha, cifs or zfs"
echo " -d | --distro: name of the Linux distro. \
Possible options are ubuntu or centos"
echo " -h | --help: print this usage message and exit"
echo ""
echo "Usage example: manila_image_elements -s nfs"
}
valid_share_protocol(){
if [ "${MANILA_SHARE_PROTO}" != "nfs" ] && [ "${MANILA_SHARE_PROTO}" != "nfs-ganesha" ] &&
valid_share_protocol() {
if [ "${MANILA_SHARE_PROTO}" != "nfs" ] && [ "${MANILA_SHARE_PROTO}" != "nfs-ganesha" ] &&
[ "${MANILA_SHARE_PROTO}" != "cifs" ] && [ "${MANILA_SHARE_PROTO}" != "zfs" ]; then
err "Protocol ${MANILA_SHARE_PROTO} not supported. Valid options are nfs, nfs-ganesha, cifs or zfs."
exit 1
fi
}
valid_distro() {
if ["${MANILA_DISTRO}" != "ubuntu" ] && [ "${MANILA_DISTRO}" != "centos" ]; then
err "Distro ${MANILA_DISTRO} not supported. Valid options are ubuntu or centos."
exit 1
fi
}
parse_arguments() {
while [[ $# > 0 ]]; do
case "$1" in
@ -79,6 +89,12 @@ parse_arguments() {
valid_share_protocol
shift 2
;;
-d|--distro)
export MANILA_DISTRO=$2
export MANILA_IMG_OS=manila-$2-minimal
valid_distro
shift 2
;;
-h|--help)
print_usage
exit 0
@ -93,27 +109,24 @@ parse_arguments() {
# Verify configuration
# --------------------
REQUIRED_ELEMENTS="manila-ssh vm $MANILA_IMG_OS dhcp-all-interfaces"
IMAGE_FORMAT="qcow2"
OPTIONAL_ELEMENTS=
OPTIONAL_DIB_ARGS=
configure() {
REQUIRED_ELEMENTS="manila-ssh vm $MANILA_IMG_OS dhcp-all-interfaces"
IMAGE_FORMAT="qcow2"
OPTIONAL_ELEMENTS=
OPTIONAL_DIB_ARGS=
if [ "$MANILA_SHARE_PROTO" = "default" ]; then
# NOTE(vkmc) Generic driver uses 2 protocols by default
# NFS and CIFS. This is required by the gate.
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS manila-nfs manila-cifs"
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS ${MANILA_DISTRO}-nfs ${MANILA_DISTRO}-cifs"
elif [ "$MANILA_SHARE_PROTO" = "nfs" ]; then
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS manila-nfs"
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS ${MANILA_DISTRO}-nfs"
elif [ "$MANILA_SHARE_PROTO" = "nfs-ganesha" ]; then
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS manila-nfs-ganesha"
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS ${MANILA_DISTRO}-nfs-ganesha"
elif [ "$MANILA_SHARE_PROTO" = "cifs" ]; then
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS manila-cifs"
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS ${MANILA_DISTRO}-cifs"
elif [ "$MANILA_SHARE_PROTO" = "zfs" ]; then
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS manila-zfs"
OPTIONAL_ELEMENTS="$OPTIONAL_ELEMENTS ${MANILA_DISTRO}-zfs"
fi
if [ "$USE_OFFLINE_MODE" = "yes" ]; then

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -eu
yum -y samba cifs-utils

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Enable and start Samba server
systemctl enable smb.service
systemctl start smb.service

View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Install required packages
yum -y install nfs-utils

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Enable and start NFS server
systemctl enable nfs-server.service
systemctl start nfs-server.service

View File

@ -0,0 +1,5 @@
=====================
manila-centos-minimal
=====================
Create a minimal image based on CentOS.

View File

@ -0,0 +1 @@
centos-minimal

View File

@ -0,0 +1 @@
operating-system

View File

@ -0,0 +1,8 @@
openssh-server:
sudo:
rpcbind:
vim:
iptables:
iputils:
net-tools:
python:

View File

@ -0,0 +1,11 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Set 'bash' as default shell for 'manila' user.
useradd -m manila -s /bin/bash
passwd manila

View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
yum -y update

View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
DIB_DISTRIBUTION_MIRROR=${DIB_DISTRIBUTION_MIRROR:-}
[ -n "$DIB_DISTRIBUTION_MIRROR" ] || exit 0
# Only set the mirror for the Base, Extras and Updates repositories
# The others arn't enabled and do not exist on all mirrors
sed -e "s|^#baseurl=http://mirror.centos.org/centos|baseurl=$DIB_DISTRIBUTION_MIRROR|;/^mirrorlist=/d" -i /etc/yum.repos.d/CentOS-Base.repo

View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
# Enable registry in samba config
sed -i "s/\[global\]/\[global\]\\n\\n include = registry\\n/g" /etc/samba/smb.conf