You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2015/04/07 17:41:12 UTC
[1/3] libcloud git commit: Fix node_list check - list_nodes now
returns an empty list and not None.
Repository: libcloud
Updated Branches:
refs/heads/trunk 3745ffcaa -> abf026f8f
Fix node_list check - list_nodes now returns an empty list and not None.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4b63b8ff
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4b63b8ff
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4b63b8ff
Branch: refs/heads/trunk
Commit: 4b63b8ffad37bdcbf24bc46aefa6cf6c9894315d
Parents: 3745ffc
Author: Tomaz Muraus <to...@apache.org>
Authored: Tue Apr 7 14:44:04 2015 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Tue Apr 7 14:44:04 2015 +0200
----------------------------------------------------------------------
libcloud/compute/drivers/azure.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/4b63b8ff/libcloud/compute/drivers/azure.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure.py b/libcloud/compute/drivers/azure.py
index 503d8d0..487265c 100644
--- a/libcloud/compute/drivers/azure.py
+++ b/libcloud/compute/drivers/azure.py
@@ -484,7 +484,7 @@ class AzureNodeDriver(NodeDriver):
machine_config.domain_join = None
- if node_list is None or ex_new_deployment:
+ if not node_list or ex_new_deployment:
port = "3389"
else:
port = random.randint(41952, 65535)
@@ -509,7 +509,7 @@ class AzureNodeDriver(NodeDriver):
enable_direct_server_return=False
)
else:
- if node_list is None or ex_new_deployment:
+ if not node_list or ex_new_deployment:
port = "22"
else:
port = random.randint(41952, 65535)
@@ -572,7 +572,7 @@ class AzureNodeDriver(NodeDriver):
# must be created using the add_role function.
#
# So, yeah, annoying.
- if node_list is None or ex_new_deployment:
+ if not node_list or ex_new_deployment:
# This is the first node in this cloud service.
if not ex_deployment_name:
[2/3] libcloud git commit: Don't explode if image.extra doesn't
contain vm_image attribute.
Posted by to...@apache.org.
Don't explode if image.extra doesn't contain vm_image attribute.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6203951b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6203951b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6203951b
Branch: refs/heads/trunk
Commit: 6203951ba368cf74b23f085fd723738072d1c1a7
Parents: 4b63b8f
Author: Tomaz Muraus <to...@apache.org>
Authored: Tue Apr 7 15:53:06 2015 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Tue Apr 7 15:53:06 2015 +0200
----------------------------------------------------------------------
libcloud/compute/drivers/azure.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/6203951b/libcloud/compute/drivers/azure.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure.py b/libcloud/compute/drivers/azure.py
index 487265c..8cab6d8 100644
--- a/libcloud/compute/drivers/azure.py
+++ b/libcloud/compute/drivers/azure.py
@@ -628,7 +628,7 @@ class AzureNodeDriver(NodeDriver):
vm_image_id = None
disk_config = None
- if image.extra['vm_image']:
+ if image.extra.get('vm_image', False):
vm_image_id = image.id
# network_config = None
else:
[3/3] libcloud git commit: Some more consistency and style cleanup in
the Azure driver.
Posted by to...@apache.org.
Some more consistency and style cleanup in the Azure driver.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/abf026f8
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/abf026f8
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/abf026f8
Branch: refs/heads/trunk
Commit: abf026f8f8dbeeb4ca6912392e6fcbf0cc932cf9
Parents: 6203951
Author: Tomaz Muraus <to...@apache.org>
Authored: Tue Apr 7 17:33:04 2015 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Tue Apr 7 17:40:52 2015 +0200
----------------------------------------------------------------------
libcloud/compute/drivers/azure.py | 142 +++++++++++++++----------------
libcloud/test/compute/test_azure.py | 11 ++-
2 files changed, 74 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/abf026f8/libcloud/compute/drivers/azure.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/azure.py b/libcloud/compute/drivers/azure.py
index 8cab6d8..75404a9 100644
--- a/libcloud/compute/drivers/azure.py
+++ b/libcloud/compute/drivers/azure.py
@@ -64,13 +64,14 @@ else:
_str = str
_unicode_type = str
-__version__ = '1.0.0'
-
-azure_service_management_host = 'management.core.windows.net'
-_USER_AGENT_STRING = 'libcloudazurecompute/' + __version__
+AZURE_SERVICE_MANAGEMENT_HOST = 'management.core.windows.net'
X_MS_VERSION = '2013-08-01'
+WINDOWS_SERVER_REGEX = re.compile(
+ r'Win|SQL|SharePoint|Visual|Dynamics|DynGP|BizTalk'
+)
+
"""
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
@@ -395,61 +396,62 @@ class AzureNodeDriver(NodeDriver):
"""
Create Azure Virtual Machine
- Reference: http://bit.ly/1fIsCb7
- [www.windowsazure.com/en-us/documentation/]
+ Reference: http://bit.ly/1fIsCb7
+ [www.windowsazure.com/en-us/documentation/]
- We default to:
+ We default to:
- + 3389/TCP - RDP - 1st Microsoft instance.
- + RANDOM/TCP - RDP - All succeeding Microsoft instances.
+ + 3389/TCP - RDP - 1st Microsoft instance.
+ + RANDOM/TCP - RDP - All succeeding Microsoft instances.
- + 22/TCP - SSH - 1st Linux instance
- + RANDOM/TCP - SSH - All succeeding Linux instances.
+ + 22/TCP - SSH - 1st Linux instance
+ + RANDOM/TCP - SSH - All succeeding Linux instances.
- The above replicates the standard behavior of the Azure UI.
- You can retrieve the assigned ports to each instance by
- using the following private function:
+ The above replicates the standard behavior of the Azure UI.
+ You can retrieve the assigned ports to each instance by
+ using the following private function:
- _get_endpoint_ports(service_name)
- Returns public,private port key pair.
+ _get_endpoint_ports(service_name)
+ Returns public,private port key pair.
- @inherits: :class:`NodeDriver.create_node`
+ @inherits: :class:`NodeDriver.create_node`
- :keyword image: The image to use when creating this node
- :type image: `NodeImage`
+ :keyword image: The image to use when creating this node
+ :type image: `NodeImage`
- :keyword size: The size of the instance to create
- :type size: `NodeSize`
+ :keyword size: The size of the instance to create
+ :type size: `NodeSize`
- :keyword ex_cloud_service_name: Required.
- Name of the Azure Cloud Service.
- :type ex_cloud_service_name: ``str``
+ :keyword ex_cloud_service_name: Required.
+ Name of the Azure Cloud Service.
+ :type ex_cloud_service_name: ``str``
- :keyword ex_storage_service_name: Optional:
- Name of the Azure Storage Service.
- :type ex_storage_service_name: ``str``
+ :keyword ex_storage_service_name: Optional:
+ Name of the Azure Storage Service.
+ :type ex_storage_service_name: ``str``
- :keyword ex_new_deployment: Optional. Tells azure to create a
- new deployment rather than add to an
- existing one.
- :type ex_new_deployment: ``boolean``
+ :keyword ex_new_deployment: Optional. Tells azure to create a
+ new deployment rather than add to an
+ existing one.
+ :type ex_new_deployment: ``boolean``
- :keyword ex_deployment_slot: Optional: Valid values: production|
- staging.
- Defaults to production.
- :type ex_deployment_slot: ``str``
+ :keyword ex_deployment_slot: Optional: Valid values: production|
+ staging.
+ Defaults to production.
+ :type ex_deployment_slot: ``str``
- :keyword ex_deployment_name: Optional. The name of the
- deployment.
- If this is not passed in we default
- to using the Cloud Service name.
- :type ex_deployment_name: ``str``
+ :keyword ex_deployment_name: Optional. The name of the
+ deployment.
+ If this is not passed in we default
+ to using the Cloud Service name.
+ :type ex_deployment_name: ``str``
- :keyword ex_admin_user_id: Optional. Defaults to 'azureuser'.
- :type ex_admin_user_id: ``str``
+ :keyword ex_admin_user_id: Optional. Defaults to 'azureuser'.
+ :type ex_admin_user_id: ``str``
"""
-
+ # TODO: Refactor this method to make it more readable, split it into
+ # multiple smaller methods
auth = self._get_and_check_auth(auth)
password = auth.password
@@ -462,6 +464,8 @@ class AzureNodeDriver(NodeDriver):
"produced by list_images()"
)
+ # Retrieve a list of currently available nodes for the provided cloud
+ # service
node_list = self.list_nodes(
ex_cloud_service_name=ex_cloud_service_name
)
@@ -471,11 +475,7 @@ class AzureNodeDriver(NodeDriver):
# We do this because we need to pass a Configuration to the
# method. This will be either Linux or Windows.
- windows_server_regex = re.compile(
- r'Win|SQL|SharePoint|Visual|Dynamics|DynGP|BizTalk'
- )
-
- if windows_server_regex.search(image.id, re.I):
+ if WINDOWS_SERVER_REGEX.search(image.id, re.I):
machine_config = WindowsConfigurationSet(
computer_name=name,
admin_password=password,
@@ -643,26 +643,21 @@ class AzureNodeDriver(NodeDriver):
media_link = "%s/vhds/%s" % (blob_url, disk_name)
disk_config = OSVirtualHardDisk(image.id, media_link)
- response = self._perform_post(
- self._get_role_path(
- ex_cloud_service_name,
- _deployment_name
- ),
- AzureXmlSerializer.add_role_to_xml(
- name, # role_name
- machine_config, # system_config
- disk_config, # os_virtual_hard_disk
- 'PersistentVMRole', # role_type
- network_config, # network_config
- None, # availability_set_name
- None, # data_virtual_hard_disks
- vm_image_id, # vm_image
- size.id # role_size
- )
+ path = self._get_role_path(ex_cloud_service_name, _deployment_name)
+ body = AzureXmlSerializer.add_role_to_xml(
+ name, # role_name
+ machine_config, # system_config
+ disk_config, # os_virtual_hard_disk
+ 'PersistentVMRole', # role_type
+ network_config, # network_config
+ None, # availability_set_name
+ None, # data_virtual_hard_disks
+ vm_image_id, # vm_image
+ size.id # role_size
)
+ response = self._perform_post(path, body)
self.raise_for_response(response, 202)
-
self._ex_complete_async_azure_operation(response)
return Node(
@@ -679,7 +674,8 @@ class AzureNodeDriver(NodeDriver):
def destroy_node(self, node, ex_cloud_service_name=None,
ex_deployment_slot="Production"):
- """Remove Azure Virtual Machine
+ """
+ Remove Azure Virtual Machine
This removes the instance, but does not
remove the disk. You will need to use destroy_volume.
@@ -783,7 +779,7 @@ class AzureNodeDriver(NodeDriver):
:rtype: ``bool``
"""
- # add check to ensure all nodes have been deleted
+ # TODO: add check to ensure all nodes have been deleted
response = self._perform_cloud_service_delete(
self._get_hosted_service_path(name)
)
@@ -906,7 +902,7 @@ class AzureNodeDriver(NodeDriver):
def _perform_cloud_service_create(self, path, data):
request = AzureHTTPRequest()
request.method = 'POST'
- request.host = azure_service_management_host
+ request.host = AZURE_SERVICE_MANAGEMENT_HOST
request.path = path
request.body = data
request.path, request.query = self._update_request_uri_query(request)
@@ -918,7 +914,7 @@ class AzureNodeDriver(NodeDriver):
def _perform_cloud_service_delete(self, path):
request = AzureHTTPRequest()
request.method = 'DELETE'
- request.host = azure_service_management_host
+ request.host = AZURE_SERVICE_MANAGEMENT_HOST
request.path = path
request.path, request.query = self._update_request_uri_query(request)
request.headers = self._update_management_header(request)
@@ -1200,7 +1196,7 @@ class AzureNodeDriver(NodeDriver):
def _perform_get(self, path, response_type):
request = AzureHTTPRequest()
request.method = 'GET'
- request.host = azure_service_management_host
+ request.host = AZURE_SERVICE_MANAGEMENT_HOST
request.path = path
request.path, request.query = self._update_request_uri_query(request)
request.headers = self._update_management_header(request)
@@ -1214,7 +1210,7 @@ class AzureNodeDriver(NodeDriver):
def _perform_post(self, path, body, response_type=None, async=False):
request = AzureHTTPRequest()
request.method = 'POST'
- request.host = azure_service_management_host
+ request.host = AZURE_SERVICE_MANAGEMENT_HOST
request.path = path
request.body = ensure_string(self._get_request_body(body))
request.path, request.query = self._update_request_uri_query(request)
@@ -1226,7 +1222,7 @@ class AzureNodeDriver(NodeDriver):
def _perform_put(self, path, body, response_type=None, async=False):
request = AzureHTTPRequest()
request.method = 'PUT'
- request.host = azure_service_management_host
+ request.host = AZURE_SERVICE_MANAGEMENT_HOST
request.path = path
request.body = ensure_string(self._get_request_body(body))
request.path, request.query = self._update_request_uri_query(request)
@@ -1238,7 +1234,7 @@ class AzureNodeDriver(NodeDriver):
def _perform_delete(self, path, async=False):
request = AzureHTTPRequest()
request.method = 'DELETE'
- request.host = azure_service_management_host
+ request.host = AZURE_SERVICE_MANAGEMENT_HOST
request.path = path
request.path, request.query = self._update_request_uri_query(request)
request.headers = self._update_management_header(request)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/abf026f8/libcloud/test/compute/test_azure.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_azure.py b/libcloud/test/compute/test_azure.py
index 4ffd07d..ca293b9 100644
--- a/libcloud/test/compute/test_azure.py
+++ b/libcloud/test/compute/test_azure.py
@@ -13,14 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.import libcloud
-from libcloud.common.types import LibcloudError
-from libcloud.compute.base import NodeAuthPassword, NodeImage, NodeSize
-from libcloud.compute.drivers.azure import azure_service_management_host
-
import os
import sys
import libcloud.security
+from libcloud.common.types import LibcloudError
+from libcloud.compute.base import NodeAuthPassword, NodeImage, NodeSize
+from libcloud.compute.drivers.azure import AZURE_SERVICE_MANAGEMENT_HOST
from libcloud.test import unittest
from libcloud.test import LibcloudTestCase
@@ -585,12 +584,12 @@ class AzureMockHttp(MockHttp):
if not getattr(AzureMockHttp, "in_redirect", False):
setattr(AzureMockHttp, "in_redirect", True)
- headers["Location"] = url.replace(azure_service_management_host, redirect_host)
+ headers["Location"] = url.replace(AZURE_SERVICE_MANAGEMENT_HOST, redirect_host)
return (httplib.TEMPORARY_REDIRECT, None, headers, httplib.responses[httplib.TEMPORARY_REDIRECT])
else:
delattr(AzureMockHttp, "in_redirect")
if redirect_host not in url:
- if azure_service_management_host in url:
+ if AZURE_SERVICE_MANAGEMENT_HOST in url:
return (httplib.TEMPORARY_REDIRECT, None, headers, httplib.responses[httplib.TEMPORARY_REDIRECT])
else:
return (httplib.REQUEST_TIMEOUT, None, None, httplib.responses[httplib.REQUEST_TIMEOUT])