Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 1 | # 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 |
| 18 | MY_XTRACE=$(set +o | grep xtrace) |
| 19 | set +o xtrace |
| 20 | |
| 21 | |
| 22 | # Defaults |
| 23 | # -------- |
| 24 | |
| 25 | PUBLIC_INTERFACE_DEFAULT=eth2 |
| 26 | GUEST_INTERFACE_DEFAULT=eth1 |
| 27 | # Allow ``build_domU.sh`` to specify the flat network bridge via kernel args |
| 28 | FLAT_NETWORK_BRIDGE_DEFAULT=$(sed -e 's/.* flat_network_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline) |
| 29 | if is_service_enabled neutron; then |
| 30 | XEN_INTEGRATION_BRIDGE=$(sed -e 's/.* xen_integration_bridge=\([[:alnum:]]*\).*$/\1/g' /proc/cmdline) |
| 31 | fi |
| 32 | |
| 33 | VNCSERVER_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 Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 40 | function cleanup_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 41 | # This function intentionally left blank |
| 42 | : |
| 43 | } |
| 44 | |
| 45 | # configure_nova_hypervisor - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 46 | function configure_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 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" |
Bob Ball | 786a3a3 | 2014-06-16 08:37:05 +0100 | [diff] [blame] | 52 | 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 Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 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 Lakat | d15c8a0 | 2014-02-04 12:38:14 +0000 | [diff] [blame] | 59 | |
| 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 Ball | 348ae44 | 2014-03-20 16:56:04 +0000 | [diff] [blame] | 66 | # 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 Lakat | d15c8a0 | 2014-02-04 12:38:14 +0000 | [diff] [blame] | 70 | # install nova plugins to dom0 |
| 71 | tar -czf - -C $NOVA_DIR/plugins/xenserver/xenapi/etc/xapi.d/plugins/ ./ | |
Bob Ball | 348ae44 | 2014-03-20 16:56:04 +0000 | [diff] [blame] | 72 | $ssh_dom0 "tar -xzf - -C $PLUGIN_DIR && chmod a+x $PLUGIN_DIR/*" |
Mate Lakat | d15c8a0 | 2014-02-04 12:38:14 +0000 | [diff] [blame] | 73 | |
| 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 |
| 81 | CRONTAB |
| 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 Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | # install_nova_hypervisor() - Install external components |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 94 | function install_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 95 | # This function intentionally left blank |
| 96 | : |
| 97 | } |
| 98 | |
| 99 | # start_nova_hypervisor - Start any required external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 100 | function start_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 101 | # This function intentionally left blank |
| 102 | : |
| 103 | } |
| 104 | |
| 105 | # stop_nova_hypervisor - Stop any external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 106 | function stop_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 107 | # 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: |