blob: 6f79e4ff7c44c4ef4308337c76b927c9a5890c80 [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 -050027# Allow ``build_domU.sh`` to specify the flat network bridge via kernel args
28FLAT_NETWORK_BRIDGE_DEFAULT=$(sed -e 's/.* flat_network_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
Dean Troyer9a532b82013-09-23 13:44:38 -050029
30VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1}
31
32
33# Entry Points
34# ------------
35
36# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110037function cleanup_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050038 # This function intentionally left blank
39 :
40}
41
42# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110043function configure_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050044 if [ -z "$XENAPI_CONNECTION_URL" ]; then
45 die $LINENO "XENAPI_CONNECTION_URL is not specified"
46 fi
Huan Xiec6081842016-11-16 00:40:32 -080047
48 # Check os-xenapi plugin is enabled
49 local plugins="${DEVSTACK_PLUGINS}"
50 local plugin
51 local found=0
52 for plugin in ${plugins//,/ }; do
53 if [[ "$plugin" = "os-xenapi" ]]; then
54 found=1
55 break
56 fi
57 done
58 if [[ $found -ne 1 ]]; then
59 die $LINENO "os-xenapi plugin is not specified. Please enable this plugin in local.conf"
60 fi
61
Dean Troyer9a532b82013-09-23 13:44:38 -050062 read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
63 iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
Bob Ball786a3a32014-06-16 08:37:05 +010064 iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL"
65 iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER"
66 iniset $NOVA_CONF xenserver connection_password "$XENAPI_PASSWORD"
Dean Troyer9a532b82013-09-23 13:44:38 -050067 iniset $NOVA_CONF DEFAULT flat_injected "False"
68 # Need to avoid crash due to new firewall support
69 XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
70 iniset $NOVA_CONF DEFAULT firewall_driver "$XEN_FIREWALL_DRIVER"
Mate Lakatd15c8a02014-02-04 12:38:14 +000071
72 local dom0_ip
73 dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-)
74
75 local ssh_dom0
76 ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip"
77
Mate Lakatd15c8a02014-02-04 12:38:14 +000078 # install console logrotate script
79 tar -czf - -C $NOVA_DIR/tools/xenserver/ rotate_xen_guest_logs.sh |
80 $ssh_dom0 'tar -xzf - -C /root/ && chmod +x /root/rotate_xen_guest_logs.sh && mkdir -p /var/log/xen/guest'
81
82 # Create a cron job that will rotate guest logs
83 $ssh_dom0 crontab - << CRONTAB
jianghua wang797668b2015-10-08 06:40:21 +010084* * * * * /root/rotate_xen_guest_logs.sh >/dev/null 2>&1
Mate Lakatd15c8a02014-02-04 12:38:14 +000085CRONTAB
86
Dean Troyer9a532b82013-09-23 13:44:38 -050087}
88
89# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110090function install_nova_hypervisor {
Huan Xiec6081842016-11-16 00:40:32 -080091 # xenapi functionality is now included in os-xenapi library which houses the plugin
92 # so this function intentionally left blank
93 :
Dean Troyer9a532b82013-09-23 13:44:38 -050094}
95
96# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +110097function start_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050098 # This function intentionally left blank
99 :
100}
101
102# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100103function stop_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500104 # This function intentionally left blank
105 :
106}
107
108
109# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100110$_XTRACE_XENSERVER
Dean Troyer9a532b82013-09-23 13:44:38 -0500111
112# Local variables:
113# mode: shell-script
114# End: