فهرست منبع

Made config variables consistent with env variables and added docs to
match.

Nuwan Goonasekera 10 سال پیش
والد
کامیت
0f0e1f82d4

+ 3 - 3
cloudbridge/cloud/base.py

@@ -60,7 +60,7 @@ class BaseConfiguration(Configuration):
         self.update(user_config)
 
     @property
-    def result_limit(self):
+    def default_result_limit(self):
         """
         Get the maximum number of results to return for a
         list method
@@ -68,7 +68,7 @@ class BaseConfiguration(Configuration):
         :rtype: ``int``
         :return: The maximum number of results to return
         """
-        return self.get('result_limit', DEFAULT_RESULT_LIMIT)
+        return self.get('default_result_limit', DEFAULT_RESULT_LIMIT)
 
     @property
     def debug_mode(self):
@@ -237,7 +237,7 @@ class ClientPagedResultList(BaseResultList):
 
     def __init__(self, provider, objects, limit=None, marker=None):
         self._objects = objects
-        limit = limit or provider.config.result_limit
+        limit = limit or provider.config.default_result_limit
         total_size = len(objects)
         if marker:
             from_marker = itertools.dropwhile(

+ 3 - 3
cloudbridge/cloud/interfaces/impl.py

@@ -34,7 +34,7 @@ class CloudProvider(object):
         Returns the config object associated with this provider. This object
         is a subclass of :class:`dict` and will contain the properties
         provided at initialization time. In addition, it also contains extra
-        provider-wide properties such as the default result_limit for list()
+        provider-wide properties such as the default result limit for list()
         queries.
 
         Example:
@@ -44,9 +44,9 @@ class CloudProvider(object):
             config = { 'aws_access_key' : '<my_key>' }
             provider = factory.create_provider(ProviderList.AWS, config)
             print(provider.config.get('aws_access_key'))
-            print(provider.config.result_limit))
+            print(provider.config.default_result_limit))
             # change provider result limit
-            provider.config.result_limit = 100
+            provider.config.default_result_limit = 100
 
         :rtype: :class:`.Configuration`
         :return:  An object of class Configuration, which contains the values

+ 1 - 1
cloudbridge/cloud/interfaces/resources.py

@@ -58,7 +58,7 @@ class Configuration(dict):
     """
 
     @abstractproperty
-    def result_limit(self):
+    def default_result_limit(self):
         """
         Get the maximum number of results to return for a
         list method

+ 6 - 5
cloudbridge/cloud/providers/aws/impl.py

@@ -27,15 +27,16 @@ class AWSCloudProvider(BaseCloudProvider):
 
         # Initialize cloud connection fields
         self.a_key = self._get_config_value(
-            'access_key', os.environ.get('AWS_ACCESS_KEY', None))
+            'aws_access_key', os.environ.get('AWS_ACCESS_KEY', None))
         self.s_key = self._get_config_value(
-            'secret_key', os.environ.get('AWS_SECRET_KEY', None))
+            'aws_secret_key', os.environ.get('AWS_SECRET_KEY', None))
         self.is_secure = self._get_config_value('is_secure', True)
-        self.region_name = self._get_config_value('region_name', 'us-east-1')
+        self.region_name = self._get_config_value(
+            'ec2_region_name', 'us-east-1')
         self.region_endpoint = self._get_config_value(
-            'region_endpoint', 'ec2.us-east-1.amazonaws.com')
+            'ec2_region_endpoint', 'ec2.us-east-1.amazonaws.com')
         self.ec2_port = self._get_config_value('ec2_port', '')
-        self.ec2_conn_path = self._get_config_value('ec2_port', '/')
+        self.ec2_conn_path = self._get_config_value('ec2_conn_path', '/')
 
         # service connections, lazily initialized
         self._ec2_conn = None

+ 2 - 2
cloudbridge/cloud/providers/openstack/helpers.py

@@ -9,7 +9,7 @@ def os_result_limit(provider, requested_limit):
     """
     Calculates the limit for openstack.
     """
-    limit = requested_limit or provider.config.result_limit
+    limit = requested_limit or provider.config.default_result_limit
     # fetch one more than the limit to help with paging.
     # i.e. if length(objects) is one more than the limit,
     # we know that the object has another page of results,
@@ -25,7 +25,7 @@ def to_server_paged_list(provider, objects, limit):
     BaseResultList, enabling extra properties like
     `is_truncated` and `marker` to be accessed.
     """
-    limit = limit or provider.config.result_limit
+    limit = limit or provider.config.default_result_limit
     is_truncated = len(objects) > limit
     next_token = objects[limit].id if is_truncated else None
     results = ServerPagedResultList(is_truncated,

+ 5 - 5
cloudbridge/cloud/providers/openstack/impl.py

@@ -29,15 +29,15 @@ class OpenStackCloudProvider(BaseCloudProvider):
 
         # Initialize cloud connection fields
         self.username = self._get_config_value(
-            'username', os.environ.get('OS_USERNAME', None))
+            'os_username', os.environ.get('OS_USERNAME', None))
         self.password = self._get_config_value(
-            'password', os.environ.get('OS_PASSWORD', None))
+            'os_password', os.environ.get('OS_PASSWORD', None))
         self.tenant_name = self._get_config_value(
-            'tenant_name', os.environ.get('OS_TENANT_NAME', None))
+            'os_tenant_name', os.environ.get('OS_TENANT_NAME', None))
         self.auth_url = self._get_config_value(
-            'auth_url', os.environ.get('OS_AUTH_URL', None))
+            'os_auth_url', os.environ.get('OS_AUTH_URL', None))
         self.region_name = self._get_config_value(
-            'region_name', os.environ.get('OS_REGION_NAME', None))
+            'os_region_name', os.environ.get('OS_REGION_NAME', None))
 
         # service connections, lazily initialized
         self._nova = None

+ 1 - 1
docs/topics/launch.rst

@@ -61,7 +61,7 @@ For OpenStack, the process is the same and you only need to specify the
 appropriate network interface ID (e.g.,
 ``lc.add_network_interface('5820c766-75fe-4fc6-96ef-798f67623238')``).
 
-Block Device Mapping
+Block device mapping
 --------------------
 Optionally, you may want to provide a block device mapping at launch,
 specifying volume or ephemeral storage mappings for the instance. While volumes

+ 38 - 0
docs/topics/setup.rst

@@ -55,3 +55,41 @@ will override environment values.
     config = {'aws_access_key' : '<your_access_key>',
               'aws_secret_key' : '<your_secret_key>'}
     provider = CloudProviderFactory().create_provider(ProviderList.AWS, config)
+
+Some optional configuration values can only be provided through the config dictionary. These
+are listed below for each provider.
+
+**CloudBridge**
+
+====================  ==================
+Variable		      Description
+====================  ==================
+default_result_limit  Number of results that a .list() method should return. Defaults to 50.
+====================  ==================
+
+
+**Amazon**
+
+====================  ==================
+Variable		      Description
+====================  ==================
+is_secure			  True to use an SSL connection. Default is True.
+ec2_region_name		  Default region name
+ec2_region_endpoint   Endpoint to use. Defaults to us-east-1.
+ec2_port		      EC2 connection port. Does not need to be specified unless EC2 servie is running on an alternative port.
+ec2_conn_path	      Connection path. Defaults to /
+====================  ==================
+
+
+Other configuration variables
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+In addition to the provider specific configuration variables above, there are some
+general configuration variables that apply to cloudbridge as a whole
+
+====================  ==================
+Variable		      Description
+====================  ==================
+CB_DEBUG			  Setting CB_DEBUG=True will cause detailed debug output to be printed for each provider (including HTTP traces).
+CB_USE_MOCK_PROVIDER  Setting this to True will cause the CloudBridge test suite to use mock drivers when available.
+CB_TEST_PROVIDER      Set this value to a valid :class:`.ProviderList` value such as ``aws``, to limit tests to that provider only.
+====================  ==================