System for quickly installing an OpenStack cloud from upstream git for testing and development.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.0KB

  1. #!/usr/bin/env bash
  2. #
  3. # source openrc [username] [projectname]
  4. #
  5. # Configure a set of credentials for $PROJECT/$USERNAME:
  6. # Set OS_PROJECT_NAME to override the default project 'demo'
  7. # Set OS_USERNAME to override the default user name 'demo'
  8. # Set ADMIN_PASSWORD to set the password for 'admin' and 'demo'
  9. # NOTE: support for the old NOVA_* novaclient environment variables has
  10. # been removed.
  11. if [[ -n "$1" ]]; then
  12. OS_USERNAME=$1
  13. fi
  14. if [[ -n "$2" ]]; then
  15. OS_PROJECT_NAME=$2
  16. fi
  17. # Find the other rc files
  18. RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
  19. # Import common functions
  20. source $RC_DIR/functions
  21. # Load local configuration
  22. source $RC_DIR/stackrc
  23. # Load the last env variables if available
  24. if [[ -r $RC_DIR/.stackenv ]]; then
  25. source $RC_DIR/.stackenv
  26. fi
  27. # Get some necessary configuration
  28. source $RC_DIR/lib/tls
  29. # The OpenStack ecosystem has standardized the term **project** as the
  30. # entity that owns resources. In some places **tenant** remains
  31. # referenced, but in all cases this just means **project**. We will
  32. # warn if we need to turn on legacy **tenant** support to have a
  33. # working environment.
  34. export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo}
  35. echo "WARNING: setting legacy OS_TENANT_NAME to support cli tools."
  36. export OS_TENANT_NAME=$OS_PROJECT_NAME
  37. # In addition to the owning entity (project), nova stores the entity performing
  38. # the action as the **user**.
  39. export OS_USERNAME=${OS_USERNAME:-demo}
  40. # With Keystone you pass the keystone password instead of an api key.
  41. # Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs
  42. # or NOVA_PASSWORD.
  43. export OS_PASSWORD=${ADMIN_PASSWORD:-secret}
  44. # Don't put the key into a keyring by default. Testing for development is much
  45. # easier with this off.
  46. export OS_NO_CACHE=${OS_NO_CACHE:-1}
  47. # Region
  48. export OS_REGION_NAME=${REGION_NAME:-RegionOne}
  49. # Set the host API endpoint. This will default to HOST_IP if SERVICE_IP_VERSION
  50. # is 4, else HOST_IPV6 if it's 6. SERVICE_HOST may also be used to specify the
  51. # endpoint, which is convenient for some localrc configurations. Additionally,
  52. # some exercises call Glance directly. On a single-node installation, Glance
  53. # should be listening on a local IP address, depending on the setting of
  54. # SERVICE_IP_VERSION. If its running elsewhere, it can be set here.
  55. if [[ $SERVICE_IP_VERSION == 6 ]]; then
  56. HOST_IPV6=${HOST_IPV6:-::1}
  57. SERVICE_HOST=${SERVICE_HOST:-[$HOST_IPV6]}
  58. GLANCE_HOST=${GLANCE_HOST:-[$HOST_IPV6]}
  59. else
  60. HOST_IP=${HOST_IP:-127.0.0.1}
  61. SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
  62. GLANCE_HOST=${GLANCE_HOST:-$HOST_IP}
  63. fi
  64. SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http}
  65. KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-$SERVICE_PROTOCOL}
  66. KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST}
  67. # Identity API version
  68. export OS_IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-3}
  69. # Authenticating against an OpenStack cloud using Keystone returns a **Token**
  70. # and **Service Catalog**. The catalog contains the endpoints for all services
  71. # the user/project has access to - including nova, glance, keystone, swift, ...
  72. # We currently recommend using the version 3 *identity api*.
  73. #
  74. export OS_AUTH_URL=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:5000/v${OS_IDENTITY_API_VERSION}
  75. # Currently, in order to use openstackclient with Identity API v3,
  76. # we need to set the domain which the user and project belong to.
  77. if [ "$OS_IDENTITY_API_VERSION" = "3" ]; then
  78. export OS_USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-"default"}
  79. export OS_PROJECT_DOMAIN_ID=${OS_PROJECT_DOMAIN_ID:-"default"}
  80. fi
  81. # Set OS_CACERT to a default CA certificate chain if it exists.
  82. if [[ ! -v OS_CACERT ]] ; then
  83. DEFAULT_OS_CACERT=$INT_CA_DIR/ca-chain.pem
  84. # If the file does not exist, this may confuse preflight sanity checks
  85. if [ -e $DEFAULT_OS_CACERT ] ; then
  86. export OS_CACERT=$DEFAULT_OS_CACERT
  87. fi
  88. fi
  89. # Currently cinderclient needs you to specify the *volume api* version. This
  90. # needs to match the config of your catalog returned by Keystone.
  91. export CINDER_VERSION=${CINDER_VERSION:-2}
  92. export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION}