Fix compute post deployment task

This commit is contained in:
John Hua 2015-07-23 15:16:59 +08:00
parent f539081402
commit 27dc44db2c
8 changed files with 130 additions and 87 deletions

View File

@ -17,9 +17,10 @@ rm newrelease.yaml
fpb --check xenserver-fuel-plugin
fpb --build xenserver-fuel-plugin
scp xenserver-fuel-plugin/xenserver-fuel-plugin-$BUILD_VERSION.noarch.rpm root@$FUELMASTER:$PLUGIN_PATH
scp xenserver-fuel-plugin/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm root@$FUELMASTER:$PLUGIN_PATH
ssh root@$FUELMASTER fuel plugins --install $PLUGIN_PATH/xenserver-fuel-plugin-$BUILD_VERSION.noarch.rpm ||
ssh root@$FUELMASTER fuel plugins --update $PLUGIN_PATH/xenserver-fuel-plugin-$BUILD_VERSION.noarch.rpm
ssh root@$FUELMASTER fuel plugins --remove xenserver-fuel-plugin==$VERSION
ssh root@$FUELMASTER fuel plugins --install $PLUGIN_PATH/xenserver-fuel-plugin-0.0-$VERSION-1.noarch.rpm
ssh root@$FUELMASTER fuel plugins --list

22
install_xapi_plugin.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -x
function install_xapi_plugin {
local nova_url
nova_url="$1"
local nova_zipball
nova_zipball=$(mktemp)
local nova_sources
nova_sources=$(mktemp -d)
wget -qO "$nova_zipball" "$nova_url"
unzip -q "$nova_zipball" -d "$nova_sources"
cp $nova_sources/*/plugins/xenserver/xenapi/etc/xapi.d/plugins/* /etc/xapi.d/plugins/
rm "$nova_zipball"
rm -rf "$nova_sources"
}
install_xapi_plugin "https://codeload.github.com/openstack/nova/zip/2014.2.2"

View File

@ -1,3 +1,3 @@
BUILD_VERSION='0.0-0.0.1-1'
FUELMASTER='HOST_OF_FUEL_MASTER'
PLUGIN_PATH='~'
VERSION="0.0.3"
FUELMASTER="HOST_OF_FUEL_MASTER"
PLUGIN_PATH="~"

View File

@ -0,0 +1,91 @@
#!/usr/bin/env python
import os
import logging
from logging import debug, info, warning
import yaml
from subprocess import call
from shutil import rmtree
from tempfile import mkstemp, mkdtemp
LOG_FILE = '/var/log/compute_post_deployment.log'
logging.basicConfig(filename=LOG_FILE,level=logging.DEBUG)
def init_eth(dev_no):
fname = '/etc/network/interfaces.d/ifcfg-eth%d' % (dev_no)
s = \
"""auto eth2
iface eth2 inet dhcp
"""
with open(fname, 'w') as f:
f.write(s)
info('%s created' % fname)
def install_xen_tools():
#TODO
'''
local xen_tools_url
xen_tools_url="$1"
local xen_tools_file
xen_tools_file=$(mktemp)
wget -qO "$xen_tools_file" "$xen_tools_url"
dpkg -i "$xen_tools_file"
rm "$xen_tools_file"
'''
def install_xenapi_sdk(xenapi_url):
xenapi_zipball = mkstemp()[1]
xenapi_sources = mkdtemp()
call(['wget', '-qO', xenapi_zipball, xenapi_url])
info('%s downloaded' % (xenapi_url))
call(['tar', '-zxf', xenapi_zipball, '-C', xenapi_sources])
subdirs = os.listdir(xenapi_sources)
if (len(subdirs) != 1) or (not subdirs[0].startswith('XenAPI')):
warning('fail to extract %s' % xenapi_url)
return
info('%s extracted' % (subdirs[0]))
src = os.path.join(xenapi_sources, subdirs[0], 'XenAPI.py')
dest = '/usr/lib/python2.7/dist-packages'
call(['cp', src, dest])
info('XenAPI.py deployed')
os.remove(xenapi_zipball)
rmtree(xenapi_sources)
def create_novacompute_conf(fuel_plugin_name='xenserver-fuel-plugin'):
astute_path = '/etc/astute.yaml'
if not os.path.exists(astute_path):
warning('%s not found' % astute_path)
return
astute = yaml.load(open(astute_path))
if not fuel_plugin_name in astute:
warning('%s not found in %s' % (fuel_plugin_name, astute_path))
return
env = astute[fuel_plugin_name]
info('username: {username_text}'.format(**env))
info('password: {password_text}'.format(**env))
template = \
"""[DEFAULT]
compute_driver=xenapi.XenAPIDriver
[xenserver]
connection_url=http://10.219.10.22
connection_username={username_text}
connection_password={password_text}
"""
s = template.format(**env)
with open('/etc/nova/nova-compute.conf','w') as f:
f.write(s)
if __name__ == '__main__':
init_eth(2)
#install_xen_tools "http://xen-tools.org/software/xen-tools/xen-tools_4.5-1_all.deb"
install_xenapi_sdk('https://pypi.python.org/packages/source/X/XenAPI/XenAPI-1.2.tar.gz')
create_novacompute_conf('xenserver-fuel-plugin')

View File

@ -1,76 +0,0 @@
#!/bin/bash
function setup_himn {
echo 'auto eth2
iface eth2 inet dhcp' \
> /etc/network/interfaces.d/ifcfg-eth2
}
function install_xen_tools {
local xen_tools_url
xen_tools_url="$1"
local xen_tools_file
xen_tools_file=$(mktemp)
wget -qO "$xen_tools_file" "$xen_tools_url"
dpkg -i "$xen_tools_file"
rm "$xen_tools_file"
}
function install_xapi_plugin {
local nova_url
nova_url="$1"
local nova_zipball
nova_zipball=$(mktemp)
local nova_sources
nova_sources=$(mktemp -d)
wget -qO "$nova_zipball" "$nova_url"
unzip "$nova_zipball" -d "$nova_sources"
cp $nova_sources/plugins/xenserver/xenapi/etc/xapi.d/plugins/* /etc/xapi.d/plugins/
rm "$nova_zipball"
rm -rf "$nova_sources"
}
function install_xenapi_sdk {
local xenapi_url
xenapi_url="$1"
local xenapi_zipball
xenapi_zipball=$(mktemp)
local xenapi_sources
xenapi_sources=$(mktemp -d)
wget -qO "$xenapi_zipball" "$xenapi_url"
unzip "$xenapi_zipball" -d "$xenapi_sources"
tar -xf $xenapi_sources/*.tar
cp $xenapi_sources/XenAPI-*/XenAPI.py /usr/lib/python2.7/dist­packages/
rm "$xenapi_zipball"
rm -rf "$xenapi_sources"
}
function create_nova­compute_conf {
local username
username="$1"
local password
password="$2"
echo '[DEFAULT]
compute_driver=xenapi.XenAPIDriver
[xenserver]
connection_url=http://10.219.10.22
connection_username=$username
connection_password=$password' \
> /etc/nova/nova­-compute.conf
}
setup_himn
install_xen_tools "http://xen-tools.org/software/xen-tools/xen-tools_4.5-1_all.deb"
install_xapi_plugin "https://codeload.github.com/openstack/nova/zip/2014.2.2"
install_xenapi_sdk "https://pypi.python.org/packages/source/X/XenAPI/XenAPI-1.2.tar.gz"
create_nova­compute_conf "$username_text" "$password_text"

View File

@ -3,7 +3,7 @@ name: xenserver-fuel-plugin
# Human-readable name for your plugin
title: Xenserver Plugin
# Plugin version
version: '0.0.2'
version: '0.0.3'
# Description
description: Enable Mirantis OpenStack to integrate with Xenserver
# Required fuel version
@ -30,6 +30,11 @@ releases:
mode: ['multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/centos
- os: ubuntu
version: 2014.2.2-6.1
mode: ['multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
# Version of plugin package
package_version: '2.0.0'

View File

@ -6,13 +6,13 @@
stage: post_deployment
type: shell
parameters:
cmd: ./controller_post_deployment.sh
cmd: ./controller_post_deployment.sh > /var/log/controller_post_deployment.log
timeout: 42
- role: ['compute']
stage: post_deployment
type: shell
parameters:
cmd: ./compute_post_deployment.sh
cmd: ./compute_post_deployment.py
timeout: 42
# Task is applied for all roles
- role: '*'

View File

@ -204,8 +204,8 @@
bind: "settings:common.libvirt_type.value"
values:
- data: "xen"
label: "Xen
description: "XenServer
label: "Xen"
description: "XenServer"
bind:
- "wizard:Storage.ceph": "disable"
- "wizard:Network.manager": "nova-network"