blob: e7f1e87b61f720a344dbc5aa7bdfcd7583df1aa6 [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
27PUBLIC_INTERFACE_DEFAULT=eth2
28GUEST_INTERFACE_DEFAULT=eth1
29# Allow ``build_domU.sh`` to specify the flat network bridge via kernel args
30FLAT_NETWORK_BRIDGE_DEFAULT=$(sed -e 's/.* flat_network_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
31if is_service_enabled neutron; then
Huan Xiebea1e192016-04-19 07:01:30 +010032 XEN_INTEGRATION_BRIDGE_DEFAULT=$(sed -e 's/.* xen_integration_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
33 XEN_INTEGRATION_BRIDGE=${XEN_INTEGRATION_BRIDGE:-$XEN_INTEGRATION_BRIDGE_DEFAULT}
Dean Troyer9a532b82013-09-23 13:44:38 -050034fi
35
36VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1}
37
38
39# Entry Points
40# ------------
41
42# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110043function cleanup_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050044 # This function intentionally left blank
45 :
46}
47
48# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110049function configure_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050050 if [ -z "$XENAPI_CONNECTION_URL" ]; then
51 die $LINENO "XENAPI_CONNECTION_URL is not specified"
52 fi
53 read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
54 iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
Bob Ball786a3a32014-06-16 08:37:05 +010055 iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL"
56 iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER"
57 iniset $NOVA_CONF xenserver connection_password "$XENAPI_PASSWORD"
Dean Troyer9a532b82013-09-23 13:44:38 -050058 iniset $NOVA_CONF DEFAULT flat_injected "False"
59 # Need to avoid crash due to new firewall support
60 XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
61 iniset $NOVA_CONF DEFAULT firewall_driver "$XEN_FIREWALL_DRIVER"
Mate Lakatd15c8a02014-02-04 12:38:14 +000062
63 local dom0_ip
64 dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-)
65
66 local ssh_dom0
67 ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip"
68
Bob Ball348ae442014-03-20 16:56:04 +000069 # Find where the plugins should go in dom0
70 xen_functions=`cat $TOP_DIR/tools/xen/functions`
71 PLUGIN_DIR=`$ssh_dom0 "$xen_functions; set -eux; xapi_plugin_location"`
72
Mate Lakatd15c8a02014-02-04 12:38:14 +000073 # install nova plugins to dom0
74 tar -czf - -C $NOVA_DIR/plugins/xenserver/xenapi/etc/xapi.d/plugins/ ./ |
Bob Ball348ae442014-03-20 16:56:04 +000075 $ssh_dom0 "tar -xzf - -C $PLUGIN_DIR && chmod a+x $PLUGIN_DIR/*"
Mate Lakatd15c8a02014-02-04 12:38:14 +000076
77 # install console logrotate script
78 tar -czf - -C $NOVA_DIR/tools/xenserver/ rotate_xen_guest_logs.sh |
79 $ssh_dom0 'tar -xzf - -C /root/ && chmod +x /root/rotate_xen_guest_logs.sh && mkdir -p /var/log/xen/guest'
80
81 # Create a cron job that will rotate guest logs
82 $ssh_dom0 crontab - << CRONTAB
jianghua wang797668b2015-10-08 06:40:21 +010083* * * * * /root/rotate_xen_guest_logs.sh >/dev/null 2>&1
Mate Lakatd15c8a02014-02-04 12:38:14 +000084CRONTAB
85
86 # Create directories for kernels and images
87 {
88 echo "set -eux"
89 cat $TOP_DIR/tools/xen/functions
90 echo "create_directory_for_images"
91 echo "create_directory_for_kernels"
92 } | $ssh_dom0
93
Dean Troyer9a532b82013-09-23 13:44:38 -050094}
95
96# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110097function install_nova_hypervisor {
Sean Dague60996b12015-04-08 09:06:49 -040098 pip_install_gr xenapi
Dean Troyer9a532b82013-09-23 13:44:38 -050099}
100
101# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100102function start_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500103 # This function intentionally left blank
104 :
105}
106
107# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100108function stop_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500109 # This function intentionally left blank
110 :
111}
112
113
114# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100115$_XTRACE_XENSERVER
Dean Troyer9a532b82013-09-23 13:44:38 -0500116
117# Local variables:
118# mode: shell-script
119# End: