Cherry-pick the following commits from release-0.4

* Add forgotten return statements
	Closes-bug: #1268934

* Fix error code when there is no input json

* Return correct http code

	During toggle enabled 500 was sent in case service is not defined
	Fix return code to 404
	Closes-Bug: #1268976

* Remove need to specify IP for load balancer
	Implements:
	   https://blueprints.launchpad.net/murano/+spec/auto-assign-virtual-ip
	Address blueprint auto-assign-virtual-ip
	Fix errors in infrastructure
	1) Update path to config file
	2) Update sample config - remove non-existing directory
	3) Add 0.4.1 version
	Fixes-Bug: 1270734

* Add new setup and SysV scripts

* Removed SysV EL6 standalone file, removed old setup scripts

* Add correct error message when no config specified
	Closes-Bug: 1271092

* Security rules updated
	* incorrect port ranges for ADDS fixed according to
	http://technet.microsoft.com/en-us/library/dd772723%28v=WS.10%29.aspx
	* security template for Windows Server Failover Cluster added according to
	http://support.microsoft.com/kb/832017#method5
	* security rules for SQL Server updated according to
	http://technet.microsoft.com/en-us/library/cc646023.aspx

	Relates-Bug: 1264088

* Typo fixed

* Revert change
	This reverts commit d87bc2309f.

* Path flattening is reverted, but opening ports for WinRM 2.0 is kept.
	Related-Bug: #1271578

* Fix paths to scripts used by MS SQL Cluster templates.
	Partial-Bug: #1271578

* Fix returning list of files in nested dirs - don't cut first symbol.

* And fix a minor PyCharm warning about var not being initialized.
	Closes-Bug: #1274851

* Add checkbox to enable floating IP auto assignment

* Implements blueprint auto-assign-floating-ip

* Fixed typo in conductor workflow
	Closes-Bug: 1264250

* Add service version during service creation
	Closes-Bug: 1269360

* Resolve issue with KeyPair assignment
	nvironment with a service with Key Pair assigned
	could not be deployed due to invalid match in workflows
	causing invalid Heat template to be produced by Conductor.
	Closes-bug: #1274011

* Correct inform message during floating ip creation

* Fix name for syslog_log_facility param

Change-Id: Id3ad4581cd9ce40a569ac580d0aee8db017855c4
This commit is contained in:
Ekaterina Fedorova 2014-01-14 16:40:00 +04:00 committed by Gerrit Code Review
parent 1fcfbce635
commit d353dacf8e
51 changed files with 1601 additions and 707 deletions

View File

@ -5,6 +5,10 @@ Repository with murano metadata
Murano project on launchpad https://launchpad.net/murano
INSTALL FROM SOURCE
=====================
Please, use setup.sh script with root user privileges for install/uninstall of the software.
License
-------
Copyright (c) 2013 Mirantis Inc.

379
common.inc Normal file
View File

@ -0,0 +1,379 @@
#!/bin/bash
#
# Common functions file
#
DEBUGLVL=2
RUN_DIR=${RUN_DIR:-$(cd $(dirname "$0") && pwd)}
LOGFILE="$RUN_DIR/install.log"
PIPAPPS="pip python-pip pip-python"
PIPCMD=""
PIPARGS=""
TRBL_FILE=""
if [ "$DEBUGLVL" -eq 4 ]; then
set -x
fi
function log {
if [ "$DEBUGLVL" -gt 0 ]; then
chars=$(echo "@$" | wc -c)
case $DEBUGLVL in
1)
echo -e "LOG:>$@"
;;
2)
echo -e "$(date +"%m-%d-%Y %H:%M") LOG:>$@" | tee --append $LOGFILE
;;
3)
echo -e "$(date +"%m-%d-%Y %H:%M") LOG:>$@" >> $LOGFILE
;;
4)
echo -e "$(date +"%m-%d-%Y %H:%M") LOG:>$@" | tee --append $LOGFILE
;;
esac
fi
}
function lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
function get_os(){
KERNEL=$(uname -r)
MACH=$(uname -m)
OS=$(uname)
if [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DISTRO_BASED_ON='RedHat'
PACKAGER='yum'
PKG_MGR='rpm'
DIST=$(cat /etc/redhat-release |sed s/\ release.*//)
PSUEDONAME=$(cat /etc/redhat-release | sed s/.*\(// | sed s/\)//)
REV=$(cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//)
elif [ -f /etc/SuSE-release ] ; then
DISTRO_BASED_ON='SuSe'
PACKAGER='zypper'
PKG_MGR='rpm'
PSUEDONAME=$(cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//)
REV=$(cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //)
elif [ -f /etc/debian_version ] ; then
DISTRO_BASED_ON='Debian'
PACKAGER='apt-get'
PKG_MGR='dpkg'
DIST=$(cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }')
PSUEDONAME=$(cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }')
REV=$(cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }')
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[$(cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//)]"
fi
OS=$(lowercase $OS)
DISTRO_BASED_ON=$(lowercase $DISTRO_BASED_ON)
readonly OS
readonly DIST
readonly DISTRO_BASED_ON
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
#readonly PACKAGER
else
OS=unknown
readonly OS
log "Unsupported OS:\"$OS\", sorry, exiting!"
exit 1
fi
}
function find_or_install()
{
_searching_for=$1
_pkg_mrg_cmd=''
_pkgr_cmd=''
retval=0
case $(lowercase $DISTRO_BASED_ON) in
"debian")
_pkg_mrg_cmd="$PKG_MGR -s $_searching_for"
_pkgr_cmd="$PACKAGER install $_searching_for --yes"
;;
*)
_pkg_mrg_cmd="$PKG_MGR -q $_searching_for"
_pkgr_cmd="$PACKAGER install $_searching_for -y"
;;
esac
$_pkg_mrg_cmd > /dev/null 2>&1
if [ $? -eq 0 ]; then
log "Package \"$_searching_for\" already installed"
retval=2
else
log "Installing \"$_searching_for\"..."
$_pkgr_cmd > /dev/null 2>&1
if [ $? -ne 0 ];then
log "...installation fails, exiting!"
retval=1
else
log "...success"
retval=0
fi
fi
return $retval
}
function is_py_package_installed()
{
retval=0
py_pkg=$1
found_pkg=$($PIPCMD freeze | grep -E "^$py_pkg")
if [ $? -ne 0 ]; then
retval=1
fi
echo $found_pkg
return $retval
}
function genpass()
{
echo $(date | md5sum |head -c${5:-13})
}
function shslash()
{
echo $1 | sed 's/\//\\\//g'
}
function split()
{
# Prefix local names with the function name to try to avoid conflicts
# local split_wordlist
split_wordlist="$1"
shift
read "$@" <<EOF-split-end-of-arguments
${split_wordlist}
EOF-split-end-of-arguments
}
# Returns true if v1 >= v2, false if v1 < v2
function version_ge()
{
# Prefix local names with the function name to try to avoid conflicts
# local version_ge_1 version_ge_2 version_ge_a version_ge_b
# local version_ge_save_ifs
version_ge_v1="$1"
version_ge_v2="$2"
version_ge_save_ifs="$IFS"
while test -n "${version_ge_v1}${version_ge_v2}"; do
IFS="."
split "$version_ge_v1" version_ge_a version_ge_v1
split "$version_ge_v2" version_ge_b version_ge_v2
IFS="$version_ge_save_ifs"
#echo " compare $version_ge_a $version_ge_b"
test "0$version_ge_a" -gt "0$version_ge_b" && return 0 # v1>v2: true
test "0$version_ge_a" -lt "0$version_ge_b" && return 1 # v1<v2:false
done
# version strings are both empty & no differences found - must be equal.
return 0 # v1==v2: true
}
function find_pip()
{
_pipargs=""
pip_min_ver="1.4"
for cmd in $PIPAPPS
do
_cmd=$(which $cmd 2>/dev/null)
if [ $? -eq 0 ];then
break
fi
done
if [ -z "$_cmd" ];then
echo "Can't find \"pip\" in system, please install it first, exiting!"
exit 1
else
_pip_ver=$($_cmd --version | grep -oE "[0-9]\.[0-9]" | head -n1)
if [ -n "$_pip_ver" ]; then
version_ge $_pip_ver $pip_min_ver
if [ $? -ne 0 ]; then
log "Upgrading pip ..."
$_cmd install --upgrade pip==$pip_min_ver
if [ $? -ne 0 ]; then
log "...pip upgrade fails, exiting!"
exit 1
else
log "...success"
sleep 2
for cmd in $PIPAPPS
do
_cmd=$(which $cmd 2>/dev/null)
if [ $? -eq 0 ];then
break
fi
done
fi
fi
_pip_ver=$($_cmd --version | grep -oE "[0-9]\.[0-9]" | head -n1)
version_ge $_pip_ver "1.5"
if [ $? -eq 0 ]; then
log "For future use, sorry, use pip v$pip_min_ver, exiting!"
exit 1
##_pipargs="--allow-unverified --allow-external"
#_pipargs="--allow-all-external"
#mk_dir "/root/.pip"
#_pipcfg="/root/.pip/pip.conf"
#if [ ! -f "$_pipcfg" ]; then
# touch $_pipcfg
#fi
#iniset 'install' 'allow-all-external' 'true' "$_pipcfg"
#iniset 'install' 'allow-all-unverified' 'true' "$_pipcfg"
#log "Setuptools upgrade required..."
#$cmd install setuptools --no-use-wheel --upgrade >> $LOGFILE 2>&1
#if [ $? -ne 0 ]; then
# log "...upgrade fails, exiting"
# exit 1
#else
# log "...success"
#fi
fi
log "Found pip version - $_pip_ver"
fi
PIPARGS=$_pipargs
PIPCMD=$_cmd
fi
}
function add_daemon_credentials()
{
retval=0
daemonuser=${1:-murano}
daemongroup=${2:-murano}
daemonhomedir=${3:-/home/$daemonuser}
getent group $daemongroup > /dev/null
if [ $? -ne 0 ]; then
log "Creating group \"$daemongroup\"..."
groupadd -r $daemongroup
if [ $? -eq 0 ]; then
log "...success"
else
log "Can't create \"$daemongroup\", exiting!"
retval=1
exit 1
fi
else
log "Group \"$daemongroup\" exists"
fi
getent passwd $daemonuser > /dev/null
if [ $? -ne 0 ]; then
log "Creating user \"$daemonuser\"..."
useradd -r -g $daemongroup -G $daemongroup -d $daemonhomedir -s $(which nologin) -c "Murano Daemons" $daemonuser
if [ $? -eq 0 ]; then
log "...success"
else
log "Can't create \"$daemonuser\", exiting!"
retval=1
exit 1
fi
else
log "User \"$daemonuser\" exists"
fi
return $retval
}
function remove_daemon_credentials()
{
retval=0
daemonuser=${1:-murano}
daemongroup=${2:-murano}
daemonhomedir=${3:-/home/$daemonuser}
getent passwd $daemonuser > /dev/null
if [ $? -eq 0 ]; then
log "Deleting user \"$daemonuser\"..."
userdel -f $daemonuser
if [ $? -eq 0 ]; then
if [ -d "$daemonhomedir" ]; then
rm -rf $daemonhomedir
fi
log "...success"
else
log "Can't delete \"$daemonuser\", exiting!"
retval=1
exit 1
fi
fi
getent group $daemongroup > /dev/null
if [ $? -eq 0 ]; then
log "Deleting group \"$daemongroup\"..."
groupdel $daemongroup
if [ $? -eq 0 ]; then
log "...success"
else
log "Can't delete \"$daemongroup\", exiting!"
retval=1
exit 1
fi
fi
return $retval
}
function iniset()
{
local section=$1
local option=$2
local value=$3
local file=$4
local line
if [ -z "$section" ] ; then
# No section name specified
sed -i -e "s/^\($option[ \t]*=[ \t]*\).*$/\1$value/" "$file"
else
# Check if section already exists
if ! grep -q "^\[$section\]" "$file" ; then
# Add section at the end
echo -e "\n[$section]" >>"$file"
fi
# Check if parameter in the section exists
line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
if [ -z "$line" ] ; then
# Add parameter if it is not exists
sed -i -e "/^\[$section\]/ a\\
$option = $value
" "$file"
else
# Replace existing parameter
sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=[ \t]*\).*$|\1$value|" "$file"
fi
fi
}
function mk_dir()
{
retval=0
path_to_check=$1
if [ -d "$path_to_check" ]; then
log "Path \"$path_to_check\" already exists."
elif [ -f "$path_to_check" ]; then
log "Path \"path_to_check\" is an existing file, exiting!"
exit 1
else
mkdir -p "$path_to_check"
if [ $? -ne 0 ]; then
log "Can't create \"$path_to_check\", exiting!"
retval=1
exit 1
fi
fi
if [ $# -eq 3 ]; then
owner_user=$2
owner_group=$3
chown -R $owner_user:$owner_group $path_to_check
if [ $? -ne 0 ]; then
log "Can't set ownership to \"$owner_user:$owner_group\" for \"$path_to_check\", exiting!"
retval=1
exit 1
fi
fi
return $retval
}
function get_service_exec_path()
{
retval=0
if [ -z "$SERVICE_EXEC_PATH" ]; then
SERVICE_EXEC_PATH=$(which $DAEMON_NAME)
if [ $? -ne 0 ]; then
log "Can't find \"$DAEMON_NAME\", please install the \"$SERVICE_SRV_NAME\" by running \"$(basename "$0") install\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
retval=1
fi
else
if [ ! -x "$SERVICE_EXEC_PATH" ]; then
log "\"$SERVICE_EXEC_PATH\" in not executable, please install the \"$DAEMON_NAME\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
retval=1
fi
fi
return $retval
}

4
etc/init.d/README.rst Normal file
View File

@ -0,0 +1,4 @@
SysV init scripts
=====================
murano-repository-redhat - for RedHat based Linux distibution
murano-repository-debian - for Debian based Linux distibution

View File

@ -0,0 +1,104 @@
#!/bin/sh
# Copyright (c) 2014 Mirantis, Inc.
#
# 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.
# Author: Igor Yozhikov <iyozhikov@mirantis.com>
#
### BEGIN INIT INFO
# Provides: murano-repository
# Required-Start: $network $local_fs $remote_fs $syslog
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenStack Murano Respository Service
# Description: This startup script launches murano-repository service daemon.
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="murano-repository"
NAME=murano-repository
DAEMON=$(which murano-repository)
PIDFILE=/var/run/murano/$NAME.pid
SCRIPTNAME=/etc/init.d/openstack-$NAME
SYSTEM_USER=murano
CONFIG_FILE=/etc/murano/murano-repository.conf
# Exit if the package is not installed
[ -x $DAEMON ] || exit 5
# source function library
. /lib/lsb/init-functions
do_start()
{
if [ ! -d "/var/run/murano" ]; then
mkdir -p /var/run/murano
chown -R $SYSTEM_USER /var/run/murano
fi
start-stop-daemon --start --background --quiet --chuid $SYSTEM_USER:$SYSTEM_USER --make-pidfile --pidfile $PIDFILE --startas $DAEMON --test -- --config-file=$CONFIG_FILE > /dev/null || return 1
start-stop-daemon --start --background --quiet --chuid $SYSTEM_USER:$SYSTEM_USER --make-pidfile --pidfile $PIDFILE --startas $DAEMON -- --config-file=$CONFIG_FILE || return 2
}
do_stop()
{
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
RETVAL="$?"
rm -f $PIDFILE
return "$RETVAL"
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) log_end_msg 0 ;;
2) log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac

View File

@ -0,0 +1,102 @@
#!/bin/sh
# Copyright (c) 2014 Mirantis, Inc.
#
# 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.
# Author: Igor Yozhikov <iyozhikov@mirantis.com>
#
### BEGIN INIT INFO
# Provides: murano-repository
# Required-Start: $network $local_fs $remote_fs $syslog
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OpenStack Murano Respository Service
# Description: This startup script launches murano-repository service daemon.
### END INIT INFO
# chkconfig: 3 90 10
# description: This startup script launches murano-repository service daemon.
# config: /etc/murano/murano-repository.conf
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="murano-repository"
NAME=murano-repository
DAEMON=$(which murano-repository)
PIDFILE=/var/run/murano/$NAME.pid
SCRIPTNAME=/etc/init.d/openstack-$NAME
SYSTEM_USER=murano
CONFIG_FILE=/etc/murano/murano-repository.conf
LOCKFILE=/var/lock/subsys/$NAME
# Exit if the package is not installed
[ -x $DAEMON ] || exit 5
# source function library
. /etc/init.d/functions
RETVAL=0
start() {
if [ ! -d "/var/run/murano" ]; then
mkdir -p /var/run/murano
chown -R $SYSTEM_USER /var/run/murano
fi
echo -n "Starting $NAME: "
daemon --user $SYSTEM_USER "$DAEMON --config-file=$CONFIG_FILE &>/dev/null & echo \$! > $PIDFILE"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCKFILE
return $RETVAL
}
stop() {
echo -n "Stopping $NAME: "
#killproc $DAEMON -TERM
killproc -p $PIDFILE $DAEMON
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
return $RETVAL
}
restart() {
stop
start
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $DAEMON
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?

View File

@ -13,8 +13,10 @@ verbose = True
# Show debugging output in logs (sets DEBUG log level output)
debug = True
# Log to this file. Make sure the user has permissions to write to this file!
# Set up logging. To use syslog just set use_syslog parameter value to 'True'.
log_file = /tmp/murano-repository.log
use_syslog = False
syslog_log_facility = LOG_LOCAL0
# Provide information about data types
# absolute or relative path to manifest location(root directory)

View File

@ -1,6 +1,6 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"/ImportCoreFunctions.ps1",
"SQLServerForAOAG.ps1"
],
"Commands": [

View File

@ -1,7 +1,7 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"Start-PowerShellProcess.ps1",
"/ImportCoreFunctions.ps1",
"/Start-PowerShellProcess.ps1",
"Failover-Cluster.ps1"
],
"Commands": [

View File

@ -1,7 +1,7 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"Update-ServiceConfig.ps1",
"/ImportCoreFunctions.ps1",
"/Update-ServiceConfig.ps1",
"SQLServerForAOAG.ps1",
"Failover-Cluster.ps1"
],

View File

@ -1,11 +1,11 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"OptionParser.ps1",
"SQLServer/SQLServerOptionParsers.ps1",
"SQLServer/SQLServerInstaller.ps1",
"Export-Function.ps1",
"Start-PowerShellProcess.ps1",
"/ImportCoreFunctions.ps1",
"/OptionParser.ps1",
"/SQLServer/SQLServerOptionParsers.ps1",
"/SQLServer/SQLServerInstaller.ps1",
"/Export-Function.ps1",
"/Start-PowerShellProcess.ps1",
"SQLServerForAOAG.ps1"
],
"Commands": [

View File

@ -1,11 +1,11 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"OptionParser.ps1",
"SQLServer/SQLServerOptionParsers.ps1",
"SQLServer/SQLServerInstaller.ps1",
"Export-Function.ps1",
"Start-PowerShellProcess.ps1",
"/ImportCoreFunctions.ps1",
"/OptionParser.ps1",
"/SQLServer/SQLServerOptionParsers.ps1",
"/SQLServer/SQLServerInstaller.ps1",
"/Export-Function.ps1",
"/Start-PowerShellProcess.ps1",
"SQLServerForAOAG.ps1"
],
"Commands": [

View File

@ -1,11 +1,11 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"OptionParser.ps1",
"SQLServer/SQLServerOptionParsers.ps1",
"SQLServer/SQLServerInstaller.ps1",
"Export-Function.ps1",
"Start-PowerShellProcess.ps1",
"/ImportCoreFunctions.ps1",
"/OptionParser.ps1",
"/SQLServer/SQLServerOptionParsers.ps1",
"/SQLServer/SQLServerInstaller.ps1",
"/Export-Function.ps1",
"/Start-PowerShellProcess.ps1",
"SQLServerForAOAG.ps1"
],
"Commands": [

View File

@ -1,9 +1,9 @@
{
"Scripts": [
"ImportCoreFunctions.ps1",
"OptionParser.ps1",
"SQLServer/SQLServerOptionParsers.ps1",
"SQLServer/SQLServerInstaller.ps1",
"/ImportCoreFunctions.ps1",
"/OptionParser.ps1",
"/SQLServer/SQLServerOptionParsers.ps1",
"/SQLServer/SQLServerInstaller.ps1",
"SQLServerForAOAG.ps1"
],
"Commands": [

View File

@ -30,6 +30,7 @@ heat:
- DefaultSecurity.template
- WindowsSecurity.template
- WebServerSecurity.template
- FloatingIP.template
agent:
- SetPassword.template

View File

@ -31,6 +31,7 @@ heat:
- DefaultSecurity.template
- WindowsSecurity.template
- WebServerSecurity.template
- FloatingIPwithLB.template
agent:
- SetPassword.template

View File

@ -5,93 +5,135 @@
"Properties": {
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "25",
"ToPort": "25",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "53",
"ToPort": "53",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "53",
"ToPort": "53",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "88",
"ToPort": "88",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "88",
"ToPort": "88",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "123",
"ToPort": "123",
"IpProtocol": "udp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "135",
"ToPort": "135",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "464",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "464",
"IpProtocol": "udp",
"FromPort": "53",
"FromPort": "137",
"ToPort": "137",
"CidrIp": "$cidr"
},
{
"ToPort": "389",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "389",
"IpProtocol": "udp",
"FromPort": "53",
"FromPort": "138",
"ToPort": "138",
"CidrIp": "$cidr"
},
{
"ToPort": "636",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "3268",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "3269",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "53",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "53",
"IpProtocol": "udp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "88",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "88",
"IpProtocol": "udp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"FromPort": "445",
"ToPort": "445",
"IpProtocol": "tcp",
"FromPort": "53",
"CidrIp": "$cidr"
},
{
"ToPort": "65535",
"IpProtocol": "udp",
"FromPort": "445",
"ToPort": "445",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "464",
"ToPort": "464",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "464",
"ToPort": "464",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "389",
"ToPort": "389",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "389",
"ToPort": "389",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "636",
"ToPort": "636",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "3268",
"ToPort": "3268",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "3269",
"ToPort": "3269",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "5722",
"ToPort": "5722",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "9389",
"ToPort": "9389",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "49152",
"ToPort": "65535",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "49152",
"ToPort": "65535",
"CidrIp": "$cidr"
}
]

View File

@ -0,0 +1,24 @@
{
"Resources": {
"${instanceName}-FloatingIP": {
"Type": "OS::Neutron::FloatingIP",
"Properties": {
"floating_network_id": "$externalNetworkId"
}
},
"${instanceName}-FloatingIpAssoc": {
"Type": "OS::Neutron::FloatingIPAssociation",
"Properties": {
"floatingip_id": { "Ref" : "${instanceName}-FloatingIP" },
"port_id": { "Ref" : "$instancePort" }
}
}
},
"Outputs": {
"${instanceName}-FloatingIPaddress": {
"Value": {"Fn::GetAtt": ["${instanceName}-FloatingIP", "floating_ip_address"]},
"Description": "Floating IP assigned"
}
}
}

View File

@ -0,0 +1,23 @@
{
"Resources": {
"${instanceName}-FloatingIP": {
"Type": "OS::Neutron::FloatingIP",
"Properties": {
"floating_network_id": "$externalNetworkId"
}
},
"${instanceName}-FloatingIpAssoc": {
"Type": "OS::Neutron::FloatingIPAssociation",
"Properties": {
"floatingip_id": { "Ref" : "${instanceName}-FloatingIP" },
"port_id": {"Fn::Select": ["port_id", {"Fn::GetAtt": ["${lbName}-Pool", "vip"]}]}
}
}
},
"Outputs": {
"${instanceName}-FloatingIPaddress": {
"Value": {"Fn::GetAtt": ["${instanceName}-FloatingIP", "floating_ip_address"]},
"Description": "Floating IP assigned"
}
}
}

View File

@ -21,7 +21,6 @@
"name": "${lbName}-Pool",
"vip": {
"name": "${lbName}-Pool-VIP",
"address": "$lbIp",
"protocol_port": "$lbPort"
},
"monitors": [{"Ref": "${lbName}-HealthMonitor"}]
@ -35,5 +34,11 @@
"members": [{"Ref": "$instanceName"}]
}
}
},
"Outputs": {
"${lbName}-loadBalancerIp": {
"Value": {"Fn::Select": ["address", {"Fn::GetAtt": ["${lbName}-Pool", "vip"]}]},
"Description": "IP assigned to VIP"
}
}
}

View File

@ -5,22 +5,34 @@
"Properties": {
"SecurityGroupIngress": [
{
"ToPort": "4022",
"IpProtocol": "tcp",
"FromPort": "4022",
"CidrIp": "$cidr"
},
{
"ToPort": "135",
"IpProtocol": "tcp",
"FromPort": "135",
"ToPort": "135",
"CidrIp": "$cidr"
},
{
"ToPort": "1433",
"IpProtocol": "tcp",
"FromPort": "1433",
"ToPort": "1433",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "udp",
"FromPort": "1434",
"ToPort": "1434",
"CidrIp": "0.0.0.0/0"
},
{
"IpProtocol": "tcp",
"FromPort": "4022",
"ToPort": "4022",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "49152",
"ToPort": "65535",
"CidrIp": "$cidr"
}
]
}

View File

@ -0,0 +1,41 @@
{
"Resources": {
"$MuranoSecurityGroup-{envName}": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": "135",
"ToPort": "135",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "137",
"ToPort": "137",
"CidrIp": "$cidr"
},
{
"IpProtocol": "tcp",
"FromPort": "3343",
"ToPort": "3343",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "3343",
"ToPort": "3343",
"CidrIp": "$cidr"
},
{
"IpProtocol": "udp",
"FromPort": "49152",
"ToPort": "65535",
"CidrIp": "$cidr"
}
]
}
}
}
}

View File

@ -31,6 +31,7 @@ heat:
- WebServerSecurity.template
- LinuxSecurity.template
- Keypair.template
- FloatingIP.template
agent:
- DeployApache.template

View File

@ -30,6 +30,7 @@ heat:
- LinuxSecurity.template
- TelnetSecurity.template
- Keypair.template
- FloatingIP.template
agent:
- DeployTelnet.template

View File

@ -31,6 +31,7 @@ heat:
- DefaultSecurity.template
- WindowsSecurity.template
- SQL-security.template
- WSFCSecurity.template
agent:
@ -48,8 +49,8 @@ scripts:
- ImportCoreFunctions.ps1
- Set-LocalUserPassword.ps1
- Update-ServiceConfig.ps1
- SQLServerForAOAG.ps1
- Failover-Cluster.ps1
- SqlServerCluster/SQLServerForAOAG.ps1
- SqlServerCluster/Failover-Cluster.ps1
- Start-PowerShellProcess.ps1
- OptionParser.ps1
- SQLServer/SQLServerOptionParsers.ps1

View File

@ -31,6 +31,7 @@ heat:
- DefaultSecurity.template
- WindowsSecurity.template
- SQL-security.template
- FloatingIP.template
agent:

View File

@ -82,6 +82,16 @@ forms:
type: password
label: Recovery password
attributeNames: false
- name: assignFloatingIP
required: false
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically to Primary DC
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -53,6 +53,16 @@ forms:
errorMessages:
invalid: Enter correct git repository url
helpText: Enter a valid git repository URL
- name: assignFloatingIP
required: false
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -66,11 +66,6 @@ forms:
maxValue: 100
initial: 2
helpText: Enter an integer value between 2 and 100
- name: loadBalancerIp
type: clusterip
label: Load Balancer VIP
description: Specify IP number where Load Balancer will be running
helpText: Enter an free IP address from the subnet where instances will be created
- name: loadBalancerPort
type: integer
label: Load Balancer port
@ -79,6 +74,15 @@ forms:
initial: 80
description: Specify port number where Load Balancer will be running
helpText: Enter an integer value from 1 to 65536
- name: assignFloatingIP
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -27,6 +27,15 @@ forms:
label: Instance Count
description: Several instances with Apache web Service can be created at one time.
helpText: Enter an integer value between 1 and 10
- name: assignFloatingIP
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname

View File

@ -27,6 +27,15 @@ forms:
hidden: true
attributeNames: units
initial: 1
- name: assignFloatingIP
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname

View File

@ -94,6 +94,10 @@ forms:
type: clusterip
label: Cluster Static IP
description: Specify a valid IPv4 fixed IP.
# temporaryHack
widgetMedia:
js: [muranodashboard/js/support_placeholder.js]
css: {all: [muranodashboard/css/support_placeholder.css]}
- name: clusterName
type: string
label: Cluster Name
@ -127,6 +131,10 @@ forms:
errorMessages:
invalid: Just letters, numbers, underscores and hyphens are allowed.
description: User name that will be created to manage cluster instances.
# temporaryHack
widgetMedia:
js: [muranodashboard/js/support_placeholder.js]
css: {all: [muranodashboard/css/support_placeholder.css]}
- name: sqlServicePassword
type: password
label: SQL User Password
@ -140,6 +148,15 @@ forms:
attributeNames: false
helpText: Enter an integer value between 2 and 5
description: Microsoft SQL Failover Cluster includes up to 5 instances.
- name: assignFloatingIP
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -64,6 +64,15 @@ forms:
description: Set system administrator password for the MS SQL Server.
helpText: SQL server System Administrator account
required: {YAQL: $.serviceConfiguration.mixedModeAuth}
- name: assignFloatingIP
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -44,6 +44,15 @@ forms:
Service can be joined to the Active Directory domain. If you want to
create an AD domain create the AD Service first.
helpText: Optional field for a domain to which service can be joined
- name: assignFloatingIP
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -54,11 +54,6 @@ forms:
label: Instance Count
description: Several instances with IIS Service can be created at one time.
helpText: Enter an integer value between 2 and 100
- name: loadBalancerIp
type: clusterip
label: Load Balancer VIP
description: Specify IP number where Load Balancer will be running
helpText: Enter an free IP address from the subnet where instances will be created
- name: loadBalancerPort
type: integer
label: Load Balancer port
@ -67,6 +62,15 @@ forms:
initial: 80
description: Specify port number where Load Balancer will be running
helpText: Enter an integer value from 1 to 65536
- name: assignFloatingIP
required: false
type: floatingip
label: Assign Floating IP
description: >-
Select to true to assign floating IP automatically
initial: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname template

View File

@ -30,6 +30,7 @@ heat:
- DefaultSecurity.template
- WindowsSecurity.template
- WebServerSecurity.template
- FloatingIP.template
agent:
- SetPassword.template

View File

@ -30,6 +30,7 @@ heat:
- DefaultSecurity.template
- WindowsSecurity.template
- WebServerSecurity.template
- FloatingIPwithLB.template
agent:
- SetPassword.template

View File

@ -1,8 +1,8 @@
<workflow>
<rule match="$[?(@.networking.state.ready_for_cf)].services[?(@.type == 'linuxApacheService' and @.keyPair)].units[?(not @.temp.KeyPairMapping)]"
<rule match="$[?(@.networking.state.ready_for_cf)].services[?(@.type == 'linuxApacheService' and @.keyPair)].units[?(@.state.hostname and not @.temp.KeyPairMapping)]"
desc="This rule allows to set Key Pair for all VMs with this service">
<update-cf-stack template="Keypair" result="outputs" error="exception">
<update-cf-stack template="Keypair" error="exception">
<parameter name="mappings">
<map>
<mapping name="instanceName"><select path="state.hostname"/></mapping>
@ -116,7 +116,7 @@
<select path="id"/>
</parameter>
<parameter name="text">
insatalling Apache on unit <select path="state.hostname"/> (<select path="name"/>)
Installing Apache on unit <select path="state.hostname"/> (<select path="name"/>)
</parameter>
</report>
<!-- Commands sequence -->

View File

@ -22,4 +22,36 @@
</rule>
</rule>
<rule match="$[?(@.networking.state.ready_for_cf and @.networking.topology == 'routed')].services[?(@.type not in ('webServerFarm', 'aspNetAppFarm') and @.assignFloatingIP)].units[?(not @.temp.floatingIpAssigned)]"
desc="Units of non-farms services which have no floating assigned yet">
<report entity="unit">
<parameter name="id"><select path="id"/></parameter>
<parameter name="text">Assigning Floating IP to the <select path="state.hostname"/> instance</parameter>
</report>
<update-cf-stack template="FloatingIP" result="outputs" error="exception">
<parameter name="mappings">
<map>
<mapping name="instanceName"><select path="state.hostname"/></mapping>
<mapping name="externalNetworkId"><select path="/networking.floatingId"/></mapping>
<mapping name="instancePort">port-<select path="state.hostname"/></mapping>
</map>
</parameter>
<success>
<set path="temp.floatingIpAssigned"><true/></set>
<set path="floatingip"><select source="outputs"><parameter name="path"><select path="state.hostname"/>-FloatingIPaddress</parameter></select></set>
<report entity="unit">
<parameter name="id"><select path="id"/></parameter>
<parameter name="text">Floating IP has been assigned to <select path="state.hostname"/></parameter>
</report>
</success>
<failure>
<report entity="unit" level="error">
<parameter name="id"><select path="id"/></parameter>
<parameter name="text">Unable to assign floating IP to instance <select path="state.hostname"/> (<select path="name"/>) due to <format-error error="exception"/></parameter>
</report>
<stop/>
</failure>
</update-cf-stack>
</rule>
</workflow>

View File

@ -8,9 +8,9 @@
</set>
</rule>
<rule match="$[?(@.networking.state.ready_for_cf)].services[?(@.type == 'linuxTelnetService' and @.keyPair)].units[?(not @.temp.KeyPairMapping)]"
<rule match="$[?(@.networking.state.ready_for_cf)].services[?(@.type == 'linuxTelnetService' and @.keyPair)].units[?(@.state.hostname and not @.temp.KeyPairMapping)]"
desc="This rule allows to set Key Pair for all VMs with this service">
<update-cf-stack template="Keypair" result="outputs" error="exception">
<update-cf-stack template="Keypair" error="exception">
<parameter name="mappings">
<map>
<mapping name="instanceName"><select path="state.hostname"/></mapping>

View File

@ -4,6 +4,8 @@
<list>
<text>SQL-security</text>
<text>WindowsSecurity</text>
<text>WSFCSecurity</text>
<text>SQLClusterSecurity</text>
</list>
</set>
</rule>

View File

@ -14,6 +14,9 @@
<set path="networking.routerId">
<select source="result" path="routerId"/>
</set>
<set path="networking.floatingId">
<select source="result" path="floatingId"/>
</set>
<rule match="$[?(@.networking.routerId == 'NOT_FOUND')]"
desc="Router could not be found">

View File

@ -63,14 +63,13 @@
<parameter name="mappings">
<map>
<mapping name="instanceName"><select path="state.hostname"/></mapping>
<mapping name="lbIp"><select path="::loadBalancerIp"/></mapping>
<mapping name="lbPort"><select path="::loadBalancerPort"/></mapping>
<mapping name="lbName"><select path="::name"/></mapping>
</map>
</parameter>
<success>
<set path="temp.registeredWithLB"><true/></set>
<set path="::uri">http://<select path="::loadBalancerIp"/>:<select path="::loadBalancerPort"/></set>
<set path="::uri">http://<select source="outputs"><parameter name="path"><select path="::name"/>-loadBalancerIp</parameter></select>:<select path="::loadBalancerPort"/></set>
</success>
<failure>
<report entity="unit" level="error">
@ -82,6 +81,35 @@
</update-cf-stack>
</rule>
<rule match="$[?(@.networking.state.ready_for_cf and @.networking.topology == 'routed')].services[?(@.type in ('webServerFarm', 'aspNetAppFarm') and @.assignFloatingIP and not @.floatingip)]"
desc="Web-farms services which have no floating assigned yet">
<report entity="unit">
<parameter name="id"><select path="id"/></parameter>
<parameter name="text">Assigning Floating IP to the to LB</parameter>
</report>
<update-cf-stack template="FloatingIPwithLB" result="outputs" error="exception">
<parameter name="mappings">
<map>
<mapping name="lbName"><select path="name"/></mapping>
<mapping name="externalNetworkId"><select path="/networking.floatingId"/></mapping>
</map>
</parameter>
<success>
<set path="floatingip"><select source="outputs"><parameter name="path"><select path="name"/>-FloatingIPaddress</parameter></select></set>
<report entity="unit">
<parameter name="id"><select path="id"/></parameter>
<parameter name="text">Floating IP has been assigned to LB</parameter>
</report>
</success>
<failure>
<report entity="unit" level="error">
<parameter name="id"><select path="id"/></parameter>
<parameter name="text">Unable to assign floating IP to <select path="name"/> due to <format-error error="exception"/></parameter>
</report>
</failure>
</update-cf-stack>
</rule>
<rule match="$.services[?(@.type in ('webServer', 'aspNetApp', 'webServerFarm', 'aspNetAppFarm') and @.adminPassword and @.adminPassword != @.state.adminPassword)].units[?(@.temp.instanceName)]"
desc="Units of web services which have got an instance deployed but has not got a correct admin password ">
<send-command template="SetPassword" error='exception'>

View File

@ -77,7 +77,9 @@ def get_locations(data_type, result_path):
# add keep path relative to result_path
base, diff = path.rsplit(result_path, 2)
# split base path and remove slash
name = os.path.join(diff[1:], name)
if diff.startswith('/'):
diff = diff[1:]
name = os.path.join(diff, name)
locations.append(name)
return jsonify({data_type: locations})
@ -226,7 +228,7 @@ def create_or_update_service(service_id, data):
'version': 0.1,
'description': '',
'author': '',
'service_version': ''}
'service_version': 1}
for parameter in required:
if not data.get(parameter):

View File

@ -63,6 +63,7 @@ def download_service_archive(service_name):
except:
log.exception(_('Unable to create service archive'))
abort(500)
else:
return send_file(file, mimetype='application/octet-stream')

View File

@ -20,8 +20,8 @@ import sys
import eventlet
import tempfile
from eventlet import wsgi
from oslo.config import cfg
import gettext
from muranorepository.openstack.common.gettextutils import _ # noqa
# If ../murano_service/__init__.py exists, add ../ to Python search path,
# so that it will override what happens to be installed in
# /usr/(local/)lib/python...
@ -37,7 +37,7 @@ if os.path.exists(os.path.join(possible_topdir,
gettext.install('muranorepository', unicode=1)
from muranorepository import config
from muranorepository import config as cfg
import muranorepository.main as server
from muranorepository.openstack.common import log
@ -48,12 +48,17 @@ LOG = log.getLogger(__name__)
def main():
dev_conf = os.path.join(possible_topdir,
'etc',
'murano',
'murano-repository.conf')
config_files = None
if os.path.exists(dev_conf):
config_files = [dev_conf]
config.parse_configs(sys.argv[1:], config_files)
if not sys.argv[1:] and not config_files:
msg = _('Unable to locate config file for murano-repository.')
raise RuntimeError(msg)
cfg.parse_configs(sys.argv[1:], config_files)
log.setup('muranorepository')
#configuring and initializing cache directory
@ -75,10 +80,10 @@ def main():
'admin_tenant_name': cfg.CONF.keystone.admin_tenant_name,
'signing_dir': cfg.CONF.keystone.signing_dir
})
if not os.path.isabs(config.CONF.manifests):
config.CONF.manifests = os.path.join(possible_topdir,
if not os.path.isabs(cfg.CONF.manifests):
cfg.CONF.manifests = os.path.join(possible_topdir,
'muranorepository',
config.CONF.manifests)
cfg.CONF.manifests)
wsgi.server(eventlet.listen((cfg.CONF.host, cfg.CONF.port),
backlog=500),
app)

View File

@ -60,7 +60,7 @@ def parse_configs(argv=None, conf_files=None):
global ARGV
ARGV = argv
try:
CONF(ARGV, project='murano_service', version="0.1",
CONF(ARGV, project='murano-repository', version='0.4.1',
default_config_files=conf_files)
except cfg.RequiredOptError as roe:
raise RuntimeError("Option '%s' is required for config group "

View File

@ -22,7 +22,6 @@ PIPAPPS="pip python-pip pip-python"
PIPCMD=""
SERVICE_SRV_NAME="murano-repository"
GIT_CLONE_DIR=`echo $SERVICE_CONTENT_DIRECTORY | sed -e "s/$SERVICE_SRV_NAME//"`
#ETC_CFG_DIR="/etc/$SERVICE_SRV_NAME"
ETC_CFG_DIR="/etc/murano"
LOG_DIR="/var/log/murano/"
SERVICE_CONFIG_FILE_PATH="$ETC_CFG_DIR/murano-repository.conf"

View File

@ -14,7 +14,7 @@
[metadata]
name = murano-repository
version = 0.4
version = 0.4.1
summary = Murano Metadata Repository
description-file = README.rst
license = Apache Software License

387
setup.sh Normal file → Executable file
View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2013 Mirantis, Inc.
#!/bin/bash
# Copyright (c) 2014 Mirantis, Inc.
#
# 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
@ -13,245 +13,236 @@
# License for the specific language governing permissions and limitations
# under the License.
#
# Ubuntu script.
LOGLVL=1
SERVICE_CONTENT_DIRECTORY=`cd $(dirname "$0") && pwd`
PREREQ_PKGS="wget make git python-pip python-dev python-mysqldb libxml2-dev libxslt-dev libffi-dev"
SERVICE_SRV_NAME="murano-repository"
GIT_CLONE_DIR=`echo $SERVICE_CONTENT_DIRECTORY | sed -e "s/$SERVICE_SRV_NAME//"`
#ETC_CFG_DIR="/etc/$SERVICE_SRV_NAME"
ETC_CFG_DIR="/etc/murano"
LOG_DIR="/var/log/murano/"
SERVICE_CONFIG_FILE_PATH="$ETC_CFG_DIR/murano-repository.conf"
# Functions
# Loger function
log()
{
MSG=$1
if [ $LOGLVL -gt 0 ]; then
echo "LOG:> $MSG"
fi
}
# Check or install package
in_sys_pkg()
{
PKG=$1
dpkg -s $PKG > /dev/null 2>&1
if [ $? -eq 0 ]; then
log "Package \"$PKG\" already installed"
RUN_DIR=$(cd $(dirname "$0") && pwd)
INC_FILE="$RUN_DIR/common.inc"
if [ -f "$INC_FILE" ]; then
source "$INC_FILE"
else
log "Installing \"$PKG\"..."
apt-get install $PKG --yes > /dev/null 2>&1
if [ $? -ne 0 ];then
log "installation fails, exiting!!!"
exit
echo "Can't load \"$INC_FILE\" or file not found, exiting!"
exit 1
fi
fi
}
#
DAEMON_NAME="murano-repository"
DAEMON_USER="murano"
DAEMON_GROUP="murano"
DAEMON_CFG_DIR="/etc/murano"
DAEMON_CACHE_DIR="/var/cache/murano"
DAEMON_LOG_DIR="/var/log/murano"
LOGFILE="/tmp/${DAEMON_NAME}_install.log"
DAEMON_DB_CONSTR="sqlite:///$DAEMON_CFG_DIR/$DAEMON_NAME.sqlite"
common_pkgs="wget git make gcc python-pip python-setuptools"
# Distro-specific package namings
debian_pkgs="python-dev python-mysqldb libxml2-dev libxslt1-dev libffi-dev"
redhat_pkgs="python-devel MySQL-python libxml2-devel libxslt-devel libffi-devel"
#
get_os
eval req_pkgs="\$$(lowercase $DISTRO_BASED_ON)_pkgs"
REQ_PKGS="$common_pkgs $req_pkgs"
# git clone
gitclone()
function install_prerequisites()
{
FROM=$1
CLONEROOT=$2
log "Cloning from \"$FROM\" repo to \"$CLONEROOT\""
cd $CLONEROOT && git clone $FROM > /dev/null 2>&1
retval=0
_dist=$(lowercase $DISTRO_BASED_ON)
if [ $_dist = "redhat" ]; then
yum repolist | grep -qoE "epel"
if [ $? -ne 0 ]; then
log "cloning from \"$FROM\" fails, exiting!!!"
exit
log "Enabling EPEL6..."
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
log "... can't enable EPEL6, exiting!"
retval=1
return $retval
fi
}
# install
inst()
{
CLONE_FROM_GIT=$1
# Checking packages
for PKG in $PREREQ_PKGS
fi
yum --quiet makecache
fi
for pack in $REQ_PKGS
do
in_sys_pkg $PKG
find_or_install "$pack"
if [ $? -eq 1 ]; then
retval=1
break
else
retval=0
fi
done
# If clone from git set
if [ ! -z $CLONE_FROM_GIT ]; then
# Preparing clone root directory
if [ ! -d $GIT_CLONE_DIR ];then
log "Creting $GIT_CLONE_DIR directory..."
mkdir -p $GIT_CLONE_DIR
return $retval
}
function make_tarball()
{
retval=0
log "Preparing tarball package..."
setuppy="$RUN_DIR/setup.py"
if [ -e "$setuppy" ]; then
chmod +x $setuppy
rm -rf $RUN_DIR/*.egg-info
cd $RUN_DIR && python $setuppy egg_info > /dev/null 2>&1
if [ $? -ne 0 ];then
log "Can't create $GIT_CLONE_DIR, exiting!!!"
exit
fi
fi
# Cloning from GIT
GIT_WEBPATH_PRFX="https://github.com/stackforge/"
gitclone "$GIT_WEBPATH_PRFX$SERVICE_SRV_NAME.git" $GIT_CLONE_DIR
# End clone from git section
fi
# Setupping...
log "Running setup.py"
MRN_CND_SPY=$SERVICE_CONTENT_DIRECTORY/setup.py
if [ -e $MRN_CND_SPY ]; then
chmod +x $MRN_CND_SPY
log "$MRN_CND_SPY output:_____________________________________________________________"
## Setup through pip
# Creating tarball
rm -rf $SERVICE_CONTENT_DIRECTORY/*.egg-info
cd $SERVICE_CONTENT_DIRECTORY && python $MRN_CND_SPY egg_info
if [ $? -ne 0 ];then
log "\"$MRN_CND_SPY\" egg info creation FAILS, exiting!!!"
log "...\"$setuppy\" egg info creation fails, exiting!!!"
retval=1
exit 1
fi
rm -rf $SERVICE_CONTENT_DIRECTORY/dist/*
cd $SERVICE_CONTENT_DIRECTORY && $MRN_CND_SPY sdist
rm -rf $RUN_DIR/dist/*
log "...\"setup.py sdist\" output will be recorded in \"$LOGFILE\""
cd $RUN_DIR && $setuppy sdist >> $LOGFILE 2>&1
if [ $? -ne 0 ];then
log "\"$MRN_CND_SPY\" tarball creation FAILS, exiting!!!"
log "...\"$setuppy\" tarball creation fails, exiting!!!"
retval=1
exit 1
fi
# Running tarball install
TRBL_FILE=$(basename `ls $SERVICE_CONTENT_DIRECTORY/dist/*.tar.gz`)
pip install $SERVICE_CONTENT_DIRECTORY/dist/$TRBL_FILE
if [ $? -ne 0 ];then
log "pip install \"$TRBL_FILE\" FAILS, exiting!!!"
exit 1
#TRBL_FILE=$(basename $(ls $RUN_DIR/dist/*.tar.gz | head -n 1))
TRBL_FILE=$(ls $RUN_DIR/dist/*.tar.gz | head -n 1)
if [ ! -e "$TRBL_FILE" ]; then
log "...tarball not found, exiting!"
retval=1
else
log "...success, tarball created as \"$TRBL_FILE\""
retval=0
fi
else
log "$MRN_CND_SPY not found!"
log "...\"$setuppy\" not found, exiting!"
retval=1
fi
# Creating etc directory for config files
if [ ! -d $ETC_CFG_DIR ];then
log "Creating $ETC_CFG_DIR directory..."
mkdir -p $ETC_CFG_DIR
return $retval
}
function run_pip_install()
{
find_pip
retval=0
tarball_file=${1:-$TRBL_FILE}
log "Running \"$PIPCMD install $PIPARGS $tarball_file\" output will be recorded in \"$LOGFILE\""
$PIPCMD install $PIPARGS $tarball_file >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
log "Can't create $ETC_CFG_DIR, exiting!!!"
log "...pip install fails, exiting!"
retval=1
exit 1
fi
fi
# Creating log directory for the murano
if [ ! -d $LOG_DIR ];then
log "Creating $LOG_DIR direcory..."
mkdir -p $LOG_DIR
if [ $? -ne 0 ];then
log "Can't create $LOG_DIR, exiting!!!"
exit 1
fi
chmod -R a+rw $LOG_DIR
fi
# making sample configs
log "Making sample configuration files at \"$ETC_CFG_DIR\""
for file in `ls $SERVICE_CONTENT_DIRECTORY/etc`
do
cp -f "$SERVICE_CONTENT_DIRECTORY/etc/$file" "$ETC_CFG_DIR/$file"
done
return $retval
}
# searching for service executable in path
get_service_exec_path()
function inject_init()
{
if [ -z "$SERVICE_EXEC_PATH" ]; then
SERVICE_EXEC_PATH=`which $SERVICE_SRV_NAME`
retval=0
_dist=$(lowercase $DISTRO_BASED_ON)
eval src_init_sctipt="$DAEMON_NAME-$_dist"
_initscript="openstack-$DAEMON_NAME"
cp -f "$RUN_DIR/etc/init.d/$src_init_sctipt" "/etc/init.d/$_initscript" || retval=$?
chmod +x "/etc/init.d/$_initscript" || retval=$?
iniset '' 'SYSTEM_USER' "$DAEMON_USER" "/etc/init.d/$_initscript"
iniset '' 'DAEMON' "$(shslash $SERVICE_EXEC_PATH)" "/etc/init.d/$_initscript"
case $_dist in
"debian")
update-rc.d $_initscript defaults || retval=$?
update-rc.d $_initscript enable || retval=$?
;;
*)
chkconfig --add $_initscript || retval=$?
chkconfig $_initscript on || retval=$?
;;
esac
return $retval
}
function purge_init()
{
retval=0
_dist=$(lowercase $DISTRO_BASED_ON)
_initscript="openstack-$DAEMON_NAME"
service $_initscript stop
if [ $? -ne 0 ]; then
log "Can't find \"$SERVICE_SRV_NAME\", please install the \"$SERVICE_SRV_NAME\" by running \"$(basename "$0") install\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
exit 1
fi
else
if [ ! -x "$SERVICE_EXEC_PATH" ]; then
log "\"$SERVICE_EXEC_PATH\" in not executable, please install the \"$SERVICE_SRV_NAME\" or set variable SERVICE_EXEC_PATH=/path/to/daemon before running setup script, exiting!"
exit 1
fi
retval=1
fi
case $_dist in
"debian")
update-rc.d $_initscript disable
update-rc.d -f $_initscript remove || retval=$?
;;
*)
chkconfig $_initscript off || retval=$?
chkconfig --del $_initscript || retval=$?
;;
esac
rm -f "/etc/init.d/$_initscript" || retval=$?
return $retval
}
# inject init
injectinit()
function run_pip_uninstall()
{
ln -s /lib/init/upstart-job /etc/init.d/$SERVICE_SRV_NAME
if [ $? -ne 0 ]; then
log "Can't create symlink, please run \"$(basename "$0") purge-init\" before \"$(basename "$0") inject-init\", exiting"
exit 1
fi
echo "description \"$SERVICE_SRV_NAME service\"
author \"Igor Yozhikov <iyozhikov@mirantis.com>\"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec start-stop-daemon --start --chuid root --user root --name $SERVICE_SRV_NAME --exec $SERVICE_EXEC_PATH -- --config-file=$SERVICE_CONFIG_FILE_PATH" > "/etc/init/$SERVICE_SRV_NAME.conf"
log "Reloading initctl"
initctl reload-configuration
}
# purge init
purgeinit()
{
rm -f /etc/init.d/$SERVICE_SRV_NAME
rm -f /etc/init/$SERVICE_SRV_NAME.conf
log "Reloading initctl"
initctl reload-configuration
}
# uninstall
uninst()
{
# Uninstall trough pip
# looking up for python package installed
PYPKG=`echo $SERVICE_SRV_NAME | tr -d '-'`
pip freeze | grep $PYPKG
find_pip
retval=0
pack_to_del=$(is_py_package_installed "$DAEMON_NAME")
if [ $? -eq 0 ]; then
log "Removing package \"$PYPKG\" with pip"
pip uninstall $PYPKG --yes
log "Running \"$PIPCMD uninstall $PIPARGS $DAEMON_NAME\" output will be recorded in \"$LOGFILE\""
$PIPCMD uninstall $pack_to_del --yes >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
log "...can't uninstall $DAEMON_NAME with $PIPCMD"
retval=1
else
log "Python package \"$PYPKG\" not found"
log "...success"
fi
else
log "Python package for \"$DAEMON_NAME\" not found"
fi
return $retval
}
# postinstall
postinst()
function install_daemon()
{
log "Please, make proper configuration,located at \"$ETC_CFG_DIR\", before starting the \"$SERVICE_SRV_NAME\" daemon!"
install_prerequisites || exit 1
make_tarball || exit $?
run_pip_install || exit $?
add_daemon_credentials "$DAEMON_USER" "$DAEMON_GROUP" || exit $?
log "Creating required directories..."
mk_dir "$DAEMON_CFG_DIR" "$DAEMON_USER" "$DAEMON_GROUP" || exit 1
mk_dir "$DAEMON_CACHE_DIR" "$DAEMON_USER" "$DAEMON_GROUP" || exit 1
mk_dir "$DAEMON_LOG_DIR" "$DAEMON_USER" "$DAEMON_GROUP" || exit 1
log "Making sample configuration files at \"$DAEMON_CFG_DIR\""
_src_conf_dir="$RUN_DIR/etc/murano"
for file in $(ls $_src_conf_dir)
do
#cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$file.sample"
cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$file"
config_file=$(echo $file | sed -e 's/.sample$//')
#if [ ! -e "$DAEMON_CFG_DIR/$file" ]; then
if [ ! -e "$DAEMON_CFG_DIR/$config_file" ]; then
cp -f "$_src_conf_dir/$file" "$DAEMON_CFG_DIR/$config_file"
else
log "\"$DAEMON_CFG_DIR/$config_file\" exists, skipping copy."
fi
done
log "Setting log file and sqlite db placement..."
iniset 'DEFAULT' 'log_file' "$(shslash $DAEMON_LOG_DIR/$DAEMON_NAME.log)" "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
iniset 'DEFAULT' 'verbose' 'True' "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
iniset 'DEFAULT' 'debug' 'True' "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
iniset 'DEFAULT' 'data_dir' "$(shslash $DAEMON_CACHE_DIR/muranorepository-data)" "$DAEMON_CFG_DIR/$DAEMON_NAME.conf"
log "Searching daemon in \$PATH..."
get_service_exec_path || exit $?
log "...found at \"$SERVICE_EXEC_PATH\""
log "Installing SysV init script."
inject_init || exit $?
log "Everything done, please, verify \"$DAEMON_CFG_DIR/$DAEMON_NAME.conf\", service created as \"openstack-${DAEMON_NAME}\"."
}
function uninstall_daemon()
{
log "Removing SysV init script..."
purge_init || exit $?
remove_daemon_credentials "$DAEMON_USER" "$DAEMON_GROUP" || exit $?
run_pip_uninstall || exit $?
log "Software uninstalled, daemon configuration files and logs located at \"$DAEMON_CFG_DIR\" and \"$DAEMON_LOG_DIR\"."
}
# Command line args'
COMMAND="$1"
case $COMMAND in
inject-init )
get_service_exec_path
log "Injecting \"$SERVICE_SRV_NAME\" to init..."
injectinit
postinst
;;
install)
inst
get_service_exec_path
injectinit
postinst
;;
installfromgit )
inst "yes"
get_service_exec_path
injectinit
postinst
;;
purge-init )
log "Purging \"$SERVICE_SRV_NAME\" from init..."
stop $SERVICE_SRV_NAME
purgeinit
rm -rf $LOGFILE
log "Installing \"$DAEMON_NAME\" to system..."
install_daemon
;;
uninstall )
log "Uninstalling \"$SERVICE_SRV_NAME\" from system..."
stop $SERVICE_SRV_NAME
purgeinit
uninst
log "Uninstalling \"$DAEMON_NAME\" from system..."
uninstall_daemon
;;
* )
echo "Usage: $(basename "$0") command \nCommands:\n\tinstall - Install $SERVICE_SRV_NAME software\n\tuninstall - Uninstall $SERVICE_SRV_NAME software\n\tinject-init - Add $SERVICE_SRV_NAME to the system start-up\n\tpurge-init - Remove $SERVICE_SRV_NAME from the system start-up"
echo -e "Usage: $(basename "$0") [command] \nCommands:\n\tinstall - Install \"$DAEMON_NAME\" software\n\tuninstall - Uninstall \"$DAEMON_NAME\" software"
exit 1
;;
esac