blob: 0046a366c95b413b1df449e85b9eb8b1391f2f6b [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)
29if is_service_enabled neutron; then
Huan Xiebea1e192016-04-19 07:01:30 +010030 XEN_INTEGRATION_BRIDGE_DEFAULT=$(sed -e 's/.* xen_integration_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
31 XEN_INTEGRATION_BRIDGE=${XEN_INTEGRATION_BRIDGE:-$XEN_INTEGRATION_BRIDGE_DEFAULT}
Dean Troyer9a532b82013-09-23 13:44:38 -050032fi
33
34VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1}
35
36
37# Entry Points
38# ------------
39
40# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110041function cleanup_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050042 # This function intentionally left blank
43 :
44}
45
46# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110047function configure_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050048 if [ -z "$XENAPI_CONNECTION_URL" ]; then
49 die $LINENO "XENAPI_CONNECTION_URL is not specified"
50 fi
Huan Xiec6081842016-11-16 00:40:32 -080051
52 # Check os-xenapi plugin is enabled
53 local plugins="${DEVSTACK_PLUGINS}"
54 local plugin
55 local found=0
56 for plugin in ${plugins//,/ }; do
57 if [[ "$plugin" = "os-xenapi" ]]; then
58 found=1
59 break
60 fi
61 done
62 if [[ $found -ne 1 ]]; then
63 die $LINENO "os-xenapi plugin is not specified. Please enable this plugin in local.conf"
64 fi
65
Dean Troyer9a532b82013-09-23 13:44:38 -050066 read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
67 iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
Bob Ball786a3a32014-06-16 08:37:05 +010068 iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL"
69 iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER"
70 iniset $NOVA_CONF xenserver connection_password "$XENAPI_PASSWORD"
Dean Troyer9a532b82013-09-23 13:44:38 -050071 iniset $NOVA_CONF DEFAULT flat_injected "False"
72 # Need to avoid crash due to new firewall support
73 XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
74 iniset $NOVA_CONF DEFAULT firewall_driver "$XEN_FIREWALL_DRIVER"
Mate Lakatd15c8a02014-02-04 12:38:14 +000075
76 local dom0_ip
77 dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-)
78
79 local ssh_dom0
80 ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip"
81
Mate Lakatd15c8a02014-02-04 12:38:14 +000082 # install console logrotate script
83 tar -czf - -C $NOVA_DIR/tools/xenserver/ rotate_xen_guest_logs.sh |
84 $ssh_dom0 'tar -xzf - -C /root/ && chmod +x /root/rotate_xen_guest_logs.sh && mkdir -p /var/log/xen/guest'
85
86 # Create a cron job that will rotate guest logs
87 $ssh_dom0 crontab - << CRONTAB
jianghua wang797668b2015-10-08 06:40:21 +010088* * * * * /root/rotate_xen_guest_logs.sh >/dev/null 2>&1
Mate Lakatd15c8a02014-02-04 12:38:14 +000089CRONTAB
90
91 # Create directories for kernels and images
92 {
93 echo "set -eux"
94 cat $TOP_DIR/tools/xen/functions
95 echo "create_directory_for_images"
96 echo "create_directory_for_kernels"
Huan Xie26edd7b2016-08-08 07:23:36 +000097 echo "install_conntrack_tools"
Mate Lakatd15c8a02014-02-04 12:38:14 +000098 } | $ssh_dom0
99
Huan Xief881a0e2016-09-27 05:57:06 +0000100 if is_service_enabled neutron; then
101 # Remove restriction on linux bridge in Dom0 when neutron is enabled
102 $ssh_dom0 "rm -f /etc/modprobe.d/blacklist-bridge*"
Huan Xie28641502016-09-20 06:49:50 +0000103
104 count=`$ssh_dom0 "iptables -t filter -L XenServerDevstack |wc -l"`
105 if [ "$count" = "0" ]; then
106 {
107 echo "iptables -t filter --new XenServerDevstack"
108 echo "iptables -t filter -I INPUT -j XenServerDevstack"
109 echo "iptables -t filter -I XenServerDevstack -p tcp --dport 6640 -j ACCEPT"
110 } | $ssh_dom0
111 fi
Huan Xief881a0e2016-09-27 05:57:06 +0000112 fi
Dean Troyer9a532b82013-09-23 13:44:38 -0500113}
114
115# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +1100116function install_nova_hypervisor {
Huan Xiec6081842016-11-16 00:40:32 -0800117 # xenapi functionality is now included in os-xenapi library which houses the plugin
118 # so this function intentionally left blank
119 :
Dean Troyer9a532b82013-09-23 13:44:38 -0500120}
121
122# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100123function start_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500124 # This function intentionally left blank
125 :
126}
127
128# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100129function stop_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500130 # This function intentionally left blank
131 :
132}
133
134
135# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100136$_XTRACE_XENSERVER
Dean Troyer9a532b82013-09-23 13:44:38 -0500137
138# Local variables:
139# mode: shell-script
140# End: