Xen Orchestra sous Debian Lenny (utilisation avec PostgreSQL)
Par david techer, dimanche 11 juillet 2010 à 14:05 :: Xen :: #717 :: rss
Xen Orchestra est une superbe interface Web permettant de gérer facilement ses VM si on doit gérer plusieur VM réparties par exemple sur plusieurs dom0. J'ai opté pour cette solution car elle offre une interface conviviale pour la gestion des domU.
Xen Orchestra en action
Pour mes test, j'ai choisi d'utiliser une base PostgreSQL pour la gestion des utilisateurs gérant la base
Téléchargement
wget http://project.xen-orchestra.com/p/xen-orchestra/source/download/master/ -O toto && unzip totoOn obtiendra ainsi un répertoire xen-orchestra-master.
Pour la suite,il suffira de suivre les indications des fichiers INSTALL et README livrés dans le répertoire décompressé.
Remarques: Pour la suite de ce billet, je désignerais- le fichier INSTALL par [1]
- le fichier README par [2]
Prérequis
Conformément, aux recommendations de [1], sur la machine qui hébergera l'application Web, il faut installer quelques paquetsapt-get update apt-get install php5-cli php5-xmlrpc php5-pgsql
Fichier de configuration.
Comme indiqué dans [1], on renomme le fichier en question
mv xen-orchestra.conf.dist xen-orchestra.confLes modifications fourniront dans mon cas le fichier suivant
melina-xen06:/opt/sites/xen-orchestra-master$ cat xen-orchestra.conf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Configuration of Xen Orcherstra (XO) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; ; Global configuration ; ;;;;;;;;;;;;;;;;;;;;;;;; [global] ; Refresh Time in seconds for Web Interface, 10 is default refresh = 10 ; XO can use a database to manage users, but this is optional, you may disable ; it by uncommenting this entry. disable_database = false ; When the database is disabled, only the guest user is available and what he ; can do is defined by this entry. ; - NONE Guest is not able to see or do anything (this is the default). ; - READ Guest is only able to see the list of dom0s/domUs. ; - WRITE As READ + he is also able to change ; - ADMIN As WRITE but also gives the power to change Xen Orchestra's ; configuration. Normally, ADMIN gives also the ability to create and ; manage users but since the database is disabled, this feature is too. default_guest_permission = ADMIN ;;;;;;;;;;;;;;;;;;;;;;;;;; ; Database configuration ; ;;;;;;;;;;;;;;;;;;;;;;;;;; ; XO can use a database to manage users and their rights. ; Since XO uses databases through PDO (PHP Database Object), you have the ; ability to choose which database you want use. ; For more information, see http://fr2.php.net/manual/en/pdo.drivers.php [database] ; The Database Source Name is used to specify which type of database you want to ; use and to define the information required to connect to it. dsn = "pgsql:host=melina-xen01.davidgis.fr dbname=xendb" ; If your database required an authentication, you have to use the following ; two entries. username = pgxenadmin password = "pgxenadmin" ;;;;;;;;;;;;;;;;;;;;;;; ; Dom0s configuration ; ;;;;;;;;;;;;;;;;;;;;;;; ; Server address and port. Example for 2Â dom0s : ; [melina:9363] username = xenxen password = xenxen ; ; [xen.intranet.com:9363] ; username = test1 ; password = test1Ainsi
- Ma base de données PostgreSQL se trouvera sur le serveur melina-xen01 pour la base xendb avec les login/password (pgxenadmin/pgxenadmin)
- Le seul dom0 a interrogé sera melina
- L'interface sera hébergée sur melina-xen06
Répartion pour Xen-Orchestra
PostgreSQL - Création de la base de données
Une fois connecté à melina-xen01 (qui hébergera la base de données), on créé donc une petite base de données ainsi que l'utilisateur en question
postgres@melina-xen01:~$ creatdb xendb postgres@melina-xen01:~$ createuser -seP pgxenadmin Saisissez le mot de passe pour le nouveau rôle : Saisissez-le à nouveau : CREATE ROLE pgxenadmin PASSWORD 'md5bf3713213e02ee1fca17481c9781cf67' SUPERUSER CREATEDB CREATEROLE INHERIT LOGIN; postgres@melina-xen01:~$ psql xendb -c "ALTER DATABASE xendb OWNER TO pgxenadmin;" ALTER DATABASE
PostgreSQL - Création des utilisateurs
melina-xen06:~# cd /opt/sites/xen-orchestra-master/scripts/
melina-xen06:/opt/sites/xen-orchestra-master/scripts# ./exec-sql-script
4 script(s) available.
1: MySQL_create-tables
2: MySQL_drop-tables
3: PostgreSQL_create-tables
4: PostgreSQL_drop-tables
Enter the number of the one you want: 3
You have selected "PostgreSQL_create-tables".
Query: CREATE TYPE PERMISSION AS ENUM ('NONE', 'READ', 'WRITE', 'ADMIN')
int(0)
Query: CREATE TABLE users
(
id SERIAL NOT NULL, -- SERIAL = Integer + auto-increment.
name CHARACTER(50) NOT NULL, -- Name = login.
password CHARACTER(32) NOT NULL, -- All passwords are hashed with md5, thus, the length is 32 characters.
email CHARACTER(320) NOT NULL, -- The maximum size of an email address is 320 characters.
permission PERMISSION NOT NULL,
PRIMARY KEY (id),
UNIQUE (name), -- It seems an index is implied by UNIQUE.
UNIQUE (email)
)
int(0)
Query: CREATE TABLE acls
(
user_id INTEGER NOT NULL,
dom0_id CHARACTER(261) NOT NULL, -- DNS: 255 chars max + 1 ':' + 5 chars for the port.
domU_name CHARACTER(50), -- No idea if there is a limit, use 50 until someone complains.
permission PERMISSION NOT NULL,
PRIMARY KEY (user_id, dom0_id, domU_name),
FOREIGN KEY (user_id) REFERENCES users (id)
)
int(0)
Query: CREATE INDEX acls_user_id_key ON acls (user_id)
int(0)
melina-xen06:/opt/sites/xen-orchestra-master/scripts# ./create-user
Username: xenxen
Password: xenxen
Email: info@davidgis.fr
Permission (NONE, read, write, admin): admin
User created with identifier 1.
Mise en place de l'interface Web (Virtual Host)
Mon fichier sera le suivantNameVirtualHost 192.168.2.224
<VirtualHost 192.168.2.224>
ServerName xen-orchestra.davidgis.fr
ServerAlias xen-orchestra
DocumentRoot /opt/sites/xen-orchestra-master/htdocs
ErrorLog /opt/sites/logs/xen-orchestra.error.log
CustomLog /opt/sites/logs/xen-orchestra.access.log combined
<Directory "/opt/sites/xen-orchestra/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Si on dispose d'un BIND pour son réseau local, on s'assure d'ajouter l'entrée nécessaire pour la nouvelle IP.
Au niveau du fichier /etc/networking/interfaces, on ajoute aussi
# Alias pour xen-orchestra ########################### auto eth0:4 iface eth0:4 inet static address 192.168.2.224 gateway 192.168.2.253 netmask 255.255.255.0 broadcast 192.168.2.255
On active ensuite le site
melina-xen06:~/xen# a2ensite xen-orchestra Enabling site xen-orchestra. Run '/etc/init.d/apache2 reload' to activate new configuration! melina-xen06:~/xen# /etc/init.d/apache2 reload
Xen et le dom0 cible
La machine melina correspond à mon dom0.Conformément à [2], il faut activer les échanges en XMLRPC. Pour des raisons de simplicités, je me suis limité à activer la ligne en question (xen-api-server ((9363 unix)))
melina:~# grep -vE '^(#|$)' /etc/xen/xend-config.sxp (logfile /var/log/xen/xend.log) (loglevel DEBUG) (xen-api-server ((9363 unix))) (xend-relocation-server yes) (xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') (network-script network-bridge) (vif-script vif-bridge) (dom0-min-mem 512) (enable-dom0-ballooning yes) (total_available_memory 0) (dom0-cpus 0) (vncpasswd '')
Conformément à la remarque formulée dans [2],si on veut pouvoir allumer/suspendre/éteindre les domU, il faut pour celà procéder à la inscription par la commande xm new .....cfg
Dans mon cas:
- Il me manquait un paquet pour pouvoir utiliser cette commande, donc
apt-get install python-xml
- Pour chaque machine, il suffit ensuite:
- de l'eteindre
xm shutdown /etc/xen/machines/melina-xen0X.cfg
- De l'inscrire
xm new /etc/xen/machines/melina-xen0X.cfg
- de la redémarrer
xm start melina-xen0X
- de l'eteindre
Commentaires
Aucun commentaire pour le moment.
Ajouter un commentaire