Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 3 | # lib/nova_plugins/hypervisor-libvirt |
| 4 | # Configure the libvirt hypervisor |
| 5 | |
| 6 | # Enable with: |
| 7 | # VIRT_DRIVER=libvirt |
| 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 |
| 20 | MY_XTRACE=$(set +o | grep xtrace) |
| 21 | set +o xtrace |
| 22 | |
Adam Gandelman | 0f73ff2 | 2014-03-13 14:20:43 -0700 | [diff] [blame] | 23 | source $TOP_DIR/lib/nova_plugins/functions-libvirt |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 24 | |
| 25 | # Defaults |
| 26 | # -------- |
| 27 | |
Russell Bryant | 5705db6 | 2014-02-01 20:06:42 -0500 | [diff] [blame] | 28 | # File injection is disabled by default in Nova. This will turn it back on. |
| 29 | ENABLE_FILE_INJECTION=${ENABLE_FILE_INJECTION:-False} |
| 30 | |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 31 | |
| 32 | # Entry Points |
| 33 | # ------------ |
| 34 | |
| 35 | # clean_nova_hypervisor - Clean up an installation |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 36 | function cleanup_nova_hypervisor { |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 37 | # This function intentionally left blank |
| 38 | : |
| 39 | } |
| 40 | |
| 41 | # configure_nova_hypervisor - Set config files, create data dirs, etc |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 42 | function configure_nova_hypervisor { |
Adam Gandelman | 0f73ff2 | 2014-03-13 14:20:43 -0700 | [diff] [blame] | 43 | configure_libvirt |
Joe Gordon | 1cd8efc | 2014-04-17 16:46:36 -0700 | [diff] [blame] | 44 | iniset $NOVA_CONF libvirt virt_type "$LIBVIRT_TYPE" |
| 45 | iniset $NOVA_CONF libvirt cpu_mode "none" |
Gary Kotton | 51c681d | 2014-04-22 01:40:56 -0700 | [diff] [blame] | 46 | iniset $NOVA_CONF libvirt use_usb_tablet "False" |
Adam Gandelman | a1ffcfa | 2014-11-20 16:42:32 -0800 | [diff] [blame] | 47 | iniset $NOVA_CONF libvirt live_migration_uri "qemu+ssh://$STACK_USER@%s/system" |
Sean Dague | 6bf1f1f | 2014-02-01 17:05:18 -0500 | [diff] [blame] | 48 | iniset $NOVA_CONF DEFAULT default_ephemeral_format "ext4" |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 49 | iniset $NOVA_CONF DEFAULT compute_driver "libvirt.LibvirtDriver" |
| 50 | LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"} |
| 51 | iniset $NOVA_CONF DEFAULT firewall_driver "$LIBVIRT_FIREWALL_DRIVER" |
| 52 | # Power architecture currently does not support graphical consoles. |
| 53 | if is_arch "ppc64"; then |
| 54 | iniset $NOVA_CONF DEFAULT vnc_enabled "false" |
| 55 | fi |
Russell Bryant | 5705db6 | 2014-02-01 20:06:42 -0500 | [diff] [blame] | 56 | |
Sean Dague | 5375329 | 2014-12-04 19:38:15 -0500 | [diff] [blame] | 57 | ENABLE_FILE_INJECTION=$(trueorfalse False ENABLE_FILE_INJECTION) |
Russell Bryant | 5705db6 | 2014-02-01 20:06:42 -0500 | [diff] [blame] | 58 | if [[ "$ENABLE_FILE_INJECTION" = "True" ]] ; then |
| 59 | # When libguestfs is available for file injection, enable using |
| 60 | # libguestfs to inspect the image and figure out the proper |
| 61 | # partition to inject into. |
| 62 | iniset $NOVA_CONF libvirt inject_partition '-1' |
| 63 | iniset $NOVA_CONF libvirt inject_key 'true' |
| 64 | else |
| 65 | # File injection is being disabled by default in the near future - |
| 66 | # disable it here for now to avoid surprises later. |
| 67 | iniset $NOVA_CONF libvirt inject_partition '-2' |
| 68 | fi |
Evgeny Antyshev | 1935458 | 2014-11-24 14:20:35 +0400 | [diff] [blame] | 69 | |
| 70 | if [[ "$LIBVIRT_TYPE" = "parallels" ]]; then |
| 71 | iniset $NOVA_CONF libvirt connection_uri "parallels+unix:///system" |
| 72 | iniset $NOVA_CONF libvirt images_type "ploop" |
| 73 | fi |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | # install_nova_hypervisor() - Install external components |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 77 | function install_nova_hypervisor { |
Adam Gandelman | 0f73ff2 | 2014-03-13 14:20:43 -0700 | [diff] [blame] | 78 | install_libvirt |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 79 | |
| 80 | # Install and configure **LXC** if specified. LXC is another approach to |
| 81 | # splitting a system into many smaller parts. LXC uses cgroups and chroot |
| 82 | # to simulate multiple systems. |
| 83 | if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
| 84 | if is_ubuntu; then |
| 85 | if [[ "$DISTRO" > natty ]]; then |
| 86 | install_package cgroup-lite |
| 87 | fi |
| 88 | else |
| 89 | ### FIXME(dtroyer): figure this out |
| 90 | echo "RPM-based cgroup not implemented yet" |
| 91 | yum_install libcgroup-tools |
| 92 | fi |
| 93 | fi |
| 94 | } |
| 95 | |
| 96 | # start_nova_hypervisor - Start any required external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 97 | function start_nova_hypervisor { |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 98 | # This function intentionally left blank |
| 99 | : |
| 100 | } |
| 101 | |
| 102 | # stop_nova_hypervisor - Stop any external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 103 | function stop_nova_hypervisor { |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 104 | # This function intentionally left blank |
| 105 | : |
| 106 | } |
| 107 | |
| 108 | |
| 109 | # Restore xtrace |
| 110 | $MY_XTRACE |
| 111 | |
| 112 | # Local variables: |
| 113 | # mode: shell-script |
| 114 | # End: |