README.rst 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. cloudbridge
  2. ===========
  3. cloudbridge provides a layer of abstraction over different cloud providers.
  4. It's a straightforward implementation of the `bridge pattern`_. It is currently
  5. under development and is in a Pre-Alpha state.
  6. .. image:: https://codeclimate.com/github/gvlproject/cloudbridge/badges/gpa.svg
  7. :target: https://codeclimate.com/github/gvlproject/cloudbridge
  8. :alt: Code Climate
  9. .. image:: https://landscape.io/github/gvlproject/cloudbridge/master/landscape.svg?style=flat
  10. :target: https://landscape.io/github/gvlproject/cloudbridge/master
  11. :alt: Landscape Code Health
  12. .. image:: https://coveralls.io/repos/gvlproject/cloudbridge/badge.svg?branch=master&service=github
  13. :target: https://coveralls.io/github/gvlproject/cloudbridge?branch=master
  14. :alt: Code Coverage
  15. .. image:: https://travis-ci.org/gvlproject/cloudbridge.svg?branch=master
  16. :target: https://travis-ci.org/gvlproject/cloudbridge
  17. :alt: Travis Build Status
  18. .. image:: https://img.shields.io/pypi/status/cloudbridge.svg
  19. :target: https://pypi.python.org/pypi/cloudbridge/
  20. :alt: latest version available on PyPI
  21. Usage example
  22. ~~~~~~~~~~~~~
  23. The simplest possible example for doing something useful with cloudbridge would
  24. look like the following.
  25. .. code-block:: python
  26. from cloudbridge.providers.factory import CloudProviderFactory, ProviderList
  27. provider = CloudProviderFactory().create_provider(ProviderList.AWS, {})
  28. print(provider.security.key_pairs.list())
  29. In the example above, the AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables
  30. must be set to your AWS credentials.
  31. Documentation
  32. ~~~~~~~~~~~~~
  33. Documentation can be found at https://cloudbridge.readthedocs.org.
  34. Design Goals
  35. ~~~~~~~~~~~~
  36. 1. Create a cloud abstraction layer which minimises or eliminates the
  37. need for cloud specific special casing.
  38. i.e. Not require clients to write if EC2 do x else if OPENSTACK do y.
  39. 2. Have a suite of conformance tests which are comprehensive enough that goal 1
  40. can be achieved. This would also mean that clients need not manually test against
  41. each provider to make sure their application is compatible.
  42. 3. Opt for a minimum set of features that a cloud provider will support,
  43. instead of a lowest common denominator approach. This means that reasonably
  44. mature clouds like Amazon and Openstack are used as the benchmark against which
  45. functionality & features are determined. Therefore, there is a definite
  46. expectation that the cloud infrastructure will support a compute service with
  47. support for images and snapshots and various machine sizes. The cloud
  48. infrastructure will very likely support block storage, although this is
  49. currently optional. It may optionally support object storage
  50. 4. Make the cloudbridge layer as thin as possible without compromising goal 1.
  51. By wrapping the cloud provider's native SDK and doing the minimal work necessary
  52. to adapt the interface, we can achieve greater development speed and reliability
  53. since the native provider SDK is most likely to have both properties.
  54. Contributing
  55. ~~~~~~~~~~~~
  56. Community contributions for any part of the project are welcome. If you have
  57. a completely new idea or would like to bounce your idea before moving forward
  58. with the implementation, feel free to create an issue to start a discussion.
  59. Contributions should come in the form or a pull request. We strive for 100%
  60. test coverage so code will only be accepted if it comes with appropriate tests
  61. and it does not break existing functionality. Further, the code needs to be
  62. well documented and all methods have docstrings.
  63. Conceptually, the library is laid out such that there is a factory used to
  64. create a reference to a cloud provider. Each provider offers a set of services
  65. and resources. Services typically perform actions while resources offer
  66. information (and can act on itself, when appropriate). The structure of each
  67. object is defined via an abstract interface (see
  68. ``cloudbridge/providers/interfaces``) and any object should implement the
  69. defined interface.
  70. Running tests
  71. ~~~~~~~~~~~~~
  72. To run the test suite locally, install `tox`_ with :code:`pip install tox`
  73. and run ``tox`` command. This will run all the tests for
  74. all the environments defined in file ``tox.ini``. In order to properly run the
  75. tests, you should have all the environment variables listed in
  76. ``tox.ini`` file (under ``passenv``) exported.
  77. If you’d like to run the tests on a specific environment only, use a command
  78. like such: ``tox -e py27`` (or ``python setup.py test`` directly). If you'd
  79. like to run the tests for a specific cloud only, you should export env var
  80. ``CB_TEST_PROVIDER`` and specify the desired provider name (e.g., ``aws`` or
  81. ``openstack``) and then run the ``tox`` command.
  82. Note that running the tests may create various cloud resources, for which you
  83. may incur costs. For the AWS cloud, there is also a mock provider that will
  84. simulate AWS resources. It is used by default when running the test suite. To
  85. disable it, set the following environment variable:
  86. ``export CB_USE_MOCK_DRIVERS=No``.
  87. Testing philosophy
  88. ~~~~~~~~~~~~~~~~~~
  89. Our testing goals are to:
  90. * Write one set of tests that all provider implementations must pass.
  91. * Make that set of tests a 'conformance' test suite which validates that each
  92. implementation correctly implements the cloudbridge specification.
  93. * Make the test suite comprehensive enough that a provider which passes all the
  94. tests can be used safely by an application with no additional testing. In other
  95. words, the cloudbridge specification and accompanying test suite must be
  96. comprehensive enough that no provider specific workarounds, code or testing is
  97. required.
  98. * For development, mock providers may be used to speed up the feedback cycle,
  99. but providers must also pass the full suite of tests when run against actual
  100. cloud infrastructure to ensure that we are not testing against an idealised
  101. or imagined environment.
  102. * Aim for 100% code coverage.
  103. .. _`bridge pattern`: https://en.wikipedia.org/wiki/Bridge_pattern
  104. .. _`tox`: https://tox.readthedocs.org/en/latest/