Updated Branches: refs/heads/trunk 906064007 -> df877a50d
docs: add a draft for pricing page. Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/df877a50 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/df877a50 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/df877a50 Branch: refs/heads/trunk Commit: df877a50d04b582601a3a95246936aab5dfedfa1 Parents: 9060640 Author: Tomaz Muraus <[email protected]> Authored: Thu Aug 8 01:15:18 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Thu Aug 8 01:15:18 2013 +0200 ---------------------------------------------------------------------- docs/compute/pricing.rst | 50 +++++++++++++++++++++++++++++++++++ docs/examples/compute/pricing.py | 19 +++++++++++++ 2 files changed, 69 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/df877a50/docs/compute/pricing.rst ---------------------------------------------------------------------- diff --git a/docs/compute/pricing.rst b/docs/compute/pricing.rst new file mode 100644 index 0000000..9dedf8f --- /dev/null +++ b/docs/compute/pricing.rst @@ -0,0 +1,50 @@ +Pricing +======= + +For majority of the compute providers Libcloud provides estimated pricing +information. Pricing information is available via the :attr:`price` attribute +on the :class:`NodeSize` object. :attr:`price` attribute is a :func:`float` +type and tells user how much it costs (in US dollars) to run a ``Node`` with a +specified ``NodeSize`` for an hour. + +Example bellow shows how to retrieve pricing for ``NodeSize`` objects using +:func:`list_sizes` method. + +.. literalinclude:: /examples/compute/pricing.py + :language: python + :emphasize-lines: 11-19 + +As noted above this pricing information is an estimate and you should only +be used as such. You should always check your provider website / control panel +for accurate pricing information and never rely solely on Libcloud pricing data. + +Besides that, many cloud providers also offer different pricing scheme based +on the volume and discounts for reserved instances. All of this information +is not taken into account in the simplistic "price per hour" pricing scheme +available in Libcloud. + +Where does the Libcloud pricing data come from? +----------------------------------------------- + +Most of the providers don't provide pricing information via the API which means +most of the pricing information is scrapped directly from the provider +websites. + +Pricing data which is scrapped from the provider websites is located in the +a JSON file (``data/pricing.json``) which is bundled with each release. This +pricing data is only updated once you install a new release which means it +could be out of date. + +Using a custom pricing file +--------------------------- + +.. note:: + + This functionality is only available in Libcloud trunk and higher. + +Updating pricing +---------------- + +.. note:: + + This functionality is only available in Libcloud trunk and higher. http://git-wip-us.apache.org/repos/asf/libcloud/blob/df877a50/docs/examples/compute/pricing.py ---------------------------------------------------------------------- diff --git a/docs/examples/compute/pricing.py b/docs/examples/compute/pricing.py new file mode 100644 index 0000000..65b4933 --- /dev/null +++ b/docs/examples/compute/pricing.py @@ -0,0 +1,19 @@ +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver + +EC2_ACCESS_ID = 'your access id' +EC2_SECRET_KEY = 'your secret key' + +cls = get_driver(Provider.EC2) +driver = cls(EC2_ACCESS_ID, EC2_SECRET_KEY) +sizes = driver.list_sizes() + +>>> sizes[:5] +[<NodeSize: id=t1.micro, name=Micro Instance, ram=613 disk=15 bandwidth=None price=0.02 driver=Amazon EC2 ...>, + <NodeSize: id=m1.small, name=Small Instance, ram=1740 disk=160 bandwidth=None price=0.065 driver=Amazon EC2 ...>, + <NodeSize: id=m1.medium, name=Medium Instance, ram=3700 disk=410 bandwidth=None price=0.13 driver=Amazon EC2 ...>, + <NodeSize: id=m1.large, name=Large Instance, ram=7680 disk=850 bandwidth=None price=0.26 driver=Amazon EC2 ...>, + <NodeSize: id=m1.xlarge, name=Extra Large Instance, ram=15360 disk=1690 bandwidth=None price=0.52 driver=Amazon EC2 ...>] +>>> sizes[0].price +0.02 +>>>
