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 <s.ba...@scalr.com> Authored: Mon Mar 6 20:18:07 2017 +0200 Committer: Anthony Shaw <anthonys...@apache.org> 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