diff --git a/deploy.sh b/deploy.sh index b6e3b8d..c012a87 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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 diff --git a/install_xapi_plugin.sh b/install_xapi_plugin.sh new file mode 100755 index 0000000..c59cc9c --- /dev/null +++ b/install_xapi_plugin.sh @@ -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" \ No newline at end of file diff --git a/localrc.sample b/localrc.sample index b2f44b1..0f1a32a 100644 --- a/localrc.sample +++ b/localrc.sample @@ -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="~" diff --git a/xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.py b/xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.py new file mode 100644 index 0000000..af630c6 --- /dev/null +++ b/xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.py @@ -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') \ No newline at end of file diff --git a/xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.sh b/xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.sh deleted file mode 100755 index 703e8d7..0000000 --- a/xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.sh +++ /dev/null @@ -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" \ No newline at end of file diff --git a/xenserver-fuel-plugin/metadata.yaml b/xenserver-fuel-plugin/metadata.yaml index 492b261..c6479e8 100644 --- a/xenserver-fuel-plugin/metadata.yaml +++ b/xenserver-fuel-plugin/metadata.yaml @@ -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' diff --git a/xenserver-fuel-plugin/tasks.yaml b/xenserver-fuel-plugin/tasks.yaml index c1d3dd0..134b095 100644 --- a/xenserver-fuel-plugin/tasks.yaml +++ b/xenserver-fuel-plugin/tasks.yaml @@ -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: '*' diff --git a/xs_release.yaml b/xs_release.yaml index af7e302..0b01549 100644 --- a/xs_release.yaml +++ b/xs_release.yaml @@ -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"