2
0

setup.rst 7.8 KB

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