Guest User

Untitled

a guest
Oct 16th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Sample ``local.sh`` for user-configurable tasks to run automatically
  4. # at the successful conclusion of ``stack.sh``.
  5.  
  6. # NOTE: Copy this file to the root DevStack directory for it to work properly.
  7.  
  8. # This is a collection of some of the things we have found to be useful to run
  9. # after ``stack.sh`` to tweak the OpenStack configuration that DevStack produces.
  10. # These should be considered as samples and are unsupported DevStack code.
  11.  
  12.  
  13. # Keep track of the DevStack directory
  14. TOP_DIR=$(cd $(dirname "$0") && pwd)
  15.  
  16. # Import common functions
  17. source $TOP_DIR/functions
  18.  
  19. # Use openrc + stackrc + localrc for settings
  20. source $TOP_DIR/stackrc
  21.  
  22. # Destination path for installation ``DEST``
  23. DEST=${DEST:-/opt/stack}
  24.  
  25. if is_service_enabled nova; then
  26.  
  27. # Import ssh keys
  28. # ---------------
  29.  
  30. # Import keys from the current user into the default OpenStack user (usually
  31. # ``demo``)
  32.  
  33. # Get OpenStack user auth
  34. source $TOP_DIR/openrc demo demo
  35.  
  36. # Add first keypair found in localhost:$HOME/.ssh
  37. for i in $HOME/.ssh/id_rsa.pub $HOME/.ssh/id_dsa.pub; do
  38. if [[ -r $i ]]; then
  39. openstack keypair create --public-key $i default
  40. break
  41. fi
  42. done
  43.  
  44.  
  45. # Create A Flavor
  46. # ---------------
  47.  
  48. # Get OpenStack admin auth
  49. source $TOP_DIR/openrc admin admin
  50.  
  51. # Name of new flavor
  52. # set in ``local.conf`` with ``DEFAULT_INSTANCE_TYPE=m1.micro``
  53. MI_NAME=m1.micro
  54.  
  55. # Create micro flavor if not present
  56. if [[ -z $(openstack flavor list | grep $MI_NAME) ]]; then
  57. openstack flavor create $MI_NAME --id 6 --ram 128 --disk 0 --vcpus 1
  58. fi
  59.  
  60.  
  61. # Other Uses
  62. # ----------
  63.  
  64. # Get OpenStack user auth
  65. source $TOP_DIR/openrc demo demo
  66.  
  67. # Add tcp/22 and icmp to default security group
  68. openstack security group rule create default --protocol tcp --ingress --dst-port 22
  69. openstack security group rule create default --protocol icmp
  70.  
  71. # My config
  72. # ---------
  73.  
  74. # Get OpenStack user auth
  75. source $TOP_DIR/openrc demo demo
  76.  
  77. openstack subnet set private-subnet --dns-nameserver 1.1.1.1
  78.  
  79. fi
Add Comment
Please, Sign In to add comment