README.rst 6.6 KB

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