Déplacement des fichiers depuis eole-one-singlenode
This commit is contained in:
commit
7a3f95db42
26
Makefile
Normal file
26
Makefile
Normal file
@ -0,0 +1,26 @@
|
||||
################################
|
||||
# Makefile pour eole-libvirt
|
||||
################################
|
||||
|
||||
SOURCE=eole-one-master
|
||||
VERSION=0.0.1
|
||||
EOLE_VERSION=2.4
|
||||
PKGAPPS=non
|
||||
#FLASK_MODULE=<APPLICATION>
|
||||
|
||||
################################
|
||||
# Début de zone à ne pas éditer
|
||||
################################
|
||||
|
||||
include eole.mk
|
||||
include apps.mk
|
||||
|
||||
################################
|
||||
# Fin de zone à ne pas éditer
|
||||
################################
|
||||
|
||||
# Makefile rules dedicated to application
|
||||
# if exists
|
||||
ifneq (, $(strip $(wildcard $(SOURCE).mk)))
|
||||
include $(SOURCE).mk
|
||||
endif
|
64
apps.mk
Normal file
64
apps.mk
Normal file
@ -0,0 +1,64 @@
|
||||
#
|
||||
# NE PAS EDITER CE FICHIER
|
||||
#
|
||||
# Voir Makefile
|
||||
|
||||
|
||||
##########################
|
||||
# Application web envole #
|
||||
##########################
|
||||
ifneq (, $(filter oui web, $(PKGAPPS)))
|
||||
#
|
||||
# Sanity check
|
||||
#
|
||||
ifeq (, $(filter-out X.X, $(strip $(VERSION))))
|
||||
$(error $$(VERSION) variable has incorrect value '$(VERSION)')
|
||||
endif
|
||||
|
||||
# Where to store web application files
|
||||
WEB_PATH := $(DESTDIR)/var/www/html
|
||||
|
||||
# Envole
|
||||
sharenvole_PROG_DIR := $(DESTDIR)/usr/share/envole/$(SOURCE)
|
||||
|
||||
src_$(SOURCE)-$(VERSION)_REC_DIR := $(WEB_PATH)/$(SOURCE)
|
||||
src_plugins-$(VERSION)_REC_DIR := $(WEB_PATH)/$(SOURCE)/plugin
|
||||
src_lang-$(VERSION)_REC_DIR := $(WEB_PATH)/$(SOURCE)/lang
|
||||
|
||||
endif
|
||||
|
||||
##########################
|
||||
# Application EOLE flask #
|
||||
##########################
|
||||
ifneq (, $(filter flask, $(PKGAPPS)))
|
||||
#
|
||||
# Sanity check
|
||||
#
|
||||
ifeq (, $(filter-out XXX, $(strip $(FLASK_MODULE))))
|
||||
$(error $$(FLASK_MODULE) variable has incorrect value '$(FLASK_MODULE)')
|
||||
endif
|
||||
|
||||
ifeq (, $(strip $(wildcard src/$(FLASK_MODULE).conf)))
|
||||
$(error missing eoleflask configuration file 'src/$(FLASK_MODULE).conf')
|
||||
endif
|
||||
|
||||
# Everything is related to mount point
|
||||
APPS_MOUNT_POINT := $(shell sed -ne 's|^"MOUNT_POINT"[[:space:]]*:[[:space:]]*"/\([^"]*\)",|\1|p' \
|
||||
src/$(FLASK_MODULE).conf)
|
||||
|
||||
ifeq (, $(strip $(APPS_MOUNT_POINT)))
|
||||
$(error no "MOUNT_POINT" in eoleflask configuration file 'src/$(FLASK_MODULE).conf')
|
||||
endif
|
||||
|
||||
# eole-flask configuration
|
||||
src_DATA_DIR := $(DESTDIR)/etc/eole/flask/available
|
||||
|
||||
# Where to store flask application files
|
||||
FLASK_PATH := $(eole_DIR)/flask/$(APPS_MOUNT_POINT)
|
||||
|
||||
# static files
|
||||
src_$(FLASK_MODULE)_static_REC_DIR := $(FLASK_PATH)/static
|
||||
src_$(FLASK_MODULE)_templates_REC_DIR := $(FLASK_PATH)/templates
|
||||
src_$(FLASK_MODULE)_instance_REC_DIR := $(FLASK_PATH)/resources
|
||||
|
||||
endif
|
90
diagnose/04-virtualisation
Normal file
90
diagnose/04-virtualisation
Normal file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /usr/lib/eole/diagnose.sh
|
||||
|
||||
|
||||
eKO() {
|
||||
EchoRouge "Erreur"
|
||||
}
|
||||
|
||||
eOK() {
|
||||
EchoVert "Ok"
|
||||
}
|
||||
|
||||
one()
|
||||
{
|
||||
su oneadmin -s /bin/sh -c "$@"
|
||||
}
|
||||
|
||||
TestServiceStatus() {
|
||||
printf ". %${len_pf}s => " "$1"
|
||||
/etc/init.d/$2 status >/dev/null 2>&1
|
||||
if [ $? -eq 0 ] ; then
|
||||
eOK
|
||||
else
|
||||
eKO
|
||||
fi
|
||||
}
|
||||
|
||||
eOneStatus() {
|
||||
[ "$1" = "STOPPED" -o "$1" = "UNKNOWN" ] && EchoRouge "$1" && return
|
||||
[ "$1" = "ACTIVE" ] && EchoVert "$1" && return
|
||||
EchoOrange "$1"
|
||||
}
|
||||
|
||||
|
||||
EchoGras "*** Virtualisation"
|
||||
|
||||
if [ "$(CreoleGet 'activer_openvswitch')" != "oui" ]; then
|
||||
printf ". %${len_pf}s => " "Virutalisation"
|
||||
EchoOrange "Non actif"
|
||||
fi
|
||||
|
||||
TestServiceStatus "libvirt" libvirt-bin
|
||||
TestServiceStatus "OpenNebula" opennebula
|
||||
TestService "XMLRPC" "localhost:2633"
|
||||
TestService "Sunstone" $(CreoleGet "ip_sunstone"):$(CreoleGet "port_sunstone")
|
||||
TestService "Proxy VNC" $(CreoleGet "ip_sunstone"):$(CreoleGet "vnc_proxy_port_sunstone")
|
||||
if [ "$(CreoleGet 'activer_oneflow')" == 'oui' ]; then
|
||||
TestService "OneFlow" $(CreoleGet "ip_oneflow"):$(CreoleGet "port_oneflow")
|
||||
fi
|
||||
echo ""
|
||||
TestServiceStatus "OpenVswitch" openvswitch-switch
|
||||
echo ""
|
||||
|
||||
if [[ $(CreoleGet activer_onesinglenode 2>&1) == 'oui' ]]
|
||||
then
|
||||
EchoGras "*** Noeuds du cluster Hâpy"
|
||||
|
||||
NODES=$(one 'onehost list -l ID,NAME,STAT' | awk '!/ID.*NAME.*STAT/ {print $1 ":" $2 ":" $3}')
|
||||
for elm in ${NODES}
|
||||
do
|
||||
node=(${elm//:/ })
|
||||
id=${node[0]}
|
||||
name=${node[1]}
|
||||
state=${node[2]}
|
||||
|
||||
printf ". %${len_pf}s => " "$name"
|
||||
eOneStatus "${state}"
|
||||
done
|
||||
fi
|
||||
|
||||
EchoGras "*** Machines Virtuelles"
|
||||
|
||||
# Les machines virtuelles se terminant par -TEST ne sont pas vérifiées
|
||||
VMs=$( one 'onevm list -l ID,NAME,STAT' | tail -n +2 | grep -ve '\-TEST ' | awk '{print $1}' )
|
||||
if [[ -z ${VMs} ]]
|
||||
then
|
||||
printf ". %${len_pf}s " "Pas de machines virtuelles instanciées"
|
||||
else
|
||||
for VM in $VMs ; do
|
||||
NAME=$( one "onevm show $VM" | grep 'NAME' | cut -d: -f2 )
|
||||
STAT=$(one "onevm show $VM" | grep '^STATE' | cut -d: -f2 | tr -d ' ' )
|
||||
printf ". %${len_pf}s => " "$NAME"
|
||||
eOneStatus "$STAT"
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
|
159
dicos/99_one-master.xml
Normal file
159
dicos/99_one-master.xml
Normal file
@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<creole>
|
||||
<files>
|
||||
<!--file filelist='onesinglenode' name='/etc/one/sunstone-server.conf' rm='True' mkdir='True'/-->
|
||||
<file filelist='onesinglenode' name='/etc/one/vmm_exec/vmm_exec_kvm.conf' rm='True' mkdir='True'/>
|
||||
<file filelist='onesinglenode' name='/etc/one/oned.conf' rm='True' mkdir='True'/>
|
||||
<service type='service'>opennebula</service>
|
||||
|
||||
<service_access service='one-ssh'>
|
||||
<tcpwrapper>sshd</tcpwrapper>
|
||||
</service_access>
|
||||
|
||||
<service_restriction service='one-ssh'>
|
||||
<ip interface='eth0' ip_type='SymLinkOption'>adresse_ip_eth0</ip>
|
||||
</service_restriction>
|
||||
</files>
|
||||
<variables>
|
||||
<family name='general'>
|
||||
<variable name='nom_machine' redefine='True' auto_freeze='True'/>
|
||||
</family>
|
||||
<family name='Virtualisation'>
|
||||
<variable name='activer_onesinglenode' type='oui/non' description="Activer le serveur de virtualisation" mode='expert'>
|
||||
<value>oui</value>
|
||||
</variable>
|
||||
<variable name='one_cluster_name' type='string' description="Nom de la grappe OpenNebula" mode='expert' auto_freeze='True' mandatory="True">
|
||||
<value></value>
|
||||
</variable>
|
||||
<variable name='vnets' type='string' description='Réseaux virtuels Niveau 3' multi='True'/>
|
||||
<variable name='vnet_network_addr' type='ip' description='Adresse du réseau'/>
|
||||
<variable name='vnet_network_mask' type='netmask' description='Masque du réseau'/>
|
||||
<variable name='vnet_network_dns' type='ip' description='Adresse du serveur DNS'/>
|
||||
<variable name='vnet_network_gw' type='ip' description='Passerelle du réseau'/>
|
||||
<variable name='vnet_range_start' type='ip' description='Première IP de la plage (si nécessaire)'/>
|
||||
<variable name='vnet_range_end' type='ip' description='Dernière IP de la plage (si nécessaire)'/>
|
||||
<variable name='vnet_vlan_tag' type='number' description='Numéro du VLAN'/>
|
||||
<variable name='vnet_vlan_trunk' type='number' description="VLAN à transporter (trunk)" mode='expert'/>
|
||||
|
||||
<variable name='l2_vnets' type='string' description='Réseaux virtuels Niveau 2' multi='True'/>
|
||||
<variable name='l2_vnet_first_mac' type='string' description='Première adresse MAC' mode='expert'/>
|
||||
<variable name='l2_vnet_size' type='number' description="Taille du réseau (en nombre d'adresse MAC)"/>
|
||||
<variable name='l2_vnet_vlan_tag' type='number' description='Numéro du VLAN'/>
|
||||
<variable name='l2_vnet_vlan_trunk' type='number' description="VLAN à transporter (trunk)" mode='expert'/>
|
||||
|
||||
<variable name='one_ds_system_prefix' description="Préfix de l'espace de stockage système" mode='expert' auto_freeze='True'>
|
||||
<value>system-</value>
|
||||
</variable>
|
||||
<variable name='one_ds_iso_name' description="Nom de l'espace de stockage des ISO" mode='expert' auto_freeze='True'>
|
||||
<value>iso-images</value>
|
||||
</variable>
|
||||
<variable name='one_ds_image_name' description="Nom de l'espace de stockage de images disque" mode='expert' auto_freeze='True'>
|
||||
<value>images-disques</value>
|
||||
</variable>
|
||||
<variable name='one_disk_cache' type='oui/non' description='Activer le cache pour les images qcow2 ?' mode='expert'>
|
||||
<value>oui</value>
|
||||
</variable>
|
||||
<variable name='one_video_driver' type='string' description='Driver video par défaut' mode='expert'>
|
||||
<value>vga</value>
|
||||
</variable>
|
||||
<variable name='activer_multinode' description='Activer le mode multi-noeud' mode='expert' type='oui/non'>
|
||||
<value>non</value>
|
||||
</variable>
|
||||
<variable name='one_nodes' type='string' description='Noeud voisin du Cluster' multi='True'/>
|
||||
<variable name='node_ip' type='ip' description='Adresse IP du noeud' multi='True'/>
|
||||
</family>
|
||||
</variables>
|
||||
|
||||
<constraints>
|
||||
<fill name='concat' target='one_cluster_name'>
|
||||
<param>CL-</param>
|
||||
<param type='eole'>numero_etab</param>
|
||||
</fill>
|
||||
|
||||
<check name='valid_enum' target='one_video_driver'>
|
||||
<param>['qxl','vga','std','cirrus']</param>
|
||||
<param name='checkval'>False</param>
|
||||
</check>
|
||||
|
||||
<condition name='disabled_if_in' source='activer_onesinglenode'>
|
||||
<param>non</param>
|
||||
<target type='filelist'>onesinglenode</target>
|
||||
<target type='variable'>one_cluster_name</target>
|
||||
<target type='variable'>one_ds_system_prefix</target>
|
||||
<target type='variable'>one_ds_iso_name</target>
|
||||
<target type='variable'>one_ds_image_name</target>
|
||||
<target type='variable'>vnets</target>
|
||||
<target type='variable'>vnet_network_addr</target>
|
||||
<target type='variable'>vnet_network_mask</target>
|
||||
<target type='variable'>vnet_network_dns</target>
|
||||
<target type='variable'>vnet_network_gw</target>
|
||||
<target type='variable'>vnet_range_start</target>
|
||||
<target type='variable'>vnet_range_end</target>
|
||||
<target type='variable'>vnet_vlan_tag</target>
|
||||
<target type='variable'>vnet_vlan_trunk</target>
|
||||
<target type='variable'>activer_multinode</target>
|
||||
<target type='variable'>l2_vnets</target>
|
||||
<target type='variable'>l2_vnet_first_mac</target>
|
||||
<target type='variable'>l2_vnet_size</target>
|
||||
<target type='variable'>l2_vnet_vlan_tag</target>
|
||||
<target type='variable'>l2_vnet_vlan_trunk</target>
|
||||
</condition>
|
||||
|
||||
<condition name='disabled_if_in' source='activer_multinode'>
|
||||
<param>non</param>
|
||||
<target type='variable'>one_nodes</target>
|
||||
<target type='variable'>node_ip</target>
|
||||
</condition>
|
||||
|
||||
<group master='vnets'>
|
||||
<slave>vnet_network_addr</slave>
|
||||
<slave>vnet_network_dns</slave>
|
||||
<slave>vnet_network_mask</slave>
|
||||
<slave>vnet_network_gw</slave>
|
||||
<slave>vnet_range_start</slave>
|
||||
<slave>vnet_range_end</slave>
|
||||
<slave>vnet_vlan_tag</slave>
|
||||
<slave>vnet_vlan_trunk</slave>
|
||||
</group>
|
||||
|
||||
<group master='l2_vnets'>
|
||||
<slave>l2_vnet_first_mac</slave>
|
||||
<slave>l2_vnet_size</slave>
|
||||
<slave>l2_vnet_vlan_tag</slave>
|
||||
<slave>l2_vnet_vlan_trunk</slave>
|
||||
</group>
|
||||
|
||||
<group master='one_nodes'>
|
||||
<slave>node_ip</slave>
|
||||
</group>
|
||||
|
||||
<check name='valid_enum' target='vnets'>
|
||||
<param>['internet','admin','pedago','dmzpub','dmzpriv','wifi']</param>
|
||||
<param name='checkval'>False</param>
|
||||
</check>
|
||||
|
||||
<check name='valid_enum' target='l2_vnets'>
|
||||
<param>['internet','admin','pedago','dmzpub','dmzpriv','wifi']</param>
|
||||
<param name='checkval'>False</param>
|
||||
</check>
|
||||
|
||||
<condition name='disabled_if_in' source='activer_openvswitch'>
|
||||
<param>non</param>
|
||||
<target type='variable'>vnet_network_addr</target>
|
||||
<target type='variable'>vnet_network_dns</target>
|
||||
<target type='variable'>vnet_network_mask</target>
|
||||
<target type='variable'>vnet_network_gw</target>
|
||||
<target type='variable'>vnet_range_start</target>
|
||||
<target type='variable'>vnet_range_end</target>
|
||||
<target type='variable'>vnet_vlan_tag</target>
|
||||
<target type='variable'>vnet_vlan_trunk</target>
|
||||
<target type='variable'>l2_vnet_first_mac</target>
|
||||
<target type='variable'>l2_vnet_size</target>
|
||||
<target type='variable'>l2_vnet_vlan_tag</target>
|
||||
<target type='variable'>l2_vnet_vlan_trunk</target>
|
||||
</condition>
|
||||
</constraints>
|
||||
<help>
|
||||
<variable name='activer_onesinglenode'>Interface d'administration du Cluster OpenNebula.</variable>
|
||||
</help>
|
||||
</creole>
|
4
eole-one-master.mk
Normal file
4
eole-one-master.mk
Normal file
@ -0,0 +1,4 @@
|
||||
# eole-one-singlenode specific rules
|
||||
|
||||
hooks_PROG_DIR := $(DESTDIR)/var/lib/one/remotes/hooks/eole
|
||||
init_PROG_DIR := $(DESTDIR)/etc/init.d
|
200
eole.mk
Normal file
200
eole.mk
Normal file
@ -0,0 +1,200 @@
|
||||
#
|
||||
# NE PAS EDITER CE FICHIER
|
||||
#
|
||||
# Utiliser <appli>.mk à inclure à la fin de Makefile
|
||||
|
||||
#################
|
||||
# Sanity checks #
|
||||
#################
|
||||
|
||||
ifeq (, $(DESTDIR))
|
||||
$(warning $$(DESTDIR) is empty, installation will be done in /)
|
||||
endif
|
||||
|
||||
ifeq (, $(filter-out XXX-XXX, $(strip $(SOURCE))))
|
||||
$(error $$(SOURCE) variable has incorrect value '$(SOURCE)')
|
||||
endif
|
||||
|
||||
#########################
|
||||
# Variables definitions #
|
||||
#########################
|
||||
|
||||
INSTALL := install
|
||||
INSTALL_DATA := install -m 644
|
||||
INSTALL_PROGRAM := install -m 755
|
||||
INSTALL_DIRECTORY := install -m 755 -d
|
||||
INSTALL_RECURSIVE := cp -dr --no-preserve=ownership
|
||||
|
||||
# Standard path
|
||||
bin_PROG_DIR := $(DESTDIR)/usr/bin
|
||||
sbin_PROG_DIR := $(DESTDIR)/usr/sbin
|
||||
man8_DATA_DIR := $(DESTDIR)/usr/share/man/fr.UTF-8/man8
|
||||
|
||||
# Base
|
||||
eole_DIR := $(DESTDIR)/usr/share/eole
|
||||
|
||||
ifeq ($(strip $(EOLE_VERSION)), 2.3)
|
||||
diagnose_PROG_DIR := $(eole_DIR)/diagnose/module
|
||||
else
|
||||
diagnose_PROG_DIR := $(eole_DIR)/diagnose/
|
||||
endif
|
||||
|
||||
# Creole
|
||||
creole_DIR := $(eole_DIR)/creole
|
||||
dicos_DATA_DIR := $(creole_DIR)/dicos
|
||||
tmpl_DATA_DIR := $(creole_DIR)/distrib
|
||||
pretemplate_PROG_DIR := $(eole_DIR)/pretemplate
|
||||
posttemplate_PROG_DIR := $(eole_DIR)/posttemplate
|
||||
preservice_PROG_DIR := $(eole_DIR)/preservice
|
||||
postservice_PROG_DIR := $(eole_DIR)/postservice
|
||||
firewall_DATA_DIR := $(eole_DIR)/firewall
|
||||
bacula_restore_DATA_DIR := $(eole_DIR)/bacula/restore
|
||||
bacula_fichier_DATA_DIR := $(DESTDIR)/etc/bacula/baculafichiers.d
|
||||
ifeq ($(strip $(EOLE_VERSION)), 2.3)
|
||||
schedule_pre_PROG_DIR := $(eole_DIR)/schedule/pre
|
||||
schedule_post_PROG_DIR := $(eole_DIR)/schedule/post
|
||||
else
|
||||
schedule_scripts_PROG_DIR := $(eole_DIR)/schedule/scripts
|
||||
endif
|
||||
extra_REC_DIR := $(creole_DIR)/extra
|
||||
|
||||
# Zéphir
|
||||
zephir_DATA_DIR := $(DESTDIR)/usr/share/zephir
|
||||
zephir_configs_DATA_DIR := $(zephir_DATA_DIR)/monitor/configs
|
||||
zephir_srv_DATA_DIR := $(zephir_configs_DATA_DIR)/services
|
||||
zephir_scripts_PROG_DIR := $(zephir_DATA_DIR)/scripts
|
||||
|
||||
# SSO
|
||||
sso_DATA_DIR := $(DESTDIR)/usr/share/sso
|
||||
sso_filtres_DATA_DIR := $(sso_DATA_DIR)/app_filters
|
||||
sso_user-info_DATA_DIR := $(sso_DATA_DIR)/user_infos
|
||||
|
||||
# EAD
|
||||
ead_DATA_DIR := $(DESTDIR)/usr/share/ead2/backend/config
|
||||
ead_actions_DATA_DIR := $(ead_DATA_DIR)/actions
|
||||
ead_perms_DATA_DIR := $(ead_DATA_DIR)/perms
|
||||
ead_roles_DATA_DIR := $(ead_DATA_DIR)/roles
|
||||
|
||||
# Program libraries goes under /usr/lib/<PROGRAM>/
|
||||
lib_$(SOURCE)_DATA_DIR := $(DESTDIR)/usr/lib/$(SOURCE)
|
||||
|
||||
# Scripts Eole
|
||||
scripts_PROG_DIR := $(eole_DIR)/sbin
|
||||
lib_eole_DATA_DIR := $(DESTDIR)/usr/lib/eole
|
||||
|
||||
# LDAP
|
||||
ldap_passwords_DATA_DIR := $(eole_DIR)/annuaire/password_files
|
||||
|
||||
# LXC
|
||||
lxc_DATA_DIR := $(eole_DIR)/lxc
|
||||
lxc_fstab_DATA_DIR := $(lxc_DATA_DIR)/fstab
|
||||
lxc_hosts_DATA_DIR := $(lxc_DATA_DIR)/hosts
|
||||
|
||||
# SQL
|
||||
sql_DATA_DIR := $(eole_DIR)/mysql/$(SOURCE)
|
||||
sql_gen_DATA_DIR := $(sql_DATA_DIR)/gen
|
||||
sql_updates_DATA_DIR := $(sql_DATA_DIR)/updates
|
||||
|
||||
sql_conf_gen_DATA_DIR := $(eole_DIR)/applications/gen
|
||||
sql_conf_passwords_DATA_DIR := $(eole_DIR)/applications/passwords
|
||||
sql_conf_updates_DATA_DIR := $(eole_DIR)/applications/updates/$(SOURCE)
|
||||
|
||||
# Certifs
|
||||
certs_DATA_DIR := $(eole_DIR)/certs
|
||||
|
||||
# Logrotate
|
||||
logrotate_DATA_DIR := $(DESTDIR)/etc/logrotate.d
|
||||
|
||||
# Cron
|
||||
cron_PROG_DIR := $(DESTDIR)/etc/cron.daily
|
||||
|
||||
# Python modules
|
||||
ifneq ($(DESTDIR),)
|
||||
PYTHON_OPTS := --root $(DESTDIR)
|
||||
endif
|
||||
|
||||
#############################################
|
||||
# Common directories and files installation #
|
||||
#############################################
|
||||
|
||||
all:
|
||||
|
||||
install:: install-dirs install-files
|
||||
|
||||
# $1 = command to run
|
||||
# $2 = source directory
|
||||
# $3 = destination directory
|
||||
define fc_install_file
|
||||
if [ -d $2 ]; then \
|
||||
for file in `ls -1 $2/`; do \
|
||||
$1 $2/$$file $3 || true; \
|
||||
done; \
|
||||
fi
|
||||
endef
|
||||
|
||||
##
|
||||
## Directory creation
|
||||
##
|
||||
|
||||
# use % to catch local name in $*
|
||||
# data, program and recursive directory require a corresponding
|
||||
# directory in local sources
|
||||
%_DATA_DIR %_PROG_DIR %REC_DIR:
|
||||
test ! -d $(subst _,/,$*) || $(INSTALL_DIRECTORY) $($@)
|
||||
|
||||
# Create the directory referenced by the variable without a local one.
|
||||
%_DIR:
|
||||
$(INSTALL_DIRECTORY) $($@)
|
||||
|
||||
##
|
||||
## Install files present directly under data, program and recursive directories
|
||||
##
|
||||
|
||||
# $* : name of variable
|
||||
# $($*): value of variable
|
||||
%-instdata:
|
||||
$(call fc_install_file, $(INSTALL_DATA), $(subst _,/,$(subst _DATA_DIR,,$*)), $($*))
|
||||
|
||||
%-instprog:
|
||||
$(call fc_install_file, $(INSTALL_PROGRAM), $(subst _,/,$(subst _PROG_DIR,,$*)), $($*))
|
||||
|
||||
%-instrec:
|
||||
$(call fc_install_file, $(INSTALL_RECURSIVE), $(subst _,/,$(subst _REC_DIR,,$*)), $($*))
|
||||
|
||||
|
||||
# Use second expansion as variables may be created in included
|
||||
# Makefiles
|
||||
.SECONDEXPANSION:
|
||||
|
||||
# List of all directories
|
||||
installdirs_LIST = $(foreach V, $(filter %_DIR, $(.VARIABLES)), \
|
||||
$(if $(filter file, $(origin $(V))), \
|
||||
$(V)))
|
||||
# List of data directories
|
||||
installdata_LIST = $(filter %_DATA_DIR, $(installdirs_LIST))
|
||||
# List of program directories
|
||||
installprog_LIST = $(filter %_PROG_DIR, $(installdirs_LIST))
|
||||
# List of recursive directories
|
||||
installrec_LIST = $(filter %_REC_DIR, $(installdirs_LIST))
|
||||
|
||||
# Expand directories to create as dependency
|
||||
# Use double-colon to permit user to define additionnal install-dirs
|
||||
install-dirs:: $$(installdirs_LIST)
|
||||
|
||||
# Expand files to install as dependency
|
||||
# Use double-colon to permit user to define additionnal install-files
|
||||
install-files:: install-data-files install-prog-files install-rec-dirs
|
||||
|
||||
install-data-files: $$(patsubst %,%-instdata,$$(installdata_LIST))
|
||||
|
||||
install-prog-files: $$(patsubst %,%-instprog,$$(installprog_LIST))
|
||||
|
||||
install-rec-dirs: $$(patsubst %,%-instrec,$$(installrec_LIST))
|
||||
|
||||
# Installation of python modules
|
||||
ifeq ($(shell test -f setup.py && echo 0), 0)
|
||||
install-files::
|
||||
python setup.py install --no-compile --install-layout=deb $(PYTHON_OPTS)
|
||||
endif
|
||||
|
||||
.PHONY: install install-dirs install-files install-data-files install-prog-files install-rec-dirs
|
76
hooks/graphicsfw
Executable file
76
hooks/graphicsfw
Executable file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
|
||||
SELF_DIR="$(dirname $(readlink -e ${0}))"
|
||||
BASE_DIR="$(dirname $(dirname ${SELF_DIR}))"
|
||||
SCRIPTCOMMON="${BASE_DIR}/scripts_common.sh"
|
||||
|
||||
. ${SCRIPTCOMMON}
|
||||
|
||||
IPTABLES="sudo iptables"
|
||||
XPATH="${BASE_DIR}/datastore/xpath.rb --stdin --base64"
|
||||
|
||||
RULES_FILE="/run/one/one_graphics_rules"
|
||||
|
||||
function one_get_port()
|
||||
{
|
||||
${XPATH} ${1} '/VM/TEMPLATE/GRAPHICS/PORT'
|
||||
}
|
||||
|
||||
function open_port()
|
||||
{
|
||||
declare -a authorized_ip
|
||||
declare -a authorized_netmask
|
||||
|
||||
vm_port=$(one_get_port ${1})
|
||||
[[ -z "${vm_port}" ]] && return 2
|
||||
authorized_ip=( $(CreoleGet ip_ssh_eth0) )
|
||||
[[ -z "${authorized_ip}" ]] && return 2
|
||||
authorized_netmask=( $(CreoleGet netmask_ssh_eth0) )
|
||||
[[ -z "${authorized_netmask}" ]] && return 2
|
||||
|
||||
for ((i = 0; i < ${#authorized_ip[*]}; i +=1))
|
||||
do
|
||||
${IPTABLES} -I eth0-root -s ${authorized_ip[$i]}/${authorized_netmask[$i]} -p tcp -m tcp --dport ${vm_port} --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
echo "/sbin/iptables -A eth0-root -s ${authorized_ip[$i]}/${authorized_netmask[$i]} -p tcp -m tcp --dport ${vm_port} --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT" >> "${RULES_FILE}"
|
||||
fi
|
||||
${IPTABLES} -I eth0-root -s $(CreoleGet one_master_ip) -p tcp -m tcp --dport ${vm_port} --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT
|
||||
[[ ${?} -eq 0 ]] && echo "/sbin/iptables -A eth0-root -s $(CreoleGet one_master_ip) -p tcp -m tcp --dport ${vm_port} --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT" >> "${RULES_FILE}"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function close_port()
|
||||
{
|
||||
vm_port=$(one_get_port ${1})
|
||||
[[ -n "${vm_port}" ]] || return 2
|
||||
rule_ids=$(${IPTABLES} -n --line-numbers -L eth0-root | awk "/dpt:${vm_port}/ {print \$1}")
|
||||
for rule_id in ${rule_ids}
|
||||
do
|
||||
${IPTABLES} -D eth0-root ${rule_id}
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
sed -i "/--dport ${vm_port}/d" "${RULES_FILE}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
action=${1}
|
||||
template=${2}
|
||||
|
||||
case $action in
|
||||
open)
|
||||
open_port ${template}
|
||||
exit $?
|
||||
;;
|
||||
close)
|
||||
close_port ${template}
|
||||
exit $?
|
||||
;;
|
||||
*)
|
||||
echo "Unknown action '$action'" >&2
|
||||
exit 127
|
||||
;;
|
||||
esac
|
83
init/onenode
Executable file
83
init/onenode
Executable file
@ -0,0 +1,83 @@
|
||||
#! /bin/sh
|
||||
### BEGIN INIT INFO
|
||||
# Provides: onenode
|
||||
# Required-Start: creoled libvirt-bin opennebula openvswitch-switch
|
||||
# Required-Stop: creoled libvirt-bin opennebula openvswitch-switch
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Node vm management
|
||||
# Description: Suspend and resume VM of OpenNebula node
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Jaime Melis <jmelis@opennebula.org>
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
DESC="OpenNebula Node"
|
||||
NAME=onevm-all
|
||||
DAEMON=/usr/share/eole/sbin/$NAME
|
||||
DAEMON_ARGS="-w"
|
||||
SCRIPTNAME=/etc/init.d/onenode
|
||||
PID_FILE=/var/run/one/onenode
|
||||
CREDS=/var/lib/one/.one/one_auth
|
||||
|
||||
# Exit if the package is not installed
|
||||
[ -x "$DAEMON" ] || exit 0
|
||||
|
||||
# Load the VERBOSE setting and other rcS variables
|
||||
. /lib/init/vars.sh
|
||||
|
||||
# Define LSB log_* functions.
|
||||
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
do_start()
|
||||
{
|
||||
${DAEMON} ${DAEMON_ARGS} -c ${CREDS} -a "resume"
|
||||
}
|
||||
|
||||
#
|
||||
# Function that stops the daemon/service
|
||||
#
|
||||
do_stop()
|
||||
{
|
||||
${DAEMON} ${DAEMON_ARGS} -c ${CREDS} -a "suspend"
|
||||
}
|
||||
|
||||
do_status()
|
||||
{
|
||||
${DAEMON} ${DAEMON_ARGS} -c ${CREDS} -a "status"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
stop)
|
||||
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
|
||||
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
|
||||
esac
|
||||
;;
|
||||
status)
|
||||
do_status
|
||||
;;
|
||||
restart|force-reload)
|
||||
echo "Not supported action"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
||||
|
||||
:
|
446
postservice/30-one-mng
Executable file
446
postservice/30-one-mng
Executable file
@ -0,0 +1,446 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function error()
|
||||
{
|
||||
MSG=${1}
|
||||
echo "[ERROR][${MSG}]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function get_user_home()
|
||||
{
|
||||
HOMEDIR=$(getent passwd ${1} | cut -d ':' -f 6)
|
||||
echo ${HOMEDIR}
|
||||
}
|
||||
|
||||
function get_one_auth()
|
||||
{
|
||||
CMD="cat"
|
||||
HOME=$(get_user_home oneadmin)
|
||||
FILE="${HOME}/.one/one_auth"
|
||||
${CMD} ${FILE}
|
||||
}
|
||||
|
||||
function check_cluster()
|
||||
{
|
||||
name="${1}"
|
||||
cmd="onecluster"
|
||||
opt="list"
|
||||
auth=$(get_one_auth)
|
||||
|
||||
res=0
|
||||
clst_list=$(${cmd} ${opt} --user ${auth%:*} --password ${auth#*:} | tail -n +2 | awk -F ' ' '{print $2}')
|
||||
for hst in ${clst_list}
|
||||
do
|
||||
[[ "${NAME}" = "${hst}" ]] && res=$((res+1))
|
||||
done
|
||||
return ${res}
|
||||
}
|
||||
|
||||
function manage_cluster()
|
||||
{
|
||||
NAME="${1}"
|
||||
CMD="onecluster create"
|
||||
AUTH=$(get_one_auth)
|
||||
|
||||
check_cluster ${clst_name}
|
||||
if [[ ${?} -eq 0 ]]
|
||||
then
|
||||
crt=$(${CMD} --user ${AUTH%:*} --password ${AUTH#*:} ${NAME})
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
error "Cluster create failed"
|
||||
else
|
||||
echo "Cluster ${NAME} created"
|
||||
fi
|
||||
else
|
||||
echo "Cluster \"${NAME}\" already exist"
|
||||
fi
|
||||
}
|
||||
|
||||
function check_host()
|
||||
{
|
||||
name="${1}"
|
||||
cmd="onehost"
|
||||
opt="list"
|
||||
auth=$(get_one_auth)
|
||||
|
||||
res=0
|
||||
clst_list=$(${cmd} ${opt} --user ${auth%:*} --password ${auth#*:} | tail -n +2 | awk -F ' ' '{print $2}')
|
||||
for hst in ${clst_list}
|
||||
do
|
||||
[[ "${NAME}" = "${hst}" ]] && res=$((res+1))
|
||||
done
|
||||
return ${res}
|
||||
}
|
||||
|
||||
function manage_host()
|
||||
{
|
||||
NAME=${1}
|
||||
CMD="onehost"
|
||||
IM_MAD='kvm'
|
||||
VM_MAD='kvm'
|
||||
VNET_MAD='ovswitch'
|
||||
OPT="create ${NAME} -i ${IM_MAD} -v ${VM_MAD} -n ${VNET_MAD}"
|
||||
AUTH=$(get_one_auth)
|
||||
|
||||
check_host ${NAME}
|
||||
if [[ ${?} -eq 0 ]]
|
||||
then
|
||||
res=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:})
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
error "Host creation failed"
|
||||
else
|
||||
echo "Host ${NAME} created"
|
||||
fi
|
||||
else
|
||||
echo "Host ${NAME} already exist"
|
||||
fi
|
||||
}
|
||||
|
||||
function get_cluster_id_by_name()
|
||||
{
|
||||
name=${1}
|
||||
cmd="onecluster"
|
||||
opt="show ${name}"
|
||||
|
||||
res=$(${cmd} ${opt} --user ${AUTH%:*} --password ${AUTH#*:} | grep ID)
|
||||
if [[ ${?} -eq 0 ]]
|
||||
then
|
||||
echo ${res#*:}
|
||||
return 0
|
||||
else
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Get Host ID by a name
|
||||
#
|
||||
function get_host_id_by_name()
|
||||
{
|
||||
name=${1}
|
||||
cmd="onehost"
|
||||
opt="show ${name}"
|
||||
|
||||
res=$(${cmd} ${opt} --user ${AUTH%:*} --password ${AUTH#*:} | grep "ID.*:")
|
||||
if [[ ${?} -eq 0 ]]
|
||||
then
|
||||
echo ${res#*:}
|
||||
return 0
|
||||
else
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Get Datastore ID by a name
|
||||
#
|
||||
function get_ds_id_by_name()
|
||||
{
|
||||
name=${1}
|
||||
cmd="onedatastore"
|
||||
opt="show ${name}"
|
||||
|
||||
res=$(${cmd} ${opt} --user ${AUTH%:*} --password ${AUTH#*:} | grep "ID.*:")
|
||||
if [[ ${?} -eq 0 ]]
|
||||
then
|
||||
echo ${res#*:}
|
||||
return 0
|
||||
else
|
||||
echo "ERR"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# check_host_in_cluster
|
||||
# if host is attached to cluster : return 0
|
||||
# if host not attached to cluster : return 1
|
||||
#
|
||||
function check_host_in_cluster()
|
||||
{
|
||||
hst=${1}
|
||||
clst=${2}
|
||||
auth=$(get_one_auth)
|
||||
cmd="onehost"
|
||||
opt="show ${hst} --user ${AUTH%:*} --password ${AUTH#*:}"
|
||||
|
||||
RES=$(${cmd} ${opt} | grep CLUSTER)
|
||||
cluster=${RES#*:}
|
||||
# clean Outpu
|
||||
cluster="${cluster#"${cluster%%[![:space:]]*}"}" # remove leading whitespace characters
|
||||
cluster="${cluster%"${cluster##*[![:space:]]}"}" # remove trailing whitespace characters
|
||||
if [[ "${cluster}" = "${clst}" ]]
|
||||
then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Attach a host to a cluster
|
||||
#
|
||||
function attach_host()
|
||||
{
|
||||
HOST=${1}
|
||||
CLST=${2}
|
||||
CLST_ID=$(get_cluster_id_by_name ${CLST})
|
||||
HST_ID=$(get_host_id_by_name ${HOST})
|
||||
AUTH=$(get_one_auth)
|
||||
CMD="onecluster"
|
||||
OPT="addhost ${CLST_ID} ${HST_ID}"
|
||||
|
||||
check_host_in_cluster ${HOST} ${CLST}
|
||||
if [[ ${?} -eq 1 ]]
|
||||
then
|
||||
if [[ -n ${CLST_ID} ]]
|
||||
then
|
||||
if [[ -n ${HST_ID} ]]
|
||||
then
|
||||
RES=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:})
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
error "Attaching ${HOST} to ${CLST} failed"
|
||||
else
|
||||
echo "${HOST} attached to ${CLST}"
|
||||
return 0
|
||||
fi
|
||||
else
|
||||
error "No host id for ${HOST}"
|
||||
fi
|
||||
else
|
||||
error "No Cluster id for ${CLST}"
|
||||
fi
|
||||
else
|
||||
echo "Host ${HOST} already present in cluster ${CLST}"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Attach a datastore to a cluster
|
||||
#
|
||||
function attach_ds_to_cluster()
|
||||
{
|
||||
DS=${1}
|
||||
CLST=${2}
|
||||
CLST_ID=$(get_cluster_id_by_name ${CLST})
|
||||
DS_ID=$(get_ds_id_by_name ${ds_name})
|
||||
AUTH=$(get_one_auth)
|
||||
CMD="onecluster"
|
||||
OPT="adddatastore ${CLST_ID} ${DS_ID}"
|
||||
|
||||
RES=$(${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:})
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
error "Attaching ${DS} to ${CLST} failed."
|
||||
else
|
||||
echo "Datastore ${DS} attached to ${CLST}."
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function create_datastore()
|
||||
{
|
||||
ds_type="${1}"
|
||||
ds_name="${2}"
|
||||
ds_cluster="${3}"
|
||||
|
||||
if [[ $(CreoleGet activer_multinode 2>&1) == 'oui' ]]
|
||||
then
|
||||
SYS_TM_MAD='ssh'
|
||||
ISO_TM_MAD='ssh'
|
||||
IMG_TM_MAD='ssh'
|
||||
else
|
||||
SYS_TM_MAD='shared'
|
||||
ISO_TM_MAD='shared'
|
||||
IMG_TM_MAD='qcow2'
|
||||
fi
|
||||
|
||||
echo "Creating datastore ${ds_name}"
|
||||
TMPL_FILE=$(mktemp)
|
||||
case ${ds_type} in
|
||||
"SYSTEM")
|
||||
cat <<__EOF__ > ${TMPL_FILE}
|
||||
NAME = ${ds_name}
|
||||
TM_MAD = ${SYS_TM_MAD}
|
||||
TYPE = SYSTEM_DS
|
||||
__EOF__
|
||||
;;
|
||||
"ISO")
|
||||
cat <<__EOF__ > ${TMPL_FILE}
|
||||
NAME = ${ds_name}
|
||||
DS_MAD = fs
|
||||
TM_MAD = ${ISO_TM_MAD}
|
||||
TYPE = IMAGE_DS
|
||||
__EOF__
|
||||
;;
|
||||
"IMAGE")
|
||||
cat <<__EOF__ > ${TMPL_FILE}
|
||||
NAME = ${ds_name}
|
||||
DS_MAD = fs
|
||||
TM_MAD = ${ISO_TM_MAD}
|
||||
TYPE = IMAGE_DS
|
||||
__EOF__
|
||||
;;
|
||||
|
||||
*) echo "Nothing to do with ${ds_type}"
|
||||
;;
|
||||
esac
|
||||
|
||||
auth=$(get_one_auth)
|
||||
cmd="onedatastore"
|
||||
#opt="create --user ${AUTH%:*} --password ${AUTH#*:} -c ${ds_cluster} ${TMPL_FILE}"
|
||||
opt="create --user ${AUTH%:*} --password ${AUTH#*:} ${TMPL_FILE}"
|
||||
RUN=$(${cmd} ${opt})
|
||||
if [[ ${?} -eq 0 ]]
|
||||
then
|
||||
attach_ds_to_cluster ${ds_name} ${ds_cluster}
|
||||
rm ${TMPL_FILE}
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function update_datastore()
|
||||
{
|
||||
local auth=${1}
|
||||
local ds_id=${2}
|
||||
local cmd="onedatastore"
|
||||
local opt="show"
|
||||
local multinode=$(CreoleGet activer_multinode 2>&1)
|
||||
ds_type=""
|
||||
ds_mad=""
|
||||
ds_name=""
|
||||
|
||||
TMPL_FILE=$(mktemp)
|
||||
|
||||
if [[ ${multinode} == 'oui' ]]
|
||||
then
|
||||
SYS_TM_MAD='ssh'
|
||||
ISO_TM_MAD='ssh'
|
||||
IMG_TM_MAD='ssh'
|
||||
else
|
||||
SYS_TM_MAD='shared'
|
||||
ISO_TM_MAD='shared'
|
||||
IMG_TM_MAD='qcow2'
|
||||
fi
|
||||
|
||||
out=$(${cmd} ${opt} ${ds_id} --user ${auth%:*} --password ${auth#*:} | \
|
||||
awk -F ':' '/^DATASTORE.*INFORMATION/,/DATASTORE CAPACITY/ {gsub(" |\t",""); print $1 ":" $2 " " }')
|
||||
for line in ${out}
|
||||
do
|
||||
[[ ${line} =~ ^TM_MAD ]] && ds_mad=${line#*:}
|
||||
[[ ${line} =~ ^NAME ]] && ds_name=${line#*:}
|
||||
[[ ${line} =~ ^TYPE ]] && ds_type=${line#*:}
|
||||
done
|
||||
|
||||
if [[ ${ds_name} == "$(CreoleGet one_ds_system_prefix 2>&1)$(CreoleGet one_cluster_name 2>&1)" ]]
|
||||
then
|
||||
cat <<__EOF__ > ${TMPL_FILE}
|
||||
NAME = ${ds_name}
|
||||
TM_MAD = ${SYS_TM_MAD}
|
||||
TYPE = SYSTEM_DS
|
||||
__EOF__
|
||||
elif [[ ${ds_name} == "$(CreoleGet one_ds_iso_name 2>&1)" ]]
|
||||
then
|
||||
cat <<__EOF__ > ${TMPL_FILE}
|
||||
NAME = ${ds_name}
|
||||
DS_MAD = fs
|
||||
TM_MAD = ${ISO_TM_MAD}
|
||||
TYPE = IMAGE_DS
|
||||
__EOF__
|
||||
elif [[ ${ds_name} == "$(CreoleGet one_ds_image_name 2>&1)" ]]
|
||||
then
|
||||
cat <<__EOF__ > ${TMPL_FILE}
|
||||
NAME = ${ds_name}
|
||||
DS_MAD = fs
|
||||
TM_MAD = ${ISO_TM_MAD}
|
||||
TYPE = IMAGE_DS
|
||||
__EOF__
|
||||
else
|
||||
echo "Nothing to do with ${ds_name}"
|
||||
fi
|
||||
|
||||
if [[ -s ${TMPL_FILE} ]]
|
||||
then
|
||||
echo "Updating ${ds_name} datastore"
|
||||
opt="update ${ds_id} --user ${AUTH%:*} --password ${AUTH#*:} ${TMPL_FILE}"
|
||||
RUN=$(${cmd} ${opt})
|
||||
rm ${TMPL_FILE}
|
||||
return ${?}
|
||||
else
|
||||
rm ${TMPL_FILE}
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function manage_datastores()
|
||||
{
|
||||
cluster=${1}
|
||||
AUTH=$(get_one_auth)
|
||||
|
||||
SYSTEM_DS="$(CreoleGet 'one_ds_system_prefix')${cluster}"
|
||||
ISO_DS=$(CreoleGet 'one_ds_iso_name')
|
||||
IMAGE_DS=$(CreoleGet 'one_ds_image_name')
|
||||
|
||||
echo "Configuring datastores for Cluster"
|
||||
sid=$(get_ds_id_by_name ${SYSTEM_DS})
|
||||
if [[ ${sid} = "ERR" ]]
|
||||
then
|
||||
create_datastore "SYSTEM" "${SYSTEM_DS}" "${cluster}"
|
||||
else
|
||||
update_datastore ${AUTH} ${sid}
|
||||
fi
|
||||
|
||||
imgid=$(get_ds_id_by_name ${IMAGE_DS})
|
||||
if [[ ${imgid} = "ERR" ]]
|
||||
then
|
||||
create_datastore "IMAGE" "${IMAGE_DS}" "${cluster}"
|
||||
else
|
||||
update_datastore ${AUTH} ${imgid}
|
||||
fi
|
||||
|
||||
isoid=$(get_ds_id_by_name ${ISO_DS})
|
||||
if [[ ${isoid} = "ERR" ]]
|
||||
then
|
||||
create_datastore "ISO" "${ISO_DS}" "${cluster}"
|
||||
else
|
||||
update_datastore ${AUTH} ${isoid}
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
#
|
||||
# Creating Cluster
|
||||
#
|
||||
clst_name=$(CreoleGet one_cluster_name)
|
||||
manage_cluster ${clst_name}
|
||||
|
||||
#
|
||||
# Creating Host
|
||||
#
|
||||
host=$(CreoleGet nom_machine)
|
||||
manage_host ${host}
|
||||
|
||||
#
|
||||
# Attaching Host to the Cluster
|
||||
#
|
||||
attach_host ${host} ${clst_name}
|
||||
|
||||
#
|
||||
# Création des Datastores
|
||||
#
|
||||
manage_datastores ${clst_name}
|
||||
}
|
||||
|
||||
main
|
345
postservice/31-one-netmng
Executable file
345
postservice/31-one-netmng
Executable file
@ -0,0 +1,345 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from pyeole import ihm
|
||||
from pyeole import process
|
||||
from creole.client import CreoleClient
|
||||
from tempfile import mkstemp
|
||||
|
||||
import sys
|
||||
import os
|
||||
import csv
|
||||
import logging
|
||||
|
||||
LOG_FILE = '/var/log/one/eole-one-node.log'
|
||||
|
||||
#= Configure Logger ===
|
||||
logger = logging.getLogger(__name__)
|
||||
#std_handler = logging.StreamHandler(sys.stdout)
|
||||
file_handler = logging.FileHandler(LOG_FILE)
|
||||
|
||||
logger.setLevel(logging.INFO)
|
||||
#std_handler.setLevel(logging.INFO)
|
||||
file_handler.setLevel(logging.DEBUG)
|
||||
|
||||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
#std_handler.setFormatter(formatter)
|
||||
file_handler.setFormatter(formatter)
|
||||
|
||||
#logger.addHandler(std_handler)
|
||||
logger.addHandler(file_handler)
|
||||
#= End Logger ===
|
||||
|
||||
|
||||
class RunCmdError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class OneClient():
|
||||
|
||||
def __init__(self, user):
|
||||
self.user = None
|
||||
self.auth = None
|
||||
self.root = '/var/lib/one'
|
||||
|
||||
if user:
|
||||
self.user = user
|
||||
else:
|
||||
self.user = 'oneadmin'
|
||||
|
||||
user_info = process.system_out(['getent', 'passwd', user])[1]
|
||||
if user_info:
|
||||
self.root = user_info.split(':')[5]
|
||||
|
||||
command = ['cat', u'{0}/.one/one_auth'.format(self.root)]
|
||||
res = process.system_out(command)
|
||||
if res[0] == 0:
|
||||
self.auth = res[1].split(':')
|
||||
|
||||
def __run_cmd__(self, cmd):
|
||||
cmd.extend(['--user', self.auth[0]])
|
||||
cmd.extend(['--password', self.auth[1]])
|
||||
|
||||
res = process.system_out(cmd)
|
||||
if res[0] == 0:
|
||||
if 'list' in cmd:
|
||||
out_lines = []
|
||||
if res:
|
||||
for line in res[1].split('\n'):
|
||||
if len(line) == 0:
|
||||
next
|
||||
elif 'ID' in line:
|
||||
next
|
||||
else:
|
||||
out_lines.append(line.split())
|
||||
return out_lines
|
||||
else:
|
||||
return res
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_hosts(self):
|
||||
""" get the list of hosts
|
||||
"""
|
||||
cmd = ['onehost', 'list']
|
||||
cmd.extend(['-l', 'ID,NAME'])
|
||||
res = self.__run_cmd__(cmd)
|
||||
return(res)
|
||||
|
||||
def get_clusters(self):
|
||||
""" get the cluster list
|
||||
"""
|
||||
cmd = ['onecluster', 'list']
|
||||
cmd.extend(['-l', 'ID,NAME'])
|
||||
return self.__run_cmd__(cmd)
|
||||
|
||||
def get_networks(self):
|
||||
""" get the virtual network list
|
||||
"""
|
||||
cmd = ['onevnet', 'list']
|
||||
cmd.extend(['-l', 'ID,NAME'])
|
||||
return self.__run_cmd__(cmd)
|
||||
|
||||
def get_cluster_id_by_name(self, name):
|
||||
cmd = ['onecluster', 'list']
|
||||
cmd.extend(['-f', 'NAME={0}'.format(name)])
|
||||
res = self.__run_cmd__(cmd)
|
||||
ID = res[0][0]
|
||||
return ID
|
||||
|
||||
def get_vnet_id_by_name(self, name):
|
||||
cmd = ['onevnet', 'list']
|
||||
cmd.extend(['-f', 'NAME={0}'.format(name)])
|
||||
res = self.__run_cmd__(cmd)
|
||||
ID = res[0][0]
|
||||
return ID
|
||||
|
||||
def create_network(self, templatefile, cluster, vnet_name):
|
||||
""" Create a network
|
||||
"""
|
||||
cmd = ['onevnet', 'create']
|
||||
cmd.extend(['--user', self.auth[0]])
|
||||
cmd.extend(['--password', self.auth[1][:-1]])
|
||||
#cmd.extend(['-c', cluster])
|
||||
cmd.append(templatefile)
|
||||
res = process.system_out(cmd)
|
||||
if res[0] == 0:
|
||||
clt_id = self.get_cluster_id_by_name(cluster)
|
||||
vnet_id = self.get_vnet_id_by_name(vnet_name)
|
||||
res = self.__run_cmd__(['onecluster', 'addvnet', clt_id, vnet_id])
|
||||
os.remove(templatefile)
|
||||
if not res:
|
||||
print("Error attaching {0} vnet to {1} cluster".format(vnet_name, cluster))
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
logger.error("Creation of virtual network with template {0} failed".format(templatefile))
|
||||
return False
|
||||
|
||||
def update_network(self, templatefile, cluster, vnet_name):
|
||||
""" Update a network
|
||||
"""
|
||||
vnet_id = self.get_vnet_id_by_name(vnet_name)
|
||||
cmd = ['onevnet', 'update']
|
||||
cmd.extend(['--user', self.auth[0]])
|
||||
cmd.extend(['--password', self.auth[1][:-1]])
|
||||
cmd.extend([vnet_id, templatefile])
|
||||
|
||||
res = process.system_out(cmd)
|
||||
if res[0] == 0:
|
||||
os.remove(templatefile)
|
||||
return True
|
||||
else:
|
||||
logger.error("Update of virtual network with template {0} failed".format(templatefile))
|
||||
return False
|
||||
|
||||
def delete_network(self, vnet_id):
|
||||
cmd = ['onevnet', 'delete']
|
||||
cmd.extend(['--user', self.auth[0]])
|
||||
cmd.extend(['--password', self.auth[1][:-1]])
|
||||
cmd.append(vnet_id)
|
||||
|
||||
res = process.system_out(cmd)
|
||||
if res[0] == 0:
|
||||
ihm.print_line("Network {0} deleted".format(vnet_id))
|
||||
return True
|
||||
else:
|
||||
logger.error("Error deleting network {0}".format(vnet_id))
|
||||
ihm.print_line("Error deleting network {0}".format(vnet_id))
|
||||
return False
|
||||
|
||||
|
||||
class OneNetwork():
|
||||
def create(self, one_client):
|
||||
tmpl_file = self.create_template()
|
||||
if one_client.create_network(tmpl_file, self.cluster, self.zone):
|
||||
ihm.print_line("Virtual network {0} created".format(self.zone))
|
||||
return True
|
||||
else:
|
||||
ihm.print_line("Error Creating virtual network {0}".format(self.zone))
|
||||
return False
|
||||
|
||||
def update(self, one_client):
|
||||
tmpl_file = self.create_template()
|
||||
if one_client.update_network(tmpl_file, self.cluster, self.zone):
|
||||
ihm.print_line("Virtual network {0} updated".format(self.zone))
|
||||
return True
|
||||
else:
|
||||
ihm.print_line("Error Updating virtual network {0}".format(self.zone))
|
||||
return False
|
||||
|
||||
def manage(self, one_client):
|
||||
found = False
|
||||
vnet = one_client.get_networks()
|
||||
network_name = self.zone
|
||||
for net in vnet:
|
||||
if network_name in net:
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
return self.create(one_client)
|
||||
else:
|
||||
return self.update(one_client)
|
||||
|
||||
class OneNetworkL3(OneNetwork):
|
||||
def __init__(self, net_info, cluster):
|
||||
self.swname = net_info[0]
|
||||
self.zone = u'{0}{1}'.format(net_info[10], net_info[1])
|
||||
self.vlan = net_info[2]
|
||||
self.vnet_addr = net_info[3]
|
||||
self.vnet_mask = net_info[4]
|
||||
self.vnet_gw = net_info[5]
|
||||
self.vnet_rg_start = net_info[6]
|
||||
self.vnet_rg_end = net_info[7]
|
||||
self.vnet_dns = net_info[8]
|
||||
self.vnet_trunk = net_info[9]
|
||||
self.cluster = cluster
|
||||
|
||||
def create_template(self):
|
||||
fd, tmp_path = mkstemp(prefix='oneVnet-')
|
||||
template = open(tmp_path, 'w')
|
||||
template.write('NAME = "{0}"\n'.format(self.zone))
|
||||
if self.vnet_rg_start and self.vnet_rg_end:
|
||||
template.write('TYPE = RANGED\n')
|
||||
template.write('IP_START = {0}\n'.format(self.vnet_rg_start))
|
||||
template.write('IP_END = {0}\n'.format(self.vnet_rg_end))
|
||||
else:
|
||||
template.write('TYPE = FIXED\n')
|
||||
|
||||
if self.vlan:
|
||||
template.write('VLAN = yes\n')
|
||||
template.write('VLAN_ID = {0}\n'.format(self.vlan))
|
||||
|
||||
if self.vnet_trunk:
|
||||
template.write('VLAN_TAGGED_ID = {0}\n'.format(self.vnet_trunk))
|
||||
|
||||
template.write('BRIDGE = {0}\n'.format(self.swname))
|
||||
template.write('NETWORK_ADDRESS = {0}\n'.format(self.vnet_addr))
|
||||
template.write('NETWORK_MASK = {0}\n'.format(self.vnet_mask))
|
||||
template.write('GATEWAY = {0}\n'.format(self.vnet_gw))
|
||||
template.write('DNS = {0}\n'.format(self.vnet_dns))
|
||||
template.close()
|
||||
return tmp_path
|
||||
|
||||
|
||||
class OneNetworkL2(OneNetwork):
|
||||
def __init__(self, net_info, cluster):
|
||||
self.swname = net_info[0]
|
||||
self.zone = u'{0}{1}'.format(net_info[6], net_info[1])
|
||||
self.net_size = net_info[2]
|
||||
self.first_mac = net_info[3]
|
||||
self.tag = net_info[4]
|
||||
self.trunk = net_info[5]
|
||||
self.cluster = cluster
|
||||
|
||||
def create_template(self):
|
||||
fd, tmp_path = mkstemp(prefix='oneVnet-')
|
||||
template = open(tmp_path, 'w')
|
||||
template.write('NAME = "{0}"\n'.format(self.zone))
|
||||
template.write('TYPE = ETHER\n')
|
||||
template.write('SIZE = "{0}"\n'.format(self.net_size))
|
||||
|
||||
if self.tag:
|
||||
template.write('VLAN = yes\n')
|
||||
template.write('VLAN_ID = {0}\n'.format(self.tag))
|
||||
|
||||
if self.trunk:
|
||||
template.write('VLAN_TAGGED_ID = {0}\n'.format(self.trunk))
|
||||
|
||||
template.write('BRIDGE = {0}\n'.format(self.swname))
|
||||
template.close()
|
||||
return tmp_path
|
||||
|
||||
def main():
|
||||
client = CreoleClient()
|
||||
one_client = OneClient('oneadmin')
|
||||
networks = []
|
||||
cluster = client.get_creole('one_cluster_name')
|
||||
swname = client.get_creole('ovs_sw_name')
|
||||
zones = client.get_creole('vnets')
|
||||
vlans = client.get_creole('vnet_vlan_tag')
|
||||
vnet_addr = client.get_creole('vnet_network_addr')
|
||||
vnet_mask = client.get_creole('vnet_network_mask')
|
||||
vnet_dns = client.get_creole('vnet_network_dns')
|
||||
vnet_gw = client.get_creole('vnet_network_gw')
|
||||
vnet_rg_start = client.get_creole('vnet_range_start')
|
||||
vnet_rg_end = client.get_creole('vnet_range_end')
|
||||
vnet_trunk = client.get_creole('vnet_vlan_trunk')
|
||||
|
||||
l2_vnet = client.get_creole('l2_vnets')
|
||||
l2_vnet_size = client.get_creole('l2_vnet_size')
|
||||
l2_vnet_vlan_tag = client.get_creole('l2_vnet_vlan_tag')
|
||||
l2_vnet_vlan_trunk = client.get_creole('l2_vnet_vlan_trunk')
|
||||
l2_vnet_first_mac = client.get_creole('l2_vnet_first_mac')
|
||||
|
||||
net_prefix = "CR_"
|
||||
|
||||
processed = []
|
||||
for cpt in range(len(zones)):
|
||||
if zones[cpt] not in processed:
|
||||
info = []
|
||||
info.append(swname)
|
||||
info.append(zones[cpt])
|
||||
info.append(vlans[cpt])
|
||||
info.append(vnet_addr[cpt])
|
||||
info.append(vnet_mask[cpt])
|
||||
info.append(vnet_gw[cpt])
|
||||
info.append(vnet_rg_start[cpt])
|
||||
info.append(vnet_rg_end[cpt])
|
||||
info.append(vnet_dns[cpt])
|
||||
info.append(vnet_trunk[cpt])
|
||||
info.append(net_prefix)
|
||||
networks.append(OneNetworkL3(info, cluster))
|
||||
processed.append(zones[cpt])
|
||||
|
||||
for i in range(len(l2_vnet)):
|
||||
if l2_vnet[i] not in processed:
|
||||
net_info = []
|
||||
net_info.append(swname)
|
||||
net_info.append(l2_vnet[i])
|
||||
net_info.append(l2_vnet_size[i])
|
||||
net_info.append(l2_vnet_first_mac[i])
|
||||
net_info.append(l2_vnet_vlan_tag[i])
|
||||
net_info.append(l2_vnet_vlan_trunk[i])
|
||||
net_info.append(net_prefix)
|
||||
networks.append(OneNetworkL2(net_info, cluster))
|
||||
processed.append(l2_vnet[i])
|
||||
|
||||
if client.get_creole('activer_openvswitch'):
|
||||
for network in networks:
|
||||
if not network.manage(one_client):
|
||||
exit(1)
|
||||
else:
|
||||
ihm.print_line(u'Open vSwitch disabled no need to configure virtual networks')
|
||||
|
||||
networks = one_client.get_networks()
|
||||
for net in networks:
|
||||
name = net[1]
|
||||
if name.startswith(net_prefix):
|
||||
if not name[3:] in zones and not name[3:] in l2_vnet:
|
||||
one_client.delete_network(net[0])
|
||||
|
||||
exit(0)
|
||||
|
||||
main()
|
10
preservice/30-one-auth
Normal file
10
preservice/30-one-auth
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
auth_mode="$(CreoleGet sunstone_auth_modes)"
|
||||
unlink /var/lib/one/remotes/auth/default 2>/dev/null
|
||||
|
||||
if [ -z "${auth_mode}" ]; then
|
||||
ln -s /var/lib/one/remotes/auth/{dummy,default}
|
||||
else
|
||||
ln -s /var/lib/one/remotes/auth/{${auth_mode},default}
|
||||
fi
|
116
scripts/onehost_create_all
Executable file
116
scripts/onehost_create_all
Executable file
@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Register all Hâpy Cluster Nodes
|
||||
#
|
||||
|
||||
. /usr/lib/eole/ihm.sh
|
||||
|
||||
#
|
||||
# NAME: copy_ssh_id
|
||||
# AIM: Copy the ssh key on the host
|
||||
# PARAM: the hostname of the node
|
||||
#
|
||||
function copy_ssh_id()
|
||||
{
|
||||
local ip=${1}
|
||||
su - ${ONEUSER} -c "ssh-copy-id ${ip}"
|
||||
}
|
||||
|
||||
#
|
||||
# NAME: register_node
|
||||
# AIM: register the node in OpenNebula master
|
||||
# PARAM: the node hostname
|
||||
#
|
||||
function register_node()
|
||||
{
|
||||
cmd="onehost create -i kvm -v kvm -n ovswitch -c \"$(CreoleGet one_cluster_name)\" ${1}"
|
||||
ret=$(su - ${ONEUSER} -c -- "${cmd}")
|
||||
return $?
|
||||
}
|
||||
|
||||
#
|
||||
# NAME: wait_node_ok
|
||||
# AIM: Wait until the node is OK or ERROR
|
||||
# PARAM: The node name
|
||||
#
|
||||
function wait_node_ok()
|
||||
{
|
||||
local RET=0
|
||||
local cmd="onehost show ${1} | awk '/^STATE/ {print \$3}'"
|
||||
local spinstr='|/-\'
|
||||
local delay=0.75
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
st=$(su - ${ONEUSER} -c "${cmd}")
|
||||
[[ ${st} == "MONITORED" ]] && break
|
||||
[[ ${st} == '' ]] && break
|
||||
if [[ ${st} == "ERROR" ]]
|
||||
then
|
||||
RET=2
|
||||
break
|
||||
fi
|
||||
|
||||
local temp=${spinstr#?}
|
||||
printf " [%c] " "$spinstr"
|
||||
local spinstr=$temp${spinstr%"$temp"}
|
||||
sleep $delay
|
||||
printf "\b\b\b\b\b\b"
|
||||
|
||||
done
|
||||
printf " \b\b\b\b"
|
||||
return ${RET}
|
||||
}
|
||||
|
||||
#
|
||||
# MAIN
|
||||
#
|
||||
HAPY_ACTIF=$(echo $(CreoleGet activer_onesinglenode))
|
||||
if [[ $HAPY_ACTIF == "non" ]]
|
||||
then
|
||||
EchoRouge "Le serveur de virtualisation n'est pas activé dans l'interface de configuration du module"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HAPY_NODE_SUPPORT=$(echo $(CreoleGet activer_multinode))
|
||||
if [[ $HAPY_NODE_SUPPORT == "non" ]]
|
||||
then
|
||||
EchoRouge "Le mode multi-noeuds n'est pas activé dans l'interface de configuration du module"
|
||||
exit 1
|
||||
fi
|
||||
declare -a HAPY_SLV=('')
|
||||
declare -a HAPY_SLV_IP=('')
|
||||
ONEUSER=$(CreoleGet virt_user)
|
||||
HAPY_SLV=$(echo $(CreoleGet one_nodes) | sed -e "s/\n/ /g")
|
||||
HAPY_SLV_IP=$(echo $(CreoleGet node_ip) | sed -e "s/\n/ /g")
|
||||
|
||||
echo -e "\n"
|
||||
EchoBleu "Vous allez inscrire un noeud dans une grappe Hâpy"
|
||||
EchoBleu "Pour ce faire vous devez vous munir du mot de passe de l'utilisateur 'oneadmin' de chacun des noeuds"
|
||||
Question_ouinon "Voulez-vous commencer ?" 'True' "oui"
|
||||
if [[ $? -ne 0 ]]
|
||||
then
|
||||
EchoOrange "Abandon de l'enregistrement"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for ((i = 0; i < ${#HAPY_SLV[*]}; i +=1))
|
||||
do
|
||||
echo -e "\n"
|
||||
EchoOrange "Traitement du noeud ${HAPY_SLV[${i}]}"
|
||||
echo
|
||||
EchoVert " * Gestion des clés SSH"
|
||||
echo
|
||||
copy_ssh_id ${HAPY_SLV_IP[${i}]}
|
||||
EchoVert " * Enregistrement du noeud"
|
||||
register_node ${HAPY_SLV[${i}]}
|
||||
wait_node_ok ${HAPY_SLV[${i}]}
|
||||
if [[ ${?} -ne 0 ]]
|
||||
then
|
||||
EchoRouge "Erreur lors de l'enregistrement du noeud ${HAPY_SLV[${i}]} !"
|
||||
fi
|
||||
done
|
||||
|
||||
echo -e "\n"
|
||||
EchoVert "Enregistrement des noeuds terminé"
|
181
scripts/onevm-all
Executable file
181
scripts/onevm-all
Executable file
@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
##############################################################################
|
||||
# Environment Configuration
|
||||
##############################################################################
|
||||
ONE_LOCATION=ENV["ONE_LOCATION"]
|
||||
USER=ENV["user"]
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION="/usr/lib/one/ruby"
|
||||
else
|
||||
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
|
||||
end
|
||||
|
||||
$: << RUBY_LIB_LOCATION
|
||||
|
||||
##############################################################################
|
||||
# Required libraries
|
||||
##############################################################################
|
||||
require 'opennebula'
|
||||
require 'optparse'
|
||||
|
||||
include OpenNebula
|
||||
|
||||
MAXWAIT=60
|
||||
INTERVAL=1
|
||||
|
||||
def _wait(vm, st)
|
||||
wait = 0
|
||||
while vm.status != st
|
||||
vm.info
|
||||
if vm.status == 'unkn'
|
||||
break
|
||||
end
|
||||
wait += INTERVAL
|
||||
sleep(INTERVAL)
|
||||
if wait >= MAXWAIT
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def CreoleGet(variable)
|
||||
begin
|
||||
value = `CreoleGet #{variable}`
|
||||
return value
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# NAME: _do_suspend
|
||||
# PARAM: OpenNebula::VirtualMachine object
|
||||
# AIM: Suspend a virtual machine
|
||||
#
|
||||
def _do_suspend(vm, wait)
|
||||
if vm.status == "runn"
|
||||
puts("Suspending #{vm.name} ...")
|
||||
vm.suspend
|
||||
if wait
|
||||
_wait(vm, "susp")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# NAME: _do_resume
|
||||
# PARAM: OpenNebula::VirtualMachine object
|
||||
# AIM: Resum a suspended virtual machines
|
||||
#
|
||||
def _do_resume(vm, wait)
|
||||
if vm.status == "susp"
|
||||
puts("Resume on #{vm.name}")
|
||||
vm.resume
|
||||
elsif vm.status == 'unkn'
|
||||
puts("Boot on #{vm.name}")
|
||||
vm.boot
|
||||
else
|
||||
return -1
|
||||
end
|
||||
if wait
|
||||
_wait(vm, "runn")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
options = {:creds => nil, :action => nil, :endpoint => nil}
|
||||
|
||||
parser = OptionParser.new do|opts|
|
||||
opts.banner = "Usage: #{File.basename(__FILE__)} [options]"
|
||||
opts.on('-c', '--creds file', 'Crediential file') do |value|
|
||||
options[:creds] = value;
|
||||
end
|
||||
|
||||
opts.on('-a', '--action action', 'Action to run') do |value|
|
||||
options[:action] = value;
|
||||
end
|
||||
|
||||
opts.on('-e', '--end-point url', 'End point URL') do |value|
|
||||
options[:endpoint] = value;
|
||||
end
|
||||
|
||||
opts.on('-w', '--wait', 'Wait for action ends') do |w|
|
||||
options[:wait] = w
|
||||
end
|
||||
|
||||
opts.on('-h', '--help', 'Displays Help') do
|
||||
puts opts
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
parser.parse!
|
||||
|
||||
# OpenNebula credentials
|
||||
|
||||
if not options[:creds]
|
||||
options[:creds] = "/var/lib/one/.one/one_auth"
|
||||
end
|
||||
|
||||
if not options[:action]
|
||||
options[:action] = "status"
|
||||
end
|
||||
|
||||
if not options[:endpoint]
|
||||
ip = CreoleGet('adresse_ip_eth0').chomp
|
||||
options[:endpoint] = "http://#{ip}:2633/RPC2"
|
||||
end
|
||||
|
||||
# Actions
|
||||
SUPPORTED = ['status', 'boot', 'resume', 'shutdown', 'suspend']
|
||||
|
||||
|
||||
if not SUPPORTED.include?(options[:action])
|
||||
puts("Action : #{options[:action]}) is not supported")
|
||||
exit -1
|
||||
end
|
||||
|
||||
begin
|
||||
File.readlines(options[:creds]).each do |line|
|
||||
CREDENTIALS = line
|
||||
end
|
||||
rescue
|
||||
puts("#{options[:creds]}: Problem loading credentials, check if file exists.")
|
||||
exit -1
|
||||
end
|
||||
|
||||
begin
|
||||
client = Client.new(CREDENTIALS, options[:endpoint])
|
||||
|
||||
vm_pool = VirtualMachinePool.new(client, -1)
|
||||
|
||||
rc = vm_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
puts rc.message
|
||||
exit -1
|
||||
end
|
||||
|
||||
vm_pool.each do |vm|
|
||||
case options[:action]
|
||||
when "status"
|
||||
puts("#{vm.name}\t#{vm.status}")
|
||||
when "boot"
|
||||
if vm.status == "unkn"
|
||||
puts("Booting #{vm.name} ...")
|
||||
vm.boot
|
||||
end
|
||||
when "suspend"
|
||||
_do_suspend(vm, options[:wait])
|
||||
when "resume"
|
||||
_do_resume(vm, options[:wait])
|
||||
else
|
||||
puts("#{vm.name}\t#{vm.status}")
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
exit -1
|
||||
end
|
||||
exit 0
|
792
tmpl/oned.conf
Normal file
792
tmpl/oned.conf
Normal file
@ -0,0 +1,792 @@
|
||||
#*******************************************************************************
|
||||
# OpenNebula Configuration file
|
||||
#*******************************************************************************
|
||||
|
||||
#*******************************************************************************
|
||||
# Daemon configuration attributes
|
||||
#-------------------------------------------------------------------------------
|
||||
# MANAGER_TIMER: Time in seconds the core uses to evaluate periodical functions.
|
||||
# MONITORING_INTERVAL cannot have a smaller value than MANAGER_TIMER.
|
||||
#
|
||||
# MONITORING_INTERVAL: Time in seconds between host and VM monitorization.
|
||||
#
|
||||
# MONITORING_THREADS: Max. number of threads used to process monitor messages
|
||||
#
|
||||
# HOST_PER_INTERVAL: Number of hosts monitored in each interval.
|
||||
# HOST_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring
|
||||
# information. Use 0 to disable HOST monitoring recording.
|
||||
#
|
||||
# VM_INDIVIDUAL_MONITORING: VM monitoring information is obtained along with the
|
||||
# host information. For some custom monitor drivers you may need activate the
|
||||
# individual VM monitoring process.
|
||||
# VM_PER_INTERVAL: Number of VMs monitored in each interval, if the individual
|
||||
# VM monitoring is set to yes.
|
||||
# VM_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring
|
||||
# information. Use 0 to disable VM monitoring recording.
|
||||
#
|
||||
# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management
|
||||
# scripts.
|
||||
#
|
||||
# PORT: Port where oned will listen for xmlrpc calls.
|
||||
#
|
||||
# DB: Configuration attributes for the database backend
|
||||
# backend : can be sqlite or mysql (default is sqlite)
|
||||
# server : (mysql) host name or an IP address for the MySQL server
|
||||
# port : (mysql) port for the connection to the server.
|
||||
# If set to 0, the default port is used.
|
||||
# user : (mysql) user's MySQL login ID
|
||||
# passwd : (mysql) the password for user
|
||||
# db_name : (mysql) the database name
|
||||
#
|
||||
# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT +
|
||||
# VMID
|
||||
#
|
||||
# LOG: Configuration for the logging system
|
||||
# system: defines the logging system:
|
||||
# file to log in the oned.log file
|
||||
# syslog to use the syslog facilities
|
||||
# debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
|
||||
#
|
||||
# VM_SUBMIT_ON_HOLD: Forces VMs to be created on hold state instead of pending.
|
||||
# Values: YES or NO.
|
||||
#*******************************************************************************
|
||||
|
||||
LOG = [
|
||||
system = "file",
|
||||
debug_level = 3
|
||||
]
|
||||
|
||||
#MANAGER_TIMER = 30
|
||||
|
||||
MONITORING_INTERVAL = 60
|
||||
MONITORING_THREADS = 50
|
||||
|
||||
#HOST_PER_INTERVAL = 15
|
||||
#HOST_MONITORING_EXPIRATION_TIME = 43200
|
||||
|
||||
#VM_INDIVIDUAL_MONITORING = "no"
|
||||
#VM_PER_INTERVAL = 5
|
||||
#VM_MONITORING_EXPIRATION_TIME = 14400
|
||||
|
||||
SCRIPTS_REMOTE_DIR=/var/tmp/one
|
||||
|
||||
PORT = 2633
|
||||
|
||||
DB = [ backend = "sqlite" ]
|
||||
|
||||
# Sample configuration for MySQL
|
||||
# DB = [ backend = "mysql",
|
||||
# server = "localhost",
|
||||
# port = 0,
|
||||
# user = "oneadmin",
|
||||
# passwd = "oneadmin",
|
||||
# db_name = "opennebula" ]
|
||||
|
||||
VNC_BASE_PORT = 5900
|
||||
|
||||
#VM_SUBMIT_ON_HOLD = "NO"
|
||||
|
||||
#*******************************************************************************
|
||||
# Federation configuration attributes
|
||||
#-------------------------------------------------------------------------------
|
||||
# Control the federation capabilities of oned. Operation in a federated setup
|
||||
# requires a special DB configuration.
|
||||
#
|
||||
# FEDERATION: Federation attributes
|
||||
# MODE: Operation mode of this oned.
|
||||
# STANDALONE no federated.This is the default operational mode
|
||||
# MASTER this oned is the master zone of the federation
|
||||
# SLAVE this oned is a slave zone
|
||||
# ZONE_ID: The zone ID as returned by onezone command
|
||||
# MASTER_ONED: The xml-rpc endpoint of the master oned, e.g.
|
||||
# http://master.one.org:2633/RPC2
|
||||
#*******************************************************************************
|
||||
|
||||
FEDERATION = [
|
||||
MODE = "STANDALONE",
|
||||
ZONE_ID = 0,
|
||||
MASTER_ONED = ""
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
# XML-RPC server configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
# These are configuration parameters for oned's xmlrpc-c server
|
||||
#
|
||||
# MAX_CONN: Maximum number of simultaneous TCP connections the server
|
||||
# will maintain
|
||||
#
|
||||
# MAX_CONN_BACKLOG: Maximum number of TCP connections the operating system
|
||||
# will accept on the server's behalf without the server accepting them from
|
||||
# the operating system
|
||||
#
|
||||
# KEEPALIVE_TIMEOUT: Maximum time in seconds that the server allows a
|
||||
# connection to be open between RPCs
|
||||
#
|
||||
# KEEPALIVE_MAX_CONN: Maximum number of RPCs that the server will execute on
|
||||
# a single connection
|
||||
#
|
||||
# TIMEOUT: Maximum time in seconds the server will wait for the client to
|
||||
# do anything while processing an RPC
|
||||
#
|
||||
# RPC_LOG: Create a separated log file for xml-rpc requests, in
|
||||
# "/var/log/one/one_xmlrpc.log".
|
||||
#
|
||||
# MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses. Only relevant for
|
||||
# slave zones.
|
||||
#*******************************************************************************
|
||||
|
||||
#MAX_CONN = 15
|
||||
#MAX_CONN_BACKLOG = 15
|
||||
#KEEPALIVE_TIMEOUT = 15
|
||||
#KEEPALIVE_MAX_CONN = 30
|
||||
#TIMEOUT = 15
|
||||
#RPC_LOG = NO
|
||||
#MESSAGE_SIZE = 1073741824
|
||||
|
||||
#*******************************************************************************
|
||||
# Physical Networks configuration
|
||||
#*******************************************************************************
|
||||
# NETWORK_SIZE: Here you can define the default size for the virtual networks
|
||||
#
|
||||
# MAC_PREFIX: Default MAC prefix to be used to create the auto-generated MAC
|
||||
# addresses is defined here (this can be overrided by the Virtual Network
|
||||
# template)
|
||||
#*******************************************************************************
|
||||
|
||||
NETWORK_SIZE = 254
|
||||
|
||||
MAC_PREFIX = "02:00"
|
||||
|
||||
#*******************************************************************************
|
||||
# DataStore Configuration
|
||||
#*******************************************************************************
|
||||
# DATASTORE_LOCATION: *Default* Path for Datastores in the hosts. It IS the
|
||||
# same for all the hosts in the cluster. DATASTORE_LOCATION IS ONLY FOR THE
|
||||
# HOSTS AND *NOT* THE FRONT-END. It defaults to /var/lib/one/datastores (or
|
||||
# $ONE_LOCATION/var/datastores in self-contained mode)
|
||||
#
|
||||
# You can define a different DATASTORE_LOCATION in each cluster by updating
|
||||
# its properties with onecluster update.
|
||||
#
|
||||
# DATASTORE_BASE_PATH: This is the base path for the SOURCE attribute of
|
||||
# the images registered in a Datastore. This is a default value, that can be
|
||||
# changed when the datastore is created.
|
||||
#
|
||||
# DATASTORE_CAPACITY_CHECK: Checks that there is enough capacity before
|
||||
# creating a new imag. Defaults to Yes
|
||||
#
|
||||
# DEFAULT_IMAGE_TYPE: This can take values
|
||||
# OS Image file holding an operating system
|
||||
# CDROM Image file holding a CDROM
|
||||
# DATABLOCK Image file holding a datablock,
|
||||
# always created as an empty block
|
||||
#
|
||||
# DEFAULT_DEVICE_PREFIX: This can be set to
|
||||
# hd IDE prefix
|
||||
# sd SCSI
|
||||
# xvd XEN Virtual Disk
|
||||
# vd KVM virtual disk
|
||||
#
|
||||
# DEFAULT_CDROM_DEVICE_PREFIX: Same as above but for CDROM devices.
|
||||
#*******************************************************************************
|
||||
|
||||
#DATASTORE_LOCATION = /var/lib/one/datastores
|
||||
|
||||
#DATASTORE_BASE_PATH = /var/lib/one/datastores
|
||||
|
||||
DATASTORE_CAPACITY_CHECK = "yes"
|
||||
|
||||
DEFAULT_IMAGE_TYPE = "OS"
|
||||
DEFAULT_DEVICE_PREFIX = "hd"
|
||||
|
||||
DEFAULT_CDROM_DEVICE_PREFIX = "hd"
|
||||
|
||||
#*******************************************************************************
|
||||
# Information Driver Configuration
|
||||
#*******************************************************************************
|
||||
# You can add more information managers with different configurations but make
|
||||
# sure it has different names.
|
||||
#
|
||||
# name : name for this information manager
|
||||
#
|
||||
# executable: path of the information driver executable, can be an
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ if OpenNebula was installed in /)
|
||||
#
|
||||
# arguments : for the driver executable, usually a probe configuration file,
|
||||
# can be an absolute path or relative to $ONE_LOCATION/etc (or
|
||||
# /etc/one/ if OpenNebula was installed in /)
|
||||
#*******************************************************************************
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Information Collector for KVM and Xen IM's.
|
||||
#-------------------------------------------------------------------------------
|
||||
# This driver CANNOT BE ASSIGNED TO A HOST, and needs to be used with KVM or
|
||||
# Xen drivers
|
||||
# -h prints this help.
|
||||
# -a Address to bind the collectd sockect (defults 0.0.0.0)
|
||||
# -p UDP port to listen for monitor information (default 4124)
|
||||
# -f Interval in seconds to flush collected information (default 5)
|
||||
# -t Number of threads for the server (defult 50)
|
||||
# -i Time in seconds of the monitorization push cycle. This parameter must
|
||||
# be smaller than MONITORING_INTERVAL, otherwise push monitorization will
|
||||
# not be effective.
|
||||
#-------------------------------------------------------------------------------
|
||||
IM_MAD = [
|
||||
name = "collectd",
|
||||
executable = "collectd",
|
||||
arguments = "-p 4124 -f 5 -t 50 -i 20" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# KVM UDP-push Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
IM_MAD = [
|
||||
name = "kvm",
|
||||
executable = "one_im_ssh",
|
||||
arguments = "-r 3 -t 15 kvm" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# KVM SSH-pull Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
# IM_MAD = [
|
||||
# name = "kvm",
|
||||
# executable = "one_im_ssh",
|
||||
# arguments = "-r 3 -t 15 kvm-probes" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# XEN UDP-push Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Driver for Xen 3.x
|
||||
#IM_MAD = [
|
||||
# name = "xen",
|
||||
# executable = "one_im_ssh",
|
||||
# arguments = "-r 3 -t 15 xen3" ]
|
||||
|
||||
# Driver for Xen 4.x
|
||||
#IM_MAD = [
|
||||
# name = "xen",
|
||||
# executable = "one_im_ssh",
|
||||
# arguments = "-r 3 -t 15 xen4" ]
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# XEN SSH-pull Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Driver for Xen 3.x
|
||||
#IM_MAD = [
|
||||
# name = "xen",
|
||||
# executable = "one_im_ssh",
|
||||
# arguments = "-r 0 -t 15 xen3-probes" ]
|
||||
|
||||
# Driver for Xen 4.x
|
||||
#IM_MAD = [
|
||||
# name = "xen",
|
||||
# executable = "one_im_ssh",
|
||||
# arguments = "-r 0 -t 15 xen4-probes" ]
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# VMware Information Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "vmware",
|
||||
# executable = "one_im_sh",
|
||||
# arguments = "-c -t 15 -r 0 vmware" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# EC2 Information Driver Manager Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [
|
||||
# name = "ec2",
|
||||
# executable = "one_im_sh",
|
||||
# arguments = "-c -t 1 -r 0 ec2" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dummy Information Driver Manager Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
#IM_MAD = [ name="dummy", executable="one_im_dummy"]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#*******************************************************************************
|
||||
# Virtualization Driver Configuration
|
||||
#*******************************************************************************
|
||||
# You can add more virtualization managers with different configurations but
|
||||
# make sure it has different names.
|
||||
#
|
||||
# name : name of the virtual machine manager driver
|
||||
#
|
||||
# executable: path of the virtualization driver executable, can be an
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ if OpenNebula was installed in /)
|
||||
#
|
||||
# arguments : for the driver executable
|
||||
#
|
||||
# default : default values and configuration parameters for the driver, can
|
||||
# be an absolute path or relative to $ONE_LOCATION/etc (or
|
||||
# /etc/one/ if OpenNebula was installed in /)
|
||||
#
|
||||
# type : driver type, supported drivers: xen, kvm, xml
|
||||
#*******************************************************************************
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# KVM Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
# -l <actions[=command_name]> actions executed locally, command can be
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate=migrate_local,save"
|
||||
#
|
||||
# Note: You can use type = "qemu" to use qemu emulated guests, e.g. if your
|
||||
# CPU does not have virtualization extensions or use nested Qemu-KVM hosts
|
||||
#-------------------------------------------------------------------------------
|
||||
VM_MAD = [
|
||||
name = "kvm",
|
||||
executable = "one_vmm_exec",
|
||||
arguments = "-t 15 -r 0 kvm",
|
||||
default = "vmm_exec/vmm_exec_kvm.conf",
|
||||
type = "kvm" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# XEN Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
# -l <actions[=command_name]> actions executed locally, command can be
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate,save"
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Driver for Xen 3.x
|
||||
#VM_MAD = [
|
||||
# name = "xen",
|
||||
# executable = "one_vmm_exec",
|
||||
# arguments = "-t 15 -r 0 xen3",
|
||||
# default = "vmm_exec/vmm_exec_xen3.conf",
|
||||
# type = "xen" ]
|
||||
|
||||
# Driver for Xen 4.x
|
||||
#VM_MAD = [
|
||||
# name = "xen",
|
||||
# executable = "one_vmm_exec",
|
||||
# arguments = "-t 15 -r 0 xen4",
|
||||
# default = "vmm_exec/vmm_exec_xen4.conf",
|
||||
# type = "xen" ]
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# VMware Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of hosts monitored at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [
|
||||
# name = "vmware",
|
||||
# executable = "one_vmm_sh",
|
||||
# arguments = "-t 15 -r 0 vmware -s sh",
|
||||
# default = "vmm_exec/vmm_exec_vmware.conf",
|
||||
# type = "vmware" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# EC2 Virtualization Driver Manager Configuration
|
||||
# -r number of retries when monitoring a host
|
||||
# -t number of threads, i.e. number of actions performed at the same time
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [
|
||||
# name = "ec2",
|
||||
# executable = "one_vmm_sh",
|
||||
# arguments = "-t 15 -r 0 ec2",
|
||||
# type = "xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Dummy Virtualization Driver Configuration
|
||||
#-------------------------------------------------------------------------------
|
||||
#VM_MAD = [ name="dummy", executable="one_vmm_dummy", type="xml" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#*******************************************************************************
|
||||
# Transfer Manager Driver Configuration
|
||||
#*******************************************************************************
|
||||
# You can add more transfer managers with different configurations but make
|
||||
# sure it has different names.
|
||||
# name : name for this transfer driver
|
||||
#
|
||||
# executable: path of the transfer driver executable, can be an
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ if OpenNebula was installed in /)
|
||||
# arguments :
|
||||
# -t: number of threads, i.e. number of transfers made at the same time
|
||||
# -d: list of transfer drivers separated by commas, if not defined all the
|
||||
# drivers available will be enabled
|
||||
#*******************************************************************************
|
||||
|
||||
TM_MAD = [
|
||||
executable = "one_tm",
|
||||
arguments = "-t 15 -d dummy,lvm,shared,fs_lvm,qcow2,ssh,vmfs,ceph"
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
# Datastore Driver Configuration
|
||||
#*******************************************************************************
|
||||
# Drivers to manage the datastores, specialized for the storage backend
|
||||
# executable: path of the transfer driver executable, can be an
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ if OpenNebula was installed in /)
|
||||
#
|
||||
# arguments : for the driver executable
|
||||
# -t number of threads, i.e. number of repo operations at the same time
|
||||
# -d datastore mads separated by commas
|
||||
#*******************************************************************************
|
||||
|
||||
DATASTORE_MAD = [
|
||||
executable = "one_datastore",
|
||||
arguments = "-t 15 -d dummy,fs,vmfs,lvm,ceph"
|
||||
]
|
||||
|
||||
#*******************************************************************************
|
||||
# Hook Manager Configuration
|
||||
#*******************************************************************************
|
||||
# The Driver (HM_MAD)
|
||||
# -----------------------------------------------
|
||||
#
|
||||
# Used to execute the Hooks:
|
||||
# executable: path of the hook driver executable, can be an
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ if OpenNebula was installed in /)
|
||||
#
|
||||
# arguments : for the driver executable, can be an absolute path or relative
|
||||
# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed
|
||||
# in /)
|
||||
#
|
||||
# Virtual Machine Hooks (VM_HOOK)
|
||||
# -------------------------------
|
||||
#
|
||||
# Defined by:
|
||||
# name : for the hook, useful to track the hook (OPTIONAL)
|
||||
# on : when the hook should be executed,
|
||||
# - CREATE, when the VM is created (onevm create)
|
||||
# - PROLOG, when the VM is in the prolog state
|
||||
# - RUNNING, after the VM is successfully booted
|
||||
# - UNKNOWN, when the VM is in the unknown state
|
||||
# - SHUTDOWN, after the VM is shutdown
|
||||
# - STOP, after the VM is stopped (including VM image transfers)
|
||||
# - DONE, after the VM is deleted or shutdown
|
||||
# - FAILED, when the VM enters the failed state
|
||||
# - CUSTOM, user defined specific STATE and LCM_STATE combination
|
||||
# of states to trigger the hook.
|
||||
# command : path is relative to $ONE_LOCATION/var/remotes/hook
|
||||
# (self-contained) or to /var/lib/one/remotes/hook (system-wide).
|
||||
# That directory will be copied on the hosts under
|
||||
# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist
|
||||
# on the target host
|
||||
# arguments : for the hook. You can access to VM information with $
|
||||
# - $ID, the ID of the virtual machine
|
||||
# - $TEMPLATE, the VM template in xml and base64 encoded
|
||||
# - $PREV_STATE, the previous STATE of the Virtual Machine
|
||||
# - $PREV_LCM_STATE, the previous LCM STATE of the Virtual Machine
|
||||
# remote : values,
|
||||
# - YES, The hook is executed in the host where the VM was
|
||||
# allocated
|
||||
# - NO, The hook is executed in the OpenNebula server (default)
|
||||
#
|
||||
# Example Virtual Machine Hook
|
||||
# ----------------------------
|
||||
#
|
||||
# VM_HOOK = [
|
||||
# name = "advanced_hook",
|
||||
# on = "CUSTOM",
|
||||
# state = "ACTIVE",
|
||||
# lcm_state = "BOOT_UNKNOWN",
|
||||
# command = "log.rb",
|
||||
# arguments = "$ID $PREV_STATE $PREV_LCM_STATE" ]
|
||||
#
|
||||
# Host Hooks (HOST_HOOK)
|
||||
# -------------------------------
|
||||
#
|
||||
# Defined by:
|
||||
# name : for the hook, useful to track the hook (OPTIONAL)
|
||||
# on : when the hook should be executed,
|
||||
# - CREATE, when the Host is created (onehost create)
|
||||
# - ERROR, when the Host enters the error state
|
||||
# - DISABLE, when the Host is disabled
|
||||
# command : path is relative to $ONE_LOCATION/var/remotes/hook
|
||||
# (self-contained) or to /var/lib/one/remotes/hook (system-wide).
|
||||
# That directory will be copied on the hosts under
|
||||
# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist
|
||||
# on the target host.
|
||||
# arguments : for the hook. You can use the following Host information:
|
||||
# - $ID, the ID of the host
|
||||
# - $TEMPLATE, the Host template in xml and base64 encoded
|
||||
# remote : values,
|
||||
# - YES, The hook is executed in the host
|
||||
# - NO, The hook is executed in the OpenNebula server (default)
|
||||
#
|
||||
# Virtual Network (VNET_HOOK)
|
||||
# User (USER_HOOK)
|
||||
# Group (GROUP_HOOK)
|
||||
# Image (IMAGE_HOOK)
|
||||
# -------------------------------
|
||||
#
|
||||
# These hooks are executed when one of the referring entities are created or
|
||||
# removed. Each hook is defined by:
|
||||
# name : for the hook, useful to track the hook (OPTIONAL)
|
||||
# on : when the hook should be executed,
|
||||
# - CREATE, when the vnet is created
|
||||
# - REMOVE, when the vnet is removed
|
||||
# command : path is relative to $ONE_LOCATION/var/remotes/hook
|
||||
# (self-contained) or to /var/lib/one/remotes/hook (system-wide).
|
||||
# That directory will be copied on the hosts under
|
||||
# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist
|
||||
# on the target host.
|
||||
# arguments : for the hook. You can use the following Host information:
|
||||
# - $ID, the ID of the host
|
||||
# - $TEMPLATE, the vnet template in xml and base64 encoded
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
VM_HOOK = [
|
||||
name = "open_ports",
|
||||
on = "RUNNING",
|
||||
command = "eole/graphicsfw",
|
||||
arguments = "open $TEMPLATE",
|
||||
remote = "YES"
|
||||
]
|
||||
|
||||
VM_HOOK = [
|
||||
name = "close_ports",
|
||||
on = "DONE",
|
||||
command = "eole/graphicsfw",
|
||||
arguments = "close $TEMPLATE",
|
||||
remote = "YES"
|
||||
]
|
||||
|
||||
VM_HOOK = [
|
||||
name = "close_ports",
|
||||
on = "STOP",
|
||||
command = "eole/graphicsfw",
|
||||
arguments = "close $TEMPLATE",
|
||||
remote = "YES"
|
||||
]
|
||||
|
||||
VM_HOOK = [
|
||||
name = "close_ports",
|
||||
on = "SHUTDOWN",
|
||||
command = "eole/graphicsfw",
|
||||
arguments = "close $TEMPLATE",
|
||||
remote = "YES"
|
||||
]
|
||||
|
||||
HM_MAD = [
|
||||
executable = "one_hm" ]
|
||||
|
||||
#*******************************************************************************
|
||||
# Fault Tolerance Hooks
|
||||
#*******************************************************************************
|
||||
# This hook is used to perform recovery actions when a host fails.
|
||||
# Script to implement host failure tolerance
|
||||
# It can be set to
|
||||
# -r recreate VMs running in the host
|
||||
# -d delete VMs running in the host
|
||||
# Additional flags
|
||||
# -f force resubmission of suspended VMs
|
||||
# -p <n> avoid resubmission if host comes
|
||||
# back after n monitoring cycles
|
||||
#*******************************************************************************
|
||||
#
|
||||
#HOST_HOOK = [
|
||||
# name = "error",
|
||||
# on = "ERROR",
|
||||
# command = "ft/host_error.rb",
|
||||
# arguments = "$ID -r",
|
||||
# remote = "no" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
# These two hooks can be used to automatically delete or resubmit VMs that reach
|
||||
# the "failed" state. This way, the administrator doesn't have to interact
|
||||
# manually to release its resources or retry the deployment.
|
||||
#
|
||||
#
|
||||
# Only one of them should be uncommented.
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
#VM_HOOK = [
|
||||
# name = "on_failure_delete",
|
||||
# on = "FAILED",
|
||||
# command = "/usr/bin/env onevm delete",
|
||||
# arguments = "$ID" ]
|
||||
#
|
||||
#VM_HOOK = [
|
||||
# name = "on_failure_recreate",
|
||||
# on = "FAILED",
|
||||
# command = "/usr/bin/env onevm delete --recreate",
|
||||
# arguments = "$ID" ]
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#*******************************************************************************
|
||||
# Auth Manager Configuration
|
||||
#*******************************************************************************
|
||||
# AUTH_MAD: The Driver that will be used to authenticate (authn) and
|
||||
# authorize (authz) OpenNebula requests. If defined OpenNebula will use the
|
||||
# built-in auth policies.
|
||||
#
|
||||
# executable: path of the auth driver executable, can be an
|
||||
# absolute path or relative to $ONE_LOCATION/lib/mads (or
|
||||
# /usr/lib/one/mads/ if OpenNebula was installed in /)
|
||||
#
|
||||
# authn : list of authentication modules separated by commas, if not
|
||||
# defined all the modules available will be enabled
|
||||
# authz : list of authentication modules separated by commas
|
||||
#
|
||||
# SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as
|
||||
# valid. During this time, the driver is not used. Use 0 to disable session
|
||||
# caching
|
||||
#
|
||||
# ENABLE_OTHER_PERMISSIONS: Whether or not users can set the permissions for
|
||||
# 'other', so publishing or sharing resources with others. Users in the oneadmin
|
||||
# group will still be able to change these permissions. Values: YES or NO.
|
||||
#
|
||||
# DEFAULT_UMASK: Similar to Unix umask, sets the default resources permissions.
|
||||
# Its format must be 3 octal digits. For example a umask of 137 will set
|
||||
# the new object's permissions to 640 "um- u-- ---"
|
||||
#*******************************************************************************
|
||||
AUTH_MAD = [
|
||||
executable = "one_auth_mad",
|
||||
authn = "server_cipher,default,%%sunstone_auth_modes"
|
||||
]
|
||||
|
||||
SESSION_EXPIRATION_TIME = 900
|
||||
|
||||
#ENABLE_OTHER_PERMISSIONS = "YES"
|
||||
|
||||
DEFAULT_UMASK = 177
|
||||
|
||||
#*******************************************************************************
|
||||
# OneGate
|
||||
# ONEGATE_ENDPOINT: The URL for the onegate server (the Gate to OpenNebula for
|
||||
# VMs). The onegate server is started using a separate command. The endpoint
|
||||
# MUST be consistent with the values in onegate-server.conf
|
||||
#*******************************************************************************
|
||||
|
||||
#ONEGATE_ENDPOINT = "http://frontend:5030"
|
||||
|
||||
#*******************************************************************************
|
||||
# Restricted Attributes Configuration
|
||||
#*******************************************************************************
|
||||
# The following attributes are restricted to users outside the oneadmin group
|
||||
#*******************************************************************************
|
||||
|
||||
VM_RESTRICTED_ATTR = "CONTEXT/FILES"
|
||||
VM_RESTRICTED_ATTR = "NIC/MAC"
|
||||
VM_RESTRICTED_ATTR = "NIC/VLAN_ID"
|
||||
VM_RESTRICTED_ATTR = "NIC/BRIDGE"
|
||||
|
||||
#VM_RESTRICTED_ATTR = "RANK"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_RANK"
|
||||
#VM_RESTRICTED_ATTR = "REQUIREMENTS"
|
||||
#VM_RESTRICTED_ATTR = "SCHED_REQUIREMENTS"
|
||||
|
||||
IMAGE_RESTRICTED_ATTR = "SOURCE"
|
||||
|
||||
#*******************************************************************************
|
||||
# Inherited Attributes Configuration
|
||||
#*******************************************************************************
|
||||
# The following attributes will be copied from the resource template to the
|
||||
# instantiated VMs. More than one attribute can be defined.
|
||||
#
|
||||
# INHERIT_IMAGE_ATTR: Attribute to be copied from the Image template
|
||||
# to each VM/DISK.
|
||||
#
|
||||
# INHERIT_DATASTORE_ATTR: Attribute to be copied from the Datastore template
|
||||
# to each VM/DISK.
|
||||
#
|
||||
# INHERIT_VNET_ATTR: Attribute to be copied from the Network template
|
||||
# to each VM/NIC.
|
||||
#*******************************************************************************
|
||||
|
||||
#INHERIT_IMAGE_ATTR = "EXAMPLE"
|
||||
#INHERIT_IMAGE_ATTR = "SECOND_EXAMPLE"
|
||||
#INHERIT_DATASTORE_ATTR = "COLOR"
|
||||
#INHERIT_VNET_ATTR = "BANDWIDTH_THROTTLING"
|
||||
|
||||
INHERIT_DATASTORE_ATTR = "CEPH_HOST"
|
||||
INHERIT_DATASTORE_ATTR = "CEPH_SECRET"
|
||||
INHERIT_DATASTORE_ATTR = "CEPH_USER"
|
||||
INHERIT_DATASTORE_ATTR = "RBD_FORMAT"
|
||||
|
||||
INHERIT_DATASTORE_ATTR = "GLUSTER_HOST"
|
||||
INHERIT_DATASTORE_ATTR = "GLUSTER_VOLUME"
|
||||
|
||||
INHERIT_VNET_ATTR = "VLAN_TAGGED_ID"
|
||||
|
||||
#*******************************************************************************
|
||||
# Transfer Manager Driver Behavior Configuration
|
||||
#*******************************************************************************
|
||||
# The configuration for each driver is defined in TM_MAD_CONF. These
|
||||
# values are used when creating a new datastore and should not be modified
|
||||
# since they define the datastore behavior.
|
||||
# name : name of the transfer driver, listed in the -d option of the
|
||||
# TM_MAD section
|
||||
# ln_target : determines how the persistent images will be cloned when
|
||||
# a new VM is instantiated.
|
||||
# NONE: The image will be linked and no more storage capacity will be used
|
||||
# SELF: The image will be cloned in the Images datastore
|
||||
# SYSTEM: The image will be cloned in the System datastore
|
||||
# clone_target : determines how the non persistent images will be
|
||||
# cloned when a new VM is instantiated.
|
||||
# NONE: The image will be linked and no more storage capacity will be used
|
||||
# SELF: The image will be cloned in the Images datastore
|
||||
# SYSTEM: The image will be cloned in the System datastore
|
||||
# shared : determines if the storage holding the system datastore is shared
|
||||
# among the different hosts or not. Valid values: "yes" or "no"
|
||||
#*******************************************************************************
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "dummy", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "lvm", ln_target = "NONE", clone_target = "SELF", shared = "yes"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "shared", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "fs_lvm", ln_target = "SYSTEM", clone_target = "SYSTEM", shared="yes"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "qcow2", ln_target = "NONE", clone_target = "SYSTEM", shared = "yes"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "ssh", ln_target = "SYSTEM", clone_target = "SYSTEM", shared = "no"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "vmfs", ln_target = "NONE", clone_target= "SYSTEM", shared = "yes"
|
||||
]
|
||||
|
||||
TM_MAD_CONF = [
|
||||
name = "ceph", ln_target = "NONE", clone_target = "SELF", shared = "yes"
|
||||
]
|
46
tmpl/vmm_exec_kvm.conf
Normal file
46
tmpl/vmm_exec_kvm.conf
Normal file
@ -0,0 +1,46 @@
|
||||
# -------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
|
||||
# #
|
||||
# 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. #
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
# Default configuration attributes for the KVM driver
|
||||
# (all domains will use these values as defaults). These values can
|
||||
# be overridden in each VM template. Valid atributes are:
|
||||
# - emulator
|
||||
# - os [kernel,initrd,boot,root,kernel_cmd,arch]
|
||||
# - vcpu
|
||||
# - features [acpi, pae]
|
||||
# - disk [driver, cache, io]
|
||||
# - nic [filter, model]
|
||||
# - raw
|
||||
|
||||
#EMULATOR = /usr/libexec/qemu-kvm
|
||||
|
||||
#VCPU = 1
|
||||
|
||||
OS = [ boot = "hd", arch = "x86_64" ]
|
||||
FEATURES = [ PAE = "no", ACPI = "yes" ]
|
||||
|
||||
NIC = [ model = "virtio" ]
|
||||
|
||||
%if %%getVar('activer_onesinglenode','non') == 'oui'
|
||||
%if %%getVar('one_disk_cache','non') == 'oui'
|
||||
DISK = [ driver = "qcow2" , cache = "writeback", DEV_PREFIX="vd" ]
|
||||
%else
|
||||
DISK = [ driver = "qcow2" , cache = "none", DEV_PREFIX="vd" ]
|
||||
%end if
|
||||
%if %%getVar('one_video_driver', False)
|
||||
RAW = "<devices><video><model type='%%one_video_driver' heads='1'/></video></devices>"
|
||||
%end if
|
||||
%end if
|
Loading…
Reference in New Issue
Block a user