Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 23C90200CF1 for ; Fri, 11 Aug 2017 07:00:47 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 227F016C93E; Fri, 11 Aug 2017 05:00:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E39D716C8CB for ; Fri, 11 Aug 2017 07:00:45 +0200 (CEST) Received: (qmail 88993 invoked by uid 500); 11 Aug 2017 05:00:45 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 88697 invoked by uid 500); 11 Aug 2017 05:00:44 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 88693 invoked by uid 99); 11 Aug 2017 05:00:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Aug 2017 05:00:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0F76FF5558; Fri, 11 Aug 2017 05:00:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anthonyshaw@apache.org To: commits@libcloud.apache.org Date: Fri, 11 Aug 2017 05:00:57 -0000 Message-Id: <69b00b68f949424aa07c6acd01f87030@git.apache.org> In-Reply-To: <69c958d0364848f298884472180d38e1@git.apache.org> References: <69c958d0364848f298884472180d38e1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [15/20] libcloud git commit: FAM-690 WIP archived-at: Fri, 11 Aug 2017 05:00:47 -0000 FAM-690 WIP Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/774b0971 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/774b0971 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/774b0971 Branch: refs/heads/trunk Commit: 774b097106ff022e48688dd554ca2d402cfd1367 Parents: c2343ad Author: mermoldy Authored: Mon Mar 6 20:18:07 2017 +0200 Committer: Anthony Shaw Committed: Fri Aug 11 14:59:31 2017 +1000 ---------------------------------------------------------------------- libcloud/compute/drivers/azure_arm.py | 32 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/774b0971/libcloud/compute/drivers/azure_arm.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/azure_arm.py b/libcloud/compute/drivers/azure_arm.py index d2f3c37..6a43d09 100644 --- a/libcloud/compute/drivers/azure_arm.py +++ b/libcloud/compute/drivers/azure_arm.py @@ -788,10 +788,10 @@ class AzureNodeDriver(NodeDriver): :rtype: :class:`StorageVolume` """ if location is None: - raise ValueError("Must provide `location` value") + raise ValueError("Must provide `location` value.") if ex_resource_group is None: - raise ValueError("Must provide `ex_resource_group` value") + raise ValueError("Must provide `ex_resource_group` value.") action = ( u'/subscriptions/{subscription_id}/resourceGroups/{resource_group}' @@ -926,17 +926,28 @@ class AzureNodeDriver(NodeDriver): Detach a managed volume from a node. """ if ex_node is None: - raise ValueError("Must provide `ex_node` value") + raise ValueError("Must provide `ex_node` value.") action = ex_node.extra['id'] location = ex_node.extra['location'] disks = ex_node.extra['properties']['storageProfile']['dataDisks'] # remove volume from `properties.storageProfile.dataDisks` + disk_index = None for index, disk in enumerate(disks): if 'managedDisk' in disk: if volume.id == disk['managedDisk'].get('id'): - del disks[index] + disk_index = index + elif 'name' in disk: + if volume.name == disk['name']: + disk_index = index + if disk_index is None: + raise LibcloudError(( + "A disk with id {} does not found among managed disks " + "attached to an instance ({})." + ).format(volume.id, ex_node.id)) + else: + del disks[disk_index] self.connection.request( action, @@ -1656,14 +1667,16 @@ class AzureNodeDriver(NodeDriver): resource = resource.id r = self.connection.request( resource, - params={"api-version": "2015-06-15"}) + params={"api-version": RESOURCE_API_VERSION}) if replace: r.object["tags"] = tags else: r.object["tags"].update(tags) - r = self.connection.request(resource, data={"tags": r.object["tags"]}, - params={"api-version": "2015-06-15"}, - method="PATCH") + self.connection.request( + resource, + data={"tags": r.object["tags"]}, + params={"api-version": RESOURCE_API_VERSION}, + method="PATCH") def ex_start_node(self, node): """ @@ -1870,6 +1883,9 @@ class AzureNodeDriver(NodeDriver): elif status["code"].startswith("ProvisioningState/failed"): state = NodeState.ERROR break + elif status["code"] == "ProvisioningState/updating": + state = NodeState.RECONFIGURING + break elif status["code"] == "ProvisioningState/succeeded": pass