| Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
 | 2 | # | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 3 | # lib/nova_plugins/hypervisor-ironic | 
 | 4 | # Configure the ironic hypervisor | 
 | 5 |  | 
 | 6 | # Enable with: | 
 | 7 | # VIRT_DRIVER=ironic | 
 | 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 | ea86174 | 2014-03-17 16:23:01 -0700 | [diff] [blame] | 23 | source $TOP_DIR/lib/nova_plugins/functions-libvirt | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 24 |  | 
 | 25 | # Defaults | 
 | 26 | # -------- | 
 | 27 |  | 
 | 28 | # Entry Points | 
 | 29 | # ------------ | 
 | 30 |  | 
 | 31 | # clean_nova_hypervisor - Clean up an installation | 
 | 32 | function cleanup_nova_hypervisor { | 
 | 33 |     # This function intentionally left blank | 
 | 34 |     : | 
 | 35 | } | 
 | 36 |  | 
 | 37 | # configure_nova_hypervisor - Set config files, create data dirs, etc | 
 | 38 | function configure_nova_hypervisor { | 
| Adam Gandelman | ea86174 | 2014-03-17 16:23:01 -0700 | [diff] [blame] | 39 |     configure_libvirt | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 40 |     LIBVIRT_FIREWALL_DRIVER=${LIBVIRT_FIREWALL_DRIVER:-"nova.virt.firewall.NoopFirewallDriver"} | 
| Davide Guerri | 08448e3 | 2014-03-21 18:14:18 +0000 | [diff] [blame] | 41 |  | 
| Devananda van der Veen | d0023fd | 2014-09-08 10:41:04 -0700 | [diff] [blame] | 42 |     iniset $NOVA_CONF DEFAULT compute_driver nova.virt.ironic.IronicDriver | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 43 |     iniset $NOVA_CONF DEFAULT firewall_driver $LIBVIRT_FIREWALL_DRIVER | 
| Devananda van der Veen | d0023fd | 2014-09-08 10:41:04 -0700 | [diff] [blame] | 44 |     iniset $NOVA_CONF DEFAULT scheduler_host_manager nova.scheduler.ironic_host_manager.IronicHostManager | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 45 |     iniset $NOVA_CONF DEFAULT ram_allocation_ratio 1.0 | 
 | 46 |     iniset $NOVA_CONF DEFAULT reserved_host_memory_mb 0 | 
 | 47 |     # ironic section | 
 | 48 |     iniset $NOVA_CONF ironic admin_username admin | 
 | 49 |     iniset $NOVA_CONF ironic admin_password $ADMIN_PASSWORD | 
| Jamie Lennox | 3561d7f | 2014-05-21 17:18:43 +1000 | [diff] [blame] | 50 |     iniset $NOVA_CONF ironic admin_url $KEYSTONE_AUTH_URI/v2.0 | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 51 |     iniset $NOVA_CONF ironic admin_tenant_name demo | 
| Adam Gandelman | 4b45fca | 2014-11-17 09:59:23 -0800 | [diff] [blame] | 52 |     iniset $NOVA_CONF ironic api_endpoint $IRONIC_SERVICE_PROTOCOL://$IRONIC_HOSTPORT/v1 | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 53 | } | 
 | 54 |  | 
 | 55 | # install_nova_hypervisor() - Install external components | 
 | 56 | function install_nova_hypervisor { | 
| Adam Gandelman | 6d27148 | 2014-08-05 18:12:29 -0700 | [diff] [blame] | 57 |     if ! is_service_enabled neutron; then | 
 | 58 |         die $LINENO "Neutron should be enabled for usage of the Ironic Nova driver." | 
| Zhongyue Luo | 37026f5 | 2014-12-16 10:56:54 +0800 | [diff] [blame] | 59 |     elif is_ironic_hardware; then | 
 | 60 |         return | 
| Adam Gandelman | 6d27148 | 2014-08-05 18:12:29 -0700 | [diff] [blame] | 61 |     fi | 
| Adam Gandelman | ea86174 | 2014-03-17 16:23:01 -0700 | [diff] [blame] | 62 |     install_libvirt | 
| Adam Gandelman | 9eb8177 | 2014-11-21 09:41:45 -0800 | [diff] [blame] | 63 |     if [[ "$IRONIC_VM_LOG_CONSOLE" == "True" ]] && is_ubuntu; then | 
 | 64 |         # Ubuntu packaging+apparmor issue prevents libvirt from loading | 
 | 65 |         # the ROM from /usr/share/misc.  Workaround by installing it directly | 
 | 66 |         # to a directory that it can read from. (LP: #1393548) | 
 | 67 |         sudo rm -rf /usr/share/qemu/sgabios.bin | 
 | 68 |         sudo cp /usr/share/misc/sgabios.bin /usr/share/qemu/sgabios.bin | 
 | 69 |     fi | 
| Alexander Gordeev | 06fb29c | 2014-01-31 18:02:07 +0400 | [diff] [blame] | 70 | } | 
 | 71 |  | 
 | 72 | # start_nova_hypervisor - Start any required external services | 
 | 73 | function start_nova_hypervisor { | 
 | 74 |     # This function intentionally left blank | 
 | 75 |     : | 
 | 76 | } | 
 | 77 |  | 
 | 78 | # stop_nova_hypervisor - Stop any external services | 
 | 79 | function stop_nova_hypervisor { | 
 | 80 |     # This function intentionally left blank | 
 | 81 |     : | 
 | 82 | } | 
 | 83 |  | 
 | 84 |  | 
 | 85 | # Restore xtrace | 
 | 86 | $MY_XTRACE | 
 | 87 |  | 
 | 88 | # Local variables: | 
 | 89 | # mode: shell-script | 
 | 90 | # End: |