Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 3 | # 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 Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 20 | _XTRACE_XENSERVER=$(set +o | grep xtrace) |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 21 | set +o xtrace |
| 22 | |
| 23 | |
| 24 | # Defaults |
| 25 | # -------- |
| 26 | |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 27 | VNCSERVER_PROXYCLIENT_ADDRESS=${VNCSERVER_PROXYCLIENT_ADDRESS=169.254.0.1} |
| 28 | |
| 29 | |
| 30 | # Entry Points |
| 31 | # ------------ |
| 32 | |
| 33 | # clean_nova_hypervisor - Clean up an installation |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 34 | function cleanup_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 35 | # This function intentionally left blank |
| 36 | : |
| 37 | } |
| 38 | |
| 39 | # configure_nova_hypervisor - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 40 | function configure_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 41 | if [ -z "$XENAPI_CONNECTION_URL" ]; then |
| 42 | die $LINENO "XENAPI_CONNECTION_URL is not specified" |
| 43 | fi |
Huan Xie | c608184 | 2016-11-16 00:40:32 -0800 | [diff] [blame] | 44 | |
| 45 | # Check os-xenapi plugin is enabled |
| 46 | local plugins="${DEVSTACK_PLUGINS}" |
| 47 | local plugin |
| 48 | local found=0 |
| 49 | for plugin in ${plugins//,/ }; do |
| 50 | if [[ "$plugin" = "os-xenapi" ]]; then |
| 51 | found=1 |
| 52 | break |
| 53 | fi |
| 54 | done |
| 55 | if [[ $found -ne 1 ]]; then |
| 56 | die $LINENO "os-xenapi plugin is not specified. Please enable this plugin in local.conf" |
| 57 | fi |
| 58 | |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 59 | iniset $NOVA_CONF DEFAULT compute_driver "xenapi.XenAPIDriver" |
Bob Ball | 786a3a3 | 2014-06-16 08:37:05 +0100 | [diff] [blame] | 60 | iniset $NOVA_CONF xenserver connection_url "$XENAPI_CONNECTION_URL" |
| 61 | iniset $NOVA_CONF xenserver connection_username "$XENAPI_USER" |
| 62 | iniset $NOVA_CONF xenserver connection_password "$XENAPI_PASSWORD" |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 63 | iniset $NOVA_CONF DEFAULT flat_injected "False" |
| 64 | # Need to avoid crash due to new firewall support |
| 65 | XEN_FIREWALL_DRIVER=${XEN_FIREWALL_DRIVER:-"nova.virt.firewall.IptablesFirewallDriver"} |
| 66 | iniset $NOVA_CONF DEFAULT firewall_driver "$XEN_FIREWALL_DRIVER" |
Mate Lakat | d15c8a0 | 2014-02-04 12:38:14 +0000 | [diff] [blame] | 67 | |
| 68 | local dom0_ip |
| 69 | dom0_ip=$(echo "$XENAPI_CONNECTION_URL" | cut -d "/" -f 3-) |
| 70 | |
| 71 | local ssh_dom0 |
| 72 | ssh_dom0="sudo -u $DOMZERO_USER ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$dom0_ip" |
| 73 | |
Mate Lakat | d15c8a0 | 2014-02-04 12:38:14 +0000 | [diff] [blame] | 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 |
jianghua wang | 797668b | 2015-10-08 06:40:21 +0100 | [diff] [blame] | 80 | * * * * * /root/rotate_xen_guest_logs.sh >/dev/null 2>&1 |
Mate Lakat | d15c8a0 | 2014-02-04 12:38:14 +0000 | [diff] [blame] | 81 | CRONTAB |
| 82 | |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | # install_nova_hypervisor() - Install external components |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 86 | function install_nova_hypervisor { |
Huan Xie | c608184 | 2016-11-16 00:40:32 -0800 | [diff] [blame] | 87 | # xenapi functionality is now included in os-xenapi library which houses the plugin |
| 88 | # so this function intentionally left blank |
| 89 | : |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | # start_nova_hypervisor - Start any required external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 93 | function start_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 94 | # This function intentionally left blank |
| 95 | : |
| 96 | } |
| 97 | |
| 98 | # stop_nova_hypervisor - Stop any external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 99 | function stop_nova_hypervisor { |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 100 | # This function intentionally left blank |
| 101 | : |
| 102 | } |
| 103 | |
| 104 | |
| 105 | # Restore xtrace |
Ian Wienand | 523f488 | 2015-10-13 11:03:03 +1100 | [diff] [blame] | 106 | $_XTRACE_XENSERVER |
Dean Troyer | 9a532b8 | 2013-09-23 13:44:38 -0500 | [diff] [blame] | 107 | |
| 108 | # Local variables: |
| 109 | # mode: shell-script |
| 110 | # End: |