Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 1 | # lib/nova_plugins/hypervisor-libvirt |
| 2 | # Configure the libvirt hypervisor |
| 3 | |
| 4 | # Enable with: |
| 5 | # VIRT_DRIVER=libvirt |
| 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 | |
Adam Gandelman | 0f73ff2 | 2014-03-13 14:20:43 -0700 | [diff] [blame] | 21 | source $TOP_DIR/lib/nova_plugins/functions-libvirt |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 22 | |
| 23 | # Defaults |
| 24 | # -------- |
| 25 | |
Russell Bryant | 5705db6 | 2014-02-01 20:06:42 -0500 | [diff] [blame] | 26 | # File injection is disabled by default in Nova. This will turn it back on. |
| 27 | ENABLE_FILE_INJECTION=${ENABLE_FILE_INJECTION:-False} |
| 28 | |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 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 | 8c032d1 | 2013-09-23 13:53:13 -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 { |
Adam Gandelman | 0f73ff2 | 2014-03-13 14:20:43 -0700 | [diff] [blame] | 41 | configure_libvirt |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 42 | iniset $NOVA_CONF DEFAULT libvirt_type "$LIBVIRT_TYPE" |
| 43 | iniset $NOVA_CONF DEFAULT libvirt_cpu_mode "none" |
| 44 | iniset $NOVA_CONF DEFAULT use_usb_tablet "False" |
Sean Dague | 6bf1f1f | 2014-02-01 17:05:18 -0500 | [diff] [blame] | 45 | iniset $NOVA_CONF DEFAULT default_ephemeral_format "ext4" |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 46 | iniset $NOVA_CONF DEFAULT compute_driver "libvirt.LibvirtDriver" |
| 47 | LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.libvirt.firewall.IptablesFirewallDriver"} |
| 48 | iniset $NOVA_CONF DEFAULT firewall_driver "$LIBVIRT_FIREWALL_DRIVER" |
| 49 | # Power architecture currently does not support graphical consoles. |
| 50 | if is_arch "ppc64"; then |
| 51 | iniset $NOVA_CONF DEFAULT vnc_enabled "false" |
| 52 | fi |
Russell Bryant | 5705db6 | 2014-02-01 20:06:42 -0500 | [diff] [blame] | 53 | |
| 54 | ENABLE_FILE_INJECTION=$(trueorfalse False $ENABLE_FILE_INJECTION) |
| 55 | if [[ "$ENABLE_FILE_INJECTION" = "True" ]] ; then |
| 56 | # When libguestfs is available for file injection, enable using |
| 57 | # libguestfs to inspect the image and figure out the proper |
| 58 | # partition to inject into. |
| 59 | iniset $NOVA_CONF libvirt inject_partition '-1' |
| 60 | iniset $NOVA_CONF libvirt inject_key 'true' |
| 61 | else |
| 62 | # File injection is being disabled by default in the near future - |
| 63 | # disable it here for now to avoid surprises later. |
| 64 | iniset $NOVA_CONF libvirt inject_partition '-2' |
| 65 | fi |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | # install_nova_hypervisor() - Install external components |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 69 | function install_nova_hypervisor { |
Adam Gandelman | 0f73ff2 | 2014-03-13 14:20:43 -0700 | [diff] [blame] | 70 | install_libvirt |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 71 | |
| 72 | # Install and configure **LXC** if specified. LXC is another approach to |
| 73 | # splitting a system into many smaller parts. LXC uses cgroups and chroot |
| 74 | # to simulate multiple systems. |
| 75 | if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then |
| 76 | if is_ubuntu; then |
| 77 | if [[ "$DISTRO" > natty ]]; then |
| 78 | install_package cgroup-lite |
| 79 | fi |
| 80 | else |
| 81 | ### FIXME(dtroyer): figure this out |
| 82 | echo "RPM-based cgroup not implemented yet" |
| 83 | yum_install libcgroup-tools |
| 84 | fi |
| 85 | fi |
| 86 | } |
| 87 | |
| 88 | # start_nova_hypervisor - Start any required external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 89 | function start_nova_hypervisor { |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 90 | # This function intentionally left blank |
| 91 | : |
| 92 | } |
| 93 | |
| 94 | # stop_nova_hypervisor - Stop any external services |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 95 | function stop_nova_hypervisor { |
Dean Troyer | 8c032d1 | 2013-09-23 13:53:13 -0500 | [diff] [blame] | 96 | # This function intentionally left blank |
| 97 | : |
| 98 | } |
| 99 | |
| 100 | |
| 101 | # Restore xtrace |
| 102 | $MY_XTRACE |
| 103 | |
| 104 | # Local variables: |
| 105 | # mode: shell-script |
| 106 | # End: |