blob: ccab18dc97dd096b255c2cde4c507ab01e579348 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Dean Troyer9a532b82013-09-23 13:44:38 -05003# lib/nova_plugins/hypervisor-xenserver
4# Configure the XenServer hypervisor
5
6# Enable with:
7# VIRT_DRIVER=xenserver
8
9# Dependencies:
10# ``functions`` file
11# ``nova`` configuration
12
13# install_nova_hypervisor - install any external requirements
14# configure_nova_hypervisor - make configuration changes, including those to other services
15# start_nova_hypervisor - start any external services
16# stop_nova_hypervisor - stop any external services
17# cleanup_nova_hypervisor - remove transient data and cache
18
19# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +110020_XTRACE_XENSERVER=$(set +o | grep xtrace)
Dean Troyer9a532b82013-09-23 13:44:38 -050021set +o xtrace
22
23
24# Defaults
25# --------
26
Dean Troyer9a532b82013-09-23 13:44:38 -050027VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1}
28
29
30# Entry Points
31# ------------
32
33# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110034function cleanup_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050035 # This function intentionally left blank
36 :
37}
38
39# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110040function configure_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050041 if [ -z "$XENAPI_CONNECTION_URL" ]; then
42 die $LINENO "XENAPI_CONNECTION_URL is not specified"
43 fi
Huan Xiec6081842016-11-16 00:40:32 -080044
45 # Check os-xenapi plugin is enabled
46 local plugins="${DEVSTACK_PLUGINS}"
47 local plugin
48 local found=0
49 for plugin in ${plugins//,/ }; do
50 if [[ "$plugin" = "os-xenapi" ]]; then
51 found=1
52 break
53 fi
54 done
55 if [[ $found -ne 1 ]]; then
56 die $LINENO "os-xenapi plugin is not specified. Please enable this plugin in local.conf"
57 fi
58
Dean Troyer9a532b82013-09-23 13:44:38 -050059 iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
Bob Ball786a3a32014-06-16 08:37:05 +010060 iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL"
61 iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER"
62 iniset $NOVA_CONF xenserver connection_password "$XENAPI_PASSWORD"
Dean Troyer9a532b82013-09-23 13:44:38 -050063 iniset $NOVA_CONF DEFAULT flat_injected "False"
64 # Need to avoid crash due to new firewall support
65 XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
66 iniset $NOVA_CONF DEFAULT firewall_driver "$XEN_FIREWALL_DRIVER"
Mate Lakatd15c8a02014-02-04 12:38:14 +000067
68 local dom0_ip
69 dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-)
70
71 local ssh_dom0
72 ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip"
73
Mate Lakatd15c8a02014-02-04 12:38:14 +000074 # install console logrotate script
75 tar -czf - -C $NOVA_DIR/tools/xenserver/ rotate_xen_guest_logs.sh |
76 $ssh_dom0 'tar -xzf - -C /root/ && chmod +x /root/rotate_xen_guest_logs.sh && mkdir -p /var/log/xen/guest'
77
78 # Create a cron job that will rotate guest logs
79 $ssh_dom0 crontab - << CRONTAB
jianghua wang797668b2015-10-08 06:40:21 +010080* * * * * /root/rotate_xen_guest_logs.sh >/dev/null 2>&1
Mate Lakatd15c8a02014-02-04 12:38:14 +000081CRONTAB
82
Dean Troyer9a532b82013-09-23 13:44:38 -050083}
84
85# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110086function install_nova_hypervisor {
Huan Xiec6081842016-11-16 00:40:32 -080087 # xenapi functionality is now included in os-xenapi library which houses the plugin
88 # so this function intentionally left blank
89 :
Dean Troyer9a532b82013-09-23 13:44:38 -050090}
91
92# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +110093function start_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050094 # This function intentionally left blank
95 :
96}
97
98# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +110099function stop_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500100 # This function intentionally left blank
101 :
102}
103
104
105# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100106$_XTRACE_XENSERVER
Dean Troyer9a532b82013-09-23 13:44:38 -0500107
108# Local variables:
109# mode: shell-script
110# End: