Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
d4443a6
Start work on Azure ARM
Aug 21, 2016
b2782a7
Update AzureResourceManagerConnection
Aug 21, 2016
7131c77
Refactor machine types and initialiser for the new driver
Aug 21, 2016
c79f44d
Update the host
Aug 21, 2016
cec35c5
Copy pasta the HTTP request code
Aug 21, 2016
6280dca
Add some placeholders
Aug 21, 2016
a86a796
Add _default_path_prefix
Aug 21, 2016
49cbeb9
Add API version by default
Aug 21, 2016
fde6eb9
Completed method list_locations
Denvar94 Aug 21, 2016
2c7cf8f
Fix cyclic dependencies
Aug 21, 2016
23123fa
Remove the redundant class
Aug 21, 2016
2461c0a
Fix this path
Aug 21, 2016
2639e35
Added mapping of json to Node Location method
Denvar94 Aug 21, 2016
d80706c
Merge conflict resovled
Denvar94 Aug 21, 2016
3433fc7
Using property decorator
Denvar94 Aug 21, 2016
f6d8072
Clean up
Denvar94 Aug 21, 2016
e1fc469
Uses NodeLocation for the new API
Denvar94 Aug 21, 2016
4a7c2d9
Use a proper JSON response
Aug 22, 2016
d80af53
Fix typo
Aug 22, 2016
7800e05
Use single quotes
Aug 22, 2016
8868ad2
Add list_sizes
Aug 22, 2016
1fc425c
For now, allow using different API versions
Aug 22, 2016
ce7c893
Fix wrong key
Aug 22, 2016
4f5d8ca
Added list_nodes function
Denvar94 Aug 22, 2016
82c575b
Added documentation
Denvar94 Aug 22, 2016
6a1bfeb
Add create_node method
Aug 22, 2016
6e44b9b
Create a public IP address
Aug 22, 2016
8c9af5e
Create a public IP address
Aug 22, 2016
3f44a85
Finish create_node call
Aug 22, 2016
42cde54
Parse body before returning
Aug 22, 2016
d194f5f
clean up"
Denvar94 Aug 22, 2016
91a7e79
Merge branch 'azure-arm' of github.com:esplorio/libcloud into azure-arm
Denvar94 Aug 22, 2016
e62e466
Use location.id
Aug 22, 2016
97c21ac
Fix typo
Aug 22, 2016
9e704c3
API Version update
Aug 22, 2016
436548d
Try an image ref instead
Aug 22, 2016
b08b19a
Update ssh key path
Aug 22, 2016
8f21918
Populate the Node to retun list of nodes
Denvar94 Aug 22, 2016
96db814
Merge branch 'azure-arm' of github.com:esplorio/libcloud into azure-arm
Denvar94 Aug 22, 2016
9617866
Fix data queries
Aug 22, 2016
b03dd1e
Return a node on create_node
Aug 22, 2016
11133bb
Return an empty node
Aug 22, 2016
04ac546
Reconstruct the URL
Aug 22, 2016
7c0f5c8
This is actually a list
Aug 22, 2016
d0605e6
Put IP addresses in the right place
Aug 22, 2016
07c6894
Added call to retreive public ip address
Denvar94 Aug 22, 2016
830d4c2
Use static allocation
Aug 22, 2016
e06ba37
Add missing property
Aug 22, 2016
aa31c67
Make these dynamic now
Aug 22, 2016
fa9b7da
Fix typo
Aug 22, 2016
2493868
Add distinction between these methods
Aug 22, 2016
26bfdfa
Add NodeState config
Aug 22, 2016
8bf08f2
Add error output
Aug 22, 2016
a480dd7
Add availability set
Aug 22, 2016
69dd20a
Remove typo
Aug 22, 2016
d41413d
Added comments to get methods
Denvar94 Aug 22, 2016
2a026a0
Add a domainNameLabel setting
Aug 23, 2016
2f1c08c
Add data disk option
Aug 23, 2016
43c7102
Merge branch 'azure-arm' of github.com:esplorio/libcloud into azure-arm
Aug 23, 2016
8d39228
Use ReadWrite cache option
Aug 23, 2016
7b7c375
Add missing key
Aug 23, 2016
c12d454
Add retry handling for rate limit errors
Aug 24, 2016
c95734f
Add explicit None check for retries
Aug 24, 2016
de13e7e
Forgot a return
Aug 24, 2016
890008b
Add comment
Aug 24, 2016
427b223
Clean up lint errors
Denvar94 Aug 30, 2016
75bfb77
Limited character space in line to 79
Denvar94 Aug 30, 2016
d6c74ef
Update comment
Aug 31, 2016
ea680f4
Update how to create a token
Aug 31, 2016
359ccfb
Merge branch 'azure-arm' of github.com:esplorio/libcloud into azure-arm
Aug 31, 2016
22876a5
Add skeleton code for Azure Arm tests
Denvar94 Sep 14, 2016
fe1205b
Merge branch 'azure-arm' of github.com:esplorio/libcloud into azure-arm
Denvar94 Sep 14, 2016
ef09f39
List nodes without the need of a resource groups
Denvar94 Sep 15, 2016
062d1b2
Added set up method
Denvar94 Sep 15, 2016
b99ed02
Added test method for listing locations
Denvar94 Sep 15, 2016
6861b4e
Added method paths for testing
Denvar94 Sep 22, 2016
20e69ca
Added test data for tests
Denvar94 Sep 22, 2016
7ae09b5
Fixed list location method and added test
Denvar94 Sep 22, 2016
4c83263
Fixed urls in the sample jsons
Denvar94 Sep 22, 2016
c6e8819
Added methods to mock the requests for network information and amende…
Denvar94 Sep 22, 2016
58eef3c
Added test to check node addresses
Denvar94 Sep 22, 2016
5b9ff7f
Added class and methods to list azure images
Denvar94 Sep 23, 2016
ad5175d
Clean up
Denvar94 Sep 23, 2016
864a6c7
Added os propety to Azure image
Denvar94 Sep 23, 2016
b3101a7
Add azure image and public ip option
Denvar94 Sep 23, 2016
68b95e2
Added azure network, subnet and config classes
Denvar94 Sep 23, 2016
c73538f
Clean up
Denvar94 Sep 23, 2016
f0dbab1
Fix missing :
Denvar94 Sep 23, 2016
26ea3f1
Use network configuation in create node and create nic methods
Denvar94 Sep 23, 2016
e6f8a02
Clean up
Denvar94 Sep 23, 2016
9c1638e
Added reboot node method and perform post
Denvar94 Sep 23, 2016
c419a32
Fix typo
Sep 26, 2016
57e57c3
Added method to return the state of VM
Denvar94 Sep 26, 2016
7885f3e
Changed parameters of get state of node
Denvar94 Sep 26, 2016
35a5976
Added return value for reboot_node
Denvar94 Sep 27, 2016
b967446
Added destroy node method
Denvar94 Sep 27, 2016
6c70449
Fix typos
Nov 9, 2016
c8b347a
Fix URL
Nov 9, 2016
771b8ab
Add value access
Nov 9, 2016
0d8a041
Remove another typo
Nov 9, 2016
eebe390
Fix more typos
Nov 9, 2016
d2d678e
Missing list index
Nov 9, 2016
99fb070
Use a proper payload
Nov 9, 2016
ea75c79
Remove location/location.id ambiguity
Nov 9, 2016
d1bebbd
Remove confusing comment
Nov 9, 2016
ce5e619
Add missing path
Nov 9, 2016
388af05
Fix publisher/offer access
Nov 9, 2016
964b201
Update comparison
Nov 9, 2016
b7917f1
Do not return prematurely
Nov 10, 2016
a03cef7
Made changes to pass tox tests
Denvar94 Dec 13, 2016
d04acc1
Reordered functions to fit libcloud criteria
Denvar94 Dec 13, 2016
1eb4262
Renamed methods to fit libcloud criteria
Denvar94 Dec 13, 2016
7e91283
Add tests
Denvar94 Dec 13, 2016
1e0afaa
Amended parameter name in list_nodes to fit with libcloud format
Denvar94 Dec 13, 2016
6f93b33
Bug fixes and typos
Denvar94 Dec 13, 2016
5935c56
Updated method name to be internal
Denvar94 Dec 13, 2016
c7a9076
Added python 3 tests
Denvar94 Dec 13, 2016
43c53f3
Change method name
Denvar94 Dec 13, 2016
f763747
Added test fixtures for azure arm requests
Denvar94 Dec 13, 2016
8836cac
Added tests for list images
Denvar94 Dec 13, 2016
8f32c66
Added test for list sizes
Denvar94 Dec 14, 2016
59db36f
Added create vm test
Denvar94 Dec 22, 2016
10c89bf
Fixed create vm test
Denvar94 Dec 22, 2016
15ef6c9
Fixed node id issues
Denvar94 Dec 23, 2016
9054168
Get rid of redundant tests
Denvar94 Dec 23, 2016
20d7647
Use the correct node ID
Apr 18, 2017
c56dc90
Merge branch 'azure-arm' of github.com:esplorio/libcloud into azure-arm
Apr 18, 2017
1c9265a
Rewrite the script to allow for multiple storage accounts
May 23, 2017
5a9afcf
Remove ex_storage_account_name
May 23, 2017
29173e0
Fix the config
May 23, 2017
086a670
Assign a different LUN value
Jun 19, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
306 changes: 305 additions & 1 deletion libcloud/common/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import hmac

from hashlib import sha256

from libcloud.utils.py3 import httplib
from libcloud.utils.py3 import b
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this import b?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know this is classic azure stuff.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry looked at wrong file

from libcloud.utils.xml import fixxpath
Expand All @@ -31,7 +32,8 @@

from libcloud.common.types import InvalidCredsError
from libcloud.common.types import LibcloudError, MalformedResponseError
from libcloud.common.base import ConnectionUserAndKey, RawResponse
from libcloud.common.base import ConnectionUserAndKey, RawResponse, \
Connection, JsonResponse
from libcloud.common.base import CertificateConnection
from libcloud.common.base import XmlResponse

Expand All @@ -42,6 +44,258 @@
AZURE_TIME_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Microsoft offer a convention for the date format in their doc or is this just any date?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again this is classic azure stuff.



"""
Sizes must be hardcoded because Microsoft doesn't provide an API to fetch them
From http://msdn.microsoft.com/en-us/library/windowsazure/dn197896.aspx

Prices are for Linux instances in East US data center. To see what pricing will
actually be, visit:
http://azure.microsoft.com/en-gb/pricing/details/virtual-machines/
"""
AZURE_COMPUTE_INSTANCE_TYPES = {
'A0': {
'id': 'ExtraSmall',
'name': 'Extra Small Instance',
'ram': 768,
'disk': 127,
'bandwidth': None,
'price': '0.0211',
'max_data_disks': 1,
'cores': 'Shared'
},
'A1': {
'id': 'Small',
'name': 'Small Instance',
'ram': 1792,
'disk': 127,
'bandwidth': None,
'price': '0.0633',
'max_data_disks': 2,
'cores': 1
},
'A2': {
'id': 'Medium',
'name': 'Medium Instance',
'ram': 3584,
'disk': 127,
'bandwidth': None,
'price': '0.1266',
'max_data_disks': 4,
'cores': 2
},
'A3': {
'id': 'Large',
'name': 'Large Instance',
'ram': 7168,
'disk': 127,
'bandwidth': None,
'price': '0.2531',
'max_data_disks': 8,
'cores': 4
},
'A4': {
'id': 'ExtraLarge',
'name': 'Extra Large Instance',
'ram': 14336,
'disk': 127,
'bandwidth': None,
'price': '0.5062',
'max_data_disks': 16,
'cores': 8
},
'A5': {
'id': 'A5',
'name': 'Memory Intensive Instance',
'ram': 14336,
'disk': 127,
'bandwidth': None,
'price': '0.2637',
'max_data_disks': 4,
'cores': 2
},
'A6': {
'id': 'A6',
'name': 'A6 Instance',
'ram': 28672,
'disk': 127,
'bandwidth': None,
'price': '0.5273',
'max_data_disks': 8,
'cores': 4
},
'A7': {
'id': 'A7',
'name': 'A7 Instance',
'ram': 57344,
'disk': 127,
'bandwidth': None,
'price': '1.0545',
'max_data_disks': 16,
'cores': 8
},
'A8': {
'id': 'A8',
'name': 'A8 Instance',
'ram': 57344,
'disk': 127,
'bandwidth': None,
'price': '2.0774',
'max_data_disks': 16,
'cores': 8
},
'A9': {
'id': 'A9',
'name': 'A9 Instance',
'ram': 114688,
'disk': 127,
'bandwidth': None,
'price': '4.7137',
'max_data_disks': 16,
'cores': 16
},
'A10': {
'id': 'A10',
'name': 'A10 Instance',
'ram': 57344,
'disk': 127,
'bandwidth': None,
'price': '1.2233',
'max_data_disks': 16,
'cores': 8
},
'A11': {
'id': 'A11',
'name': 'A11 Instance',
'ram': 114688,
'disk': 127,
'bandwidth': None,
'price': '2.1934',
'max_data_disks': 16,
'cores': 16
},
'D1': {
'id': 'Standard_D1',
'name': 'D1 Faster Compute Instance',
'ram': 3584,
'disk': 127,
'bandwidth': None,
'price': '0.0992',
'max_data_disks': 2,
'cores': 1
},
'D2': {
'id': 'Standard_D2',
'name': 'D2 Faster Compute Instance',
'ram': 7168,
'disk': 127,
'bandwidth': None,
'price': '0.1983',
'max_data_disks': 4,
'cores': 2
},
'D3': {
'id': 'Standard_D3',
'name': 'D3 Faster Compute Instance',
'ram': 14336,
'disk': 127,
'bandwidth': None,
'price': '0.3965',
'max_data_disks': 8,
'cores': 4
},
'D4': {
'id': 'Standard_D4',
'name': 'D4 Faster Compute Instance',
'ram': 28672,
'disk': 127,
'bandwidth': None,
'price': '0.793',
'max_data_disks': 16,
'cores': 8
},
'D11': {
'id': 'Standard_D11',
'name': 'D11 Faster Compute Instance',
'ram': 14336,
'disk': 127,
'bandwidth': None,
'price': '0.251',
'max_data_disks': 4,
'cores': 2
},
'D12': {
'id': 'Standard_D12',
'name': 'D12 Faster Compute Instance',
'ram': 28672,
'disk': 127,
'bandwidth': None,
'price': '0.502',
'max_data_disks': 8,
'cores': 4
},
'D13': {
'id': 'Standard_D13',
'name': 'D13 Faster Compute Instance',
'ram': 57344,
'disk': 127,
'bandwidth': None,
'price': '0.9038',
'max_data_disks': 16,
'cores': 8
},
'D14': {
'id': 'Standard_D14',
'name': 'D14 Faster Compute Instance',
'ram': 114688,
'disk': 127,
'bandwidth': None,
'price': '1.6261',
'max_data_disks': 32,
'cores': 16
},
'Standard_D2_v2': {
'id': 'Standard_D2_v2',
'name': 'D2 v2 Faster Compute Instance',
'ram': 7168,
'disk': 100,
'bandwidth': None,
'price': '0.16',
'max_data_disks': 4,
'cores': 2
},
'Standard_D3_v2': {
'id': 'Standard_D3_v2',
'name': 'D3 v2 Faster Compute Instance',
'ram': 14336,
'disk': 200,
'bandwidth': None,
'price': '0.319',
'max_data_disks': 8,
'cores': 4
},
'Standard_D4_v2': {
'id': 'Standard_D4_v2',
'name': 'D4 v2 Faster Compute Instance',
'ram': 28672,
'disk': 400,
'bandwidth': None,
'price': '0.672',
'max_data_disks': 16,
'cores': 8
},
'Standard_D5_v2': {
'id': 'Standard_D5_v2',
'name': 'D5 v2 Faster Compute Instance',
'ram': 57344,
'disk': 800,
'bandwidth': None,
'price': '1.277',
'max_data_disks': 32,
'cores': 16
}
}


class AzureRedirectException(Exception):

def __init__(self, response):
Expand Down Expand Up @@ -293,3 +547,53 @@ def add_default_headers(self, headers):
headers['x-ms-date'] = time.strftime(AZURE_TIME_FORMAT, time.gmtime())
# headers['host'] = self.host
return headers


class AzureARMResponse(JsonResponse):

valid_response_codes = [
httplib.NOT_FOUND,
httplib.CONFLICT,
httplib.BAD_REQUEST,
httplib.TEMPORARY_REDIRECT
# added TEMPORARY_REDIRECT as this can sometimes be
# sent by azure instead of a success or fail response
]

def success(self):
i = int(self.status)
return 200 <= i <= 299 or i in self.valid_response_codes


class AzureResourceManagerConnection(Connection):
driver = AzureBaseDriver
responseCls = AzureARMResponse
rawResponseCls = AzureRawResponse
name = 'Azure Resource Manager API Connection'
host = 'management.azure.com'
token = ''

def __init__(self, subscription_id, token, *args, **kwargs):
"""
:param subscription_id: Azure subscription ID.
:type subscription_id: ``str``

:param token: JSON web token to authenticate with
Azure Active Directory
:type token: ``str``
"""

super(AzureResourceManagerConnection, self).__init__(
*args,
**kwargs
)
self.subscription_id = subscription_id
self.token = token

def add_default_headers(self, headers):
"""
@inherits: :class:`Connection.add_default_headers`
"""
headers['Content-Type'] = 'application/json'
headers['Authorization'] = 'Bearer %s' % self.token
return headers
3 changes: 3 additions & 0 deletions libcloud/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,8 @@ def exception_from_message(code, message, headers=None):
if headers and 'retry_after' in headers:
kwargs['retry_after'] = headers['retry_after']

if headers and 'retry-after' in headers:
kwargs['retry_after'] = headers['retry-after']

cls = _code_map.get(code, BaseHTTPError)
return cls(**kwargs)
Loading