Add a method for retrieving rates on Azure.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/938d9090 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/938d9090 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/938d9090 Branch: refs/heads/trunk Commit: 938d9090a31c13c7e0e28aac28c30965998afae7 Parents: 774ffde Author: Soren L. Hansen <so...@linux2go.dk> Authored: Sun Dec 11 08:14:58 2016 -0600 Committer: Anthony Shaw <anthonys...@apache.org> Committed: Tue Dec 27 19:42:08 2016 +1100 ---------------------------------------------------------------------- libcloud/compute/drivers/azure_arm.py | 34 + ...9_providers_Microsoft_Commerce_RateCard.json | 84270 +++++++++++++++++ libcloud/test/compute/test_azure_arm.py | 8 + 3 files changed, 84312 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/938d9090/libcloud/compute/drivers/azure_arm.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py index c7d0441..44abcdb 100644 --- a/libcloud/compute/drivers/azure_arm.py +++ b/libcloud/compute/drivers/azure_arm.py @@ -709,6 +709,40 @@ class AzureNodeDriver(NodeDriver): return True + def ex_get_ratecard(self, offer_durable_id, currency='USD', + locale='en-US', region='US'): + """ + Get rate card + + :param offer_durable_id: ID of the offer applicable for this + user account. (e.g. "0026P") + See http://azure.microsoft.com/en-us/support/legal/offer-details/ + :type offer_durable_id: str + + :param currency: Desired currency for the response (default: "USD") + :type currency: ``str`` + + :param locale: Locale (default: "en-US") + :type locale: ``str`` + + :param region: Region (two-letter code) (default: "US") + :type regions: ``str`` + + :return: A dictionary of rates whose ID's correspond to nothing at all + :rtype: ``dict`` + """ + + action = "/subscriptions/%s/providers/Microsoft.Commerce/" \ + "RateCard" % (self.subscription_id,) + params = {"api-version": "2016-08-31-preview", + "$filter": "OfferDurableId eq 'MS-AZR-%s' and " + "Currency eq '%s' and " + "Locale eq '%s' and " + "RegionInfo eq '%s'" % + (offer_durable_id, currency, locale, region)} + r = self.connection.request(action, params=params) + return r.object + def ex_list_publishers(self, location=None): """ List node image publishers.