setup.rst 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. =================== ==================
  13. Mandatory variables Optional Variables
  14. =================== ==================
  15. AWS_ACCESS_KEY
  16. AWS_SECRET_KEY
  17. =================== ==================
  18. **Openstack**
  19. =================== ==================
  20. Mandatory variables Optional Variables
  21. =================== ==================
  22. OS_AUTH_URL NOVA_SERVICE_NAME
  23. OS_USERNAME OS_COMPUTE_API_VERSION
  24. OS_PASSWORD OS_VOLUME_API_VERSION
  25. OS_PROJECT_NAME
  26. OS_REGION_NAME
  27. =================== ==================
  28. Once the environment variables are set, you can create a connection as follows:
  29. .. code-block:: python
  30. from cloudbridge.cloud.factory import CloudProviderFactory, ProviderList
  31. provider = CloudProviderFactory().create_provider(ProviderList.OPENSTACK, {})
  32. Providing access credentials through a dictionary
  33. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. You can initialize a simple config as follows. The key names are the same
  35. as the environment variables, in lower case. Note that the config dictionary
  36. will override environment values.
  37. .. code-block:: python
  38. from cloudbridge.cloud.factory import CloudProviderFactory, ProviderList
  39. config = {'aws_access_key' : '<your_access_key>',
  40. 'aws_secret_key' : '<your_secret_key>'}
  41. provider = CloudProviderFactory().create_provider(ProviderList.AWS, config)
  42. Some optional configuration values can only be provided through the config
  43. dictionary. These are listed below for each provider.
  44. **CloudBridge**
  45. ==================== ==================
  46. Variable Description
  47. ==================== ==================
  48. default_result_limit Number of results that a ``.list()`` method should return.
  49. Defaults to 50.
  50. ==================== ==================
  51. **Amazon**
  52. ==================== ==================
  53. Variable Description
  54. ==================== ==================
  55. ec2_is_secure True to use an SSL connection. Default is ``True``.
  56. ec2_region_name Default region name. Defaults to ``us-east-1``.
  57. ec2_region_endpoint Endpoint to use. Default is ``ec2.us-east-1.amazonaws.com``.
  58. ec2_port EC2 connection port. Does not need to be specified unless
  59. EC2 service is running on an alternative port.
  60. ec2_conn_path Connection path. Defaults to ``/``.
  61. ec2_validate_certs Whether to use SSL certificate verification. Default is
  62. ``False``.
  63. s3_is_secure True to use an SSL connection. Default is ``True``.
  64. s3_host Host connection endpoint. Default is ``s3.amazonaws.com``.
  65. s3_port Host connection port. Does not need to be specified unless
  66. S3 service is running on an alternative port.
  67. s3_conn_path Connection path. Defaults to ``/``.
  68. s3_validate_certs Whether to use SSL certificate verification. Default is
  69. ``False``.
  70. ==================== ==================
  71. Other configuration variables
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73. In addition to the provider specific configuration variables above, there are
  74. some general configuration environment variables that apply to CloudBridge as
  75. a whole
  76. ===================== ==================
  77. Variable Description
  78. ===================== ==================
  79. CB_DEBUG Setting ``CB_DEBUG=True`` will cause detailed debug
  80. output to be printed for each provider (including HTTP
  81. traces).
  82. CB_USE_MOCK_PROVIDERS Setting this to ``True`` will cause the CloudBridge test
  83. suite to use mock drivers when available.
  84. CB_TEST_PROVIDER Set this value to a valid :class:`.ProviderList` value
  85. such as ``aws``, to limit tests to that provider only.
  86. ===================== ==================