From ce3ea63680117509262bc86ed3474a4b7a7c097b Mon Sep 17 00:00:00 2001 From: linggao Date: Sat, 30 Mar 2013 21:14:20 +0000 Subject: [PATCH] Openstack support git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15740 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/setup_openstack_repo | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 xCAT/postscripts/setup_openstack_repo diff --git a/xCAT/postscripts/setup_openstack_repo b/xCAT/postscripts/setup_openstack_repo new file mode 100755 index 000000000..67b8df4b4 --- /dev/null +++ b/xCAT/postscripts/setup_openstack_repo @@ -0,0 +1,76 @@ +#!/bin/sh +# IBM(c) 2013 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------------------------------- +#=head1 setup_openstack_repo +#=head2 This command adds the OpenStack repository to the node. It is run +# as a postscript. +# Usage: +# setup_openstack_repo +# +#=cut +#------------------------------------------------------------------------------- + +pmatch () +{ + case $1 in + $2) return 0;; # zero return code means string matched by pattern + esac + + return 1 # non-zero return code means string not matched by pattern +} + +# is_lsb_ubuntu exit status indicates whether system appears to be Ubuntu. +# Using required /etc/lsb-release file, instead of optional lsb_release command. +is_lsb_ubuntu () +{ + awk ' + (match($0, "^[ \t]*DISTRIB_ID=") == 1) { # A DISTRIB_ID line + id = substr($0, RLENGTH + 1) # Save its value + } + + END { + # Examine last DISTRIB_ID value to see if Ubuntu indicated + + if (match(id, "^(Ubuntu|\"Ubuntu\")[ \t]*$") == 1) { + exit 0 # Ubuntu + } + exit 1 # Not Ubuntu + } + + ' /etc/lsb-release >/dev/null 2>&1 + + # Routine exit status is exit status of the last command -- the awk script. + # + # Note: if /etc/lsb-release does not exist, the exit status indicates + # failure (not Ubuntu), which is the correct outcome. +} + +if [ "$(uname -s)" = "Linux" ]; then + if ( pmatch "$OSVER" "ubuntu*" ) || ( is_lsb_ubuntu ); then + #add the OpenStack Folsom (2012.2.*) version for Ubunto 12.04.2 to the repository + urelease="precise" #default release name + urelease=`cat /etc/lsb-release |grep DISTRIB_CODENAME |cut -d= -f2` + + echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main" > /etc/apt/sources.list.d/folsom.list + + #Refresh the repository + apt-get install ubuntu-cloud-keyring -y + apt-get update + + echo "Added the OpenStack Folsom version for Ubunto 12.04.2 to the repository, Please modify this script if you need a different version." + + elif ( pmatch "$OSVER" "rh*" ) || [ -f /etc/redhat-release ]; then + #use yum repository + echo "Redhat TODO". + else + echo "OpenStack deployment with xCAT is not supported on this platform yet.". + fi +else + echo "OpenStack is not supported on this platform." +fi + + + + + +