setup.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 following ways:
  6. 1. Environment variables
  7. 2. A dictionary
  8. 3. Configuration file
  9. Providing access credentials through environment variables
  10. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. The following environment variables must be set, depending on the provider in use.
  12. **Amazon**
  13. =================== ==================
  14. Mandatory variables Optional Variables
  15. =================== ==================
  16. AWS_ACCESS_KEY
  17. AWS_SECRET_KEY
  18. =================== ==================
  19. **Openstack**
  20. =================== ==================
  21. Mandatory variables Optional Variables
  22. =================== ==================
  23. OS_AUTH_URL NOVA_SERVICE_NAME
  24. OS_USERNAME OS_COMPUTE_API_VERSION
  25. OS_PASSWORD OS_VOLUME_API_VERSION
  26. OS_PROJECT_NAME OS_STORAGE_URL
  27. OS_REGION_NAME OS_AUTH_TOKEN
  28. =================== ==================
  29. **Azure**
  30. ====================== ==================
  31. Mandatory variables Optional Variables
  32. ====================== ==================
  33. AZURE_SUBSCRIPTION_ID AZURE_REGION_NAME
  34. AZURE_CLIENT_ID AZURE_RESOURCE_GROUP
  35. AZURE_SECRET AZURE_STORAGE_ACCOUNT_NAME
  36. AZURE_TENANT
  37. ====================== ==================
  38. Once the environment variables are set, you can create a connection as follows:
  39. .. code-block:: python
  40. from cloudbridge.cloud.factory import CloudProviderFactory, ProviderList
  41. provider = CloudProviderFactory().create_provider(ProviderList.OPENSTACK, {})
  42. Providing access credentials through a dictionary
  43. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. You can initialize a simple config as follows. The key names are the same
  45. as the environment variables, in lower case. Note that the config dictionary
  46. will override environment values.
  47. .. code-block:: python
  48. from cloudbridge.cloud.factory import CloudProviderFactory, ProviderList
  49. config = {'aws_access_key' : '<your_access_key>',
  50. 'aws_secret_key' : '<your_secret_key>'}
  51. provider = CloudProviderFactory().create_provider(ProviderList.AWS, config)
  52. ## For Azure
  53. config = {'azure_subscription_id': '<your_subscription_id>',
  54. 'azure_client_id': '<your_client_id>',
  55. 'azure_secret': '<your_secret>',
  56. 'azure_tenant': '<your_tenant>',
  57. 'azure_resource_group': '<your resource group>'}
  58. provider = CloudProviderFactory().create_provider(ProviderList.AZURE, config)
  59. For Azure, Create service principle credentials from the following link :
  60. https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#check-azure-subscription-permissions
  61. Some optional configuration values can only be provided through the config
  62. dictionary. These are listed below for each provider.
  63. **CloudBridge**
  64. ==================== ==================
  65. Variable Description
  66. ==================== ==================
  67. default_result_limit Number of results that a ``.list()`` method should return.
  68. Defaults to 50.
  69. ==================== ==================
  70. **Amazon**
  71. ==================== ==================
  72. Variable Description
  73. ==================== ==================
  74. aws_session_token Session key for your AWS account (if using temporary
  75. credentials).
  76. ec2_is_secure True to use an SSL connection. Default is ``True``.
  77. ec2_region_name Default region name. Defaults to ``us-east-1``.
  78. ec2_region_endpoint Endpoint to use. Default is ``ec2.us-east-1.amazonaws.com``.
  79. ec2_port EC2 connection port. Does not need to be specified unless
  80. EC2 service is running on an alternative port.
  81. ec2_conn_path Connection path. Defaults to ``/``.
  82. ec2_validate_certs Whether to use SSL certificate verification. Default is
  83. ``False``.
  84. s3_is_secure True to use an SSL connection. Default is ``True``.
  85. s3_host Host connection endpoint. Default is ``s3.amazonaws.com``.
  86. s3_port Host connection port. Does not need to be specified unless
  87. S3 service is running on an alternative port.
  88. s3_conn_path Connection path. Defaults to ``/``.
  89. s3_validate_certs Whether to use SSL certificate verification. Default is
  90. ``False``.
  91. ==================== ==================
  92. Providing access credentials in a file
  93. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  94. CloudBridge can also read credentials from a file on your local file system.
  95. The file should be placed in one of two locations: ``/etc/cloudbridge.ini`` or
  96. ``~/.cloudbridge``. Each set of credentials should be delineated with the
  97. provider ID (e.g., ``openstack``, ``aws``, ``azure``) with the necessary credentials
  98. being supplied in YAML format. Note that only one set of credentials per
  99. cloud provider type can be supplied (i.e., via this method, it is not possible
  100. to provide credentials for two different OpenStack clouds).
  101. .. code-block:: bash
  102. [openstack]
  103. os_username: username
  104. os_password: password
  105. os_auth_url: auth url
  106. os_user_domain_name: user domain name
  107. os_project_domain_name: project domain name
  108. os_project_name: project name
  109. [aws]
  110. aws_access_key: access key
  111. aws_secret_key: secret key
  112. Other configuration variables
  113. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  114. In addition to the provider specific configuration variables above, there are
  115. some general configuration environment variables that apply to CloudBridge as
  116. a whole
  117. ====================== ==================
  118. Variable Description
  119. ====================== ==================
  120. CB_DEBUG Setting ``CB_DEBUG=True`` will cause detailed debug
  121. output to be printed for each provider (including HTTP
  122. traces).
  123. CB_USE_MOCK_PROVIDERS Setting this to ``True`` will cause the CloudBridge test
  124. suite to use mock drivers when available.
  125. CB_TEST_PROVIDER Set this value to a valid :class:`.ProviderList` value
  126. such as ``aws``, to limit tests to that provider only.
  127. CB_DEFAULT_SUBNET_NAME Name to be used for a subnet that will be considered
  128. the 'default' by the library. This default will be used
  129. only in cases there is no subnet marked as the default by the provider.
  130. CB_DEFAULT_NETWORK_NAME Name to be used for a network that will be considered
  131. the 'default' by the library. This default will be used
  132. only in cases there is no network marked as the default by the provider.
  133. ======================= ==================