blob: 984326106507e02f84e4851c73044f5998292aa7 [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
40function cleanup_nova_hypervisor() {
41 # This function intentionally left blank
42 :
43}
44
45# configure_nova_hypervisor - Set config files, create data dirs, etc
46function configure_nova_hypervisor() {
47 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"
52 iniset $NOVA_CONF DEFAULT xenapi_connection_url "$XENAPI_CONNECTION_URL"
53 iniset $NOVA_CONF DEFAULT xenapi_connection_username "$XENAPI_USER"
54 iniset $NOVA_CONF DEFAULT xenapi_connection_password "$XENAPI_PASSWORD"
55 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
66 # install nova plugins to dom0
67 tar -czf - -C $NOVA_DIR/plugins/xenserver/xenapi/etc/xapi.d/plugins/ ./ |
68 $ssh_dom0 'tar -xzf - -C /etc/xapi.d/plugins/ && chmod a+x /etc/xapi.d/plugins/*'
69
70 # install console logrotate script
71 tar -czf - -C $NOVA_DIR/tools/xenserver/ rotate_xen_guest_logs.sh |
72 $ssh_dom0 'tar -xzf - -C /root/ && chmod +x /root/rotate_xen_guest_logs.sh && mkdir -p /var/log/xen/guest'
73
74 # Create a cron job that will rotate guest logs
75 $ssh_dom0 crontab - << CRONTAB
76* * * * * /root/rotate_xen_guest_logs.sh
77CRONTAB
78
79 # Create directories for kernels and images
80 {
81 echo "set -eux"
82 cat $TOP_DIR/tools/xen/functions
83 echo "create_directory_for_images"
84 echo "create_directory_for_kernels"
85 } | $ssh_dom0
86
Dean Troyer9a532b82013-09-23 13:44:38 -050087}
88
89# install_nova_hypervisor() - Install external components
90function install_nova_hypervisor() {
91 # This function intentionally left blank
92 :
93}
94
95# start_nova_hypervisor - Start any required external services
96function start_nova_hypervisor() {
97 # This function intentionally left blank
98 :
99}
100
101# stop_nova_hypervisor - Stop any external services
102function stop_nova_hypervisor() {
103 # This function intentionally left blank
104 :
105}
106
107
108# Restore xtrace
109$MY_XTRACE
110
111# Local variables:
112# mode: shell-script
113# End: