blob: 0dba471394838b778ba59d53b860d9149a39a1a4 [file] [log] [blame]
Dean Troyer9a532b82013-09-23 13:44:38 -05001# lib/nova_plugins/hypervisor-xenserver
2# Configure the XenServer hypervisor
3
4# Enable with:
5# VIRT_DRIVER=xenserver
6
7# Dependencies:
8# ``functions`` file
9# ``nova`` configuration
10
11# install_nova_hypervisor - install any external requirements
12# configure_nova_hypervisor - make configuration changes, including those to other services
13# start_nova_hypervisor - start any external services
14# stop_nova_hypervisor - stop any external services
15# cleanup_nova_hypervisor - remove transient data and cache
16
17# Save trace setting
18MY_XTRACE=$(set +o | grep xtrace)
19set +o xtrace
20
21
22# Defaults
23# --------
24
25PUBLIC_INTERFACE_DEFAULT=eth2
26GUEST_INTERFACE_DEFAULT=eth1
27# 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
30 XEN_INTEGRATION_BRIDGE=$(sed -e 's/.* xen_integration_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline)
31fi
32
33VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1}
34
35
36# Entry Points
37# ------------
38
39# clean_nova_hypervisor - Clean up an installation
Ian Wienandaee18c72014-02-21 15:35:08 +110040function cleanup_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050041 # This function intentionally left blank
42 :
43}
44
45# configure_nova_hypervisor - Set config files, create data dirs, etc
Ian Wienandaee18c72014-02-21 15:35:08 +110046function configure_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050047 if [ -z "$XENAPI_CONNECTION_URL" ]; then
48 die $LINENO "XENAPI_CONNECTION_URL is not specified"
49 fi
50 read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
51 iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver"
Bob Ball786a3a32014-06-16 08:37:05 +010052 iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL"
53 iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER"
54 iniset $NOVA_CONF xenserver connection_password "$XENAPI_PASSWORD"
Dean Troyer9a532b82013-09-23 13:44:38 -050055 iniset $NOVA_CONF DEFAULT flat_injected "False"
56 # Need to avoid crash due to new firewall support
57 XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"}
58 iniset $NOVA_CONF DEFAULT firewall_driver "$XEN_FIREWALL_DRIVER"
Mate Lakatd15c8a02014-02-04 12:38:14 +000059
60 local dom0_ip
61 dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-)
62
63 local ssh_dom0
64 ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip"
65
Bob Ball348ae442014-03-20 16:56:04 +000066 # Find where the plugins should go in dom0
67 xen_functions=`cat $TOP_DIR/tools/xen/functions`
68 PLUGIN_DIR=`$ssh_dom0 "$xen_functions; set -eux; xapi_plugin_location"`
69
Mate Lakatd15c8a02014-02-04 12:38:14 +000070 # install nova plugins to dom0
71 tar -czf - -C $NOVA_DIR/plugins/xenserver/xenapi/etc/xapi.d/plugins/ ./ |
Bob Ball348ae442014-03-20 16:56:04 +000072 $ssh_dom0 "tar -xzf - -C $PLUGIN_DIR && chmod a+x $PLUGIN_DIR/*"
Mate Lakatd15c8a02014-02-04 12:38:14 +000073
74 # 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
80* * * * * /root/rotate_xen_guest_logs.sh
81CRONTAB
82
83 # Create directories for kernels and images
84 {
85 echo "set -eux"
86 cat $TOP_DIR/tools/xen/functions
87 echo "create_directory_for_images"
88 echo "create_directory_for_kernels"
89 } | $ssh_dom0
90
Dean Troyer9a532b82013-09-23 13:44:38 -050091}
92
93# install_nova_hypervisor() - Install external components
Ian Wienandaee18c72014-02-21 15:35:08 +110094function install_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -050095 # This function intentionally left blank
96 :
97}
98
99# start_nova_hypervisor - Start any required external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100100function start_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500101 # This function intentionally left blank
102 :
103}
104
105# stop_nova_hypervisor - Stop any external services
Ian Wienandaee18c72014-02-21 15:35:08 +1100106function stop_nova_hypervisor {
Dean Troyer9a532b82013-09-23 13:44:38 -0500107 # This function intentionally left blank
108 :
109}
110
111
112# Restore xtrace
113$MY_XTRACE
114
115# Local variables:
116# mode: shell-script
117# End: