setup.rst 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Setup
  2. -----
  3. To initialize a connection to a cloud and get a provider object, you will
  4. need to provide the cloud's access credentials to Cloudbridge. These may
  5. be provided in one of two ways:
  6. 1. Environment variables
  7. 2. A dictionary
  8. Providing access credentials through environment variables
  9. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  10. The following environment variables must be set, depending on the provider in use.
  11. **Amazon**
  12. *Mandatory variables*::
  13. AWS_ACCESS_KEY
  14. AWS_SECRET_KEY
  15. **Openstack**
  16. *Mandatory variables*::
  17. OS_AUTH_URL
  18. OS_USERNAME
  19. OS_PASSWORD
  20. OS_TENANT_NAME
  21. OS_REGION_NAME
  22. *Optional variables*::
  23. NOVA_SERVICE_NAME
  24. OS_COMPUTE_API_VERSION
  25. OS_VOLUME_API_VERSION
  26. Once the environment variables are set, you can create a connection as follows:
  27. .. code-block:: python
  28. from cloudbridge.cloud.factory import CloudProviderFactory, ProviderList
  29. provider = CloudProviderFactory().create_provider(ProviderList.OPENSTACK, {})
  30. Providing access credentials through a dictionary
  31. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  32. You can initialize a simple config as follows. The key names are the same
  33. as the environment variables, in lower case. Note that the config dictionary
  34. will override environment values.
  35. .. code-block:: python
  36. from cloudbridge.cloud.factory import CloudProviderFactory, ProviderList
  37. config = {'aws_access_key' : '<your_access_key>',
  38. 'aws_secret_key' : '<your_secret_key>'}
  39. provider = CloudProviderFactory().create_provider(ProviderList.AWS, config)