Fix post deployment tasks
This commit is contained in:
parent
1a5d9b071c
commit
488d0c64f4
15
README.md
15
README.md
|
@ -12,18 +12,11 @@ Environment Setup
|
|||
|
||||
git clone https://github.com/citrix-openstack/xenserver-fuel-plugin.git
|
||||
cd xenserver-fuel-plugin
|
||||
cp localrc.sample localrc
|
||||
vi localrc #configure your local environment
|
||||
cp localrc.sample localrc && vi localrc #configure your local environment
|
||||
|
||||
Deployment
|
||||
----------
|
||||
|
||||
./deploy.sh
|
||||
|
||||
Check out on Fuel Web UI
|
||||
------------------------
|
||||
|
||||
Open Fuel Web UI, go the Setting Tab of a new/existing Environment.
|
||||
|
||||
You have to enable the plugin(check on the checkbox) before use it.
|
||||
|
||||
./deploy.sh release
|
||||
./deploy.sh plugin
|
||||
./deploy.sh #both
|
||||
|
|
|
@ -17,6 +17,7 @@ extra_vdi=$(xe vdi-create \
|
|||
virtual-size="${disksize}GiB" \
|
||||
sr-uuid=$localsr type=user)
|
||||
xe vbd-create vm-uuid=$vm_uuid vdi-uuid=$extra_vdi device=0
|
||||
xe vm-cd-add vm=$vm_uuid device=1 cd-name="xs-tools.iso"
|
||||
|
||||
xe vm-memory-limits-set \
|
||||
static-min=${memory}MiB \
|
||||
|
|
|
@ -30,7 +30,7 @@ def import_raw_vdi(host, session, filename):
|
|||
}
|
||||
vdi = session.xenapi.VDI.create(vdi_spec)
|
||||
|
||||
task_name = 'import ' + vdi
|
||||
task_name = 'import ' + session.xenapi.VDI.get_uuid(vdi)
|
||||
import_task = session.xenapi.task.create(task_name, '')
|
||||
|
||||
put_url = '/import_raw_vdi?session_id=%s&vdi=%s&task_id=%s' % \
|
||||
|
@ -43,12 +43,17 @@ def import_raw_vdi(host, session, filename):
|
|||
response = conn.getresponse()
|
||||
|
||||
import_status = session.xenapi.task.get_status(import_task)
|
||||
timeout = 30
|
||||
while import_status == 'pending':
|
||||
print import_status
|
||||
print import_status, timeout
|
||||
"""TODO: loop 'pending', suspiciously a bug of XenServer that
|
||||
could be fixed by installing SP1"""
|
||||
time.sleep(1)
|
||||
import_status = session.xenapi.task.get_status(import_task)
|
||||
timeout -= 1
|
||||
if timeout < 0:
|
||||
session.xenapi.task.cancel(import_task)
|
||||
break
|
||||
|
||||
if import_status != 'success':
|
||||
error_info = session.xenapi.task.get_error_info(import_task)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
VM_NAMES="$@"
|
||||
|
||||
for VM_NAME in $VM_NAMES
|
||||
do
|
||||
xe vm-cd-insert uuid=$(xe vm-list name-label="$VM_NAME") cd-name="xs-tools.iso"
|
||||
done
|
66
xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.py
Normal file → Executable file
66
xenserver-fuel-plugin/deployment_scripts/compute_post_deployment.py
Normal file → Executable file
|
@ -9,8 +9,30 @@ from shutil import rmtree
|
|||
from tempfile import mkstemp, mkdtemp
|
||||
|
||||
LOG_FILE = '/tmp/compute_post_deployment.log'
|
||||
ASTUTE_PATH = '/etc/astute.yaml'
|
||||
ACCESS_SECTION = 'xenserver_access'
|
||||
XENAPI_URL = 'https://pypi.python.org/packages/source/X/XenAPI/XenAPI-1.2.tar.gz'
|
||||
|
||||
logging.basicConfig(filename=LOG_FILE,level=logging.DEBUG)
|
||||
|
||||
def get_access(astute_path, access_section):
|
||||
if not os.path.exists(astute_path):
|
||||
warning('%s not found' % astute_path)
|
||||
return None
|
||||
|
||||
astute = yaml.load(open(astute_path))
|
||||
if not access_section in astute:
|
||||
warning('%s not found' % access_section)
|
||||
return None
|
||||
|
||||
access = astute[access_section]
|
||||
info('username: {user}'.format(**access))
|
||||
info('password: {password}'.format(**access))
|
||||
return access
|
||||
|
||||
def install_xentools():
|
||||
os.system('mount /dev/cdrom /mnt && /mnt/Linux/install.sh')
|
||||
|
||||
def init_eth(dev_no):
|
||||
fname = '/etc/network/interfaces.d/ifcfg-eth%d' % (dev_no)
|
||||
s = \
|
||||
|
@ -21,20 +43,6 @@ iface eth2 inet dhcp
|
|||
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()
|
||||
|
@ -57,35 +65,23 @@ def install_xenapi_sdk(xenapi_url):
|
|||
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))
|
||||
|
||||
def create_novacompute_conf(access):
|
||||
template = \
|
||||
"""[DEFAULT]
|
||||
compute_driver=xenapi.XenAPIDriver
|
||||
[xenserver]
|
||||
connection_url=http://10.219.10.22
|
||||
connection_username={username_text}
|
||||
connection_password={password_text}
|
||||
connection_username={user}
|
||||
connection_password={password}
|
||||
"""
|
||||
s = template.format(**env)
|
||||
s = template.format(**access)
|
||||
with open('/etc/nova/nova-compute.conf','w') as f:
|
||||
f.write(s)
|
||||
info('nova-compute.conf created')
|
||||
|
||||
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')
|
||||
install_xenapi_sdk(XENAPI_URL)
|
||||
access = get_access(ASTUTE_PATH, ACCESS_SECTION)
|
||||
if access is not None:
|
||||
create_novacompute_conf(access)
|
|
@ -1,9 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
LOG_FILE="/tmp/controller_post_deployment.log"
|
||||
|
||||
function clear_images {
|
||||
for ID in $(glance image-list | awk 'NR>2{print $2}' | grep -v '^$');
|
||||
do
|
||||
glance image-delete $ID
|
||||
glance image-delete $ID &>> $LOG_FILE
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -27,13 +29,15 @@ function create_image {
|
|||
--disk-format vhd \
|
||||
--property vm_mode="$vm_mode" \
|
||||
--is-public True \
|
||||
--file "$image_file"
|
||||
--file "$image_file" \
|
||||
&>> $LOG_FILE
|
||||
|
||||
rm "$image_file"
|
||||
}
|
||||
|
||||
source /root/openrc
|
||||
source /root/openrc admin
|
||||
|
||||
clear_images
|
||||
create_image "TestVM" "xen" "http://ca.downloads.xensource.com/OpenStack/cirros-0.3.3-x86_64-disk.vhd"
|
||||
create_image "F17-x86_64-cfntools" "hvm" "http://ca.downloads.xensource.com/OpenStack/F21-x86_64-cfntools.tgz"
|
||||
glance image-list >> $LOG_FILE
|
|
@ -6,7 +6,7 @@
|
|||
stage: post_deployment
|
||||
type: shell
|
||||
parameters:
|
||||
cmd: ./controller_post_deployment.sh > /tmp/controller_post_deployment.log
|
||||
cmd: ./controller_post_deployment.sh
|
||||
timeout: 42
|
||||
- role: ['compute']
|
||||
stage: post_deployment
|
||||
|
|
Loading…
Reference in New Issue