[GitHub] libcloud pull request #1128: Fix api version used to list and delete NICs.

2017-10-11 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/libcloud/pull/1128


---


libcloud git commit: azure_arm: Fix api version used to list and delete NICs

2017-10-11 Thread quentinp
Repository: libcloud
Updated Branches:
  refs/heads/trunk a1c0e60fc -> 3ffac42c2


azure_arm: Fix api version used to list and delete NICs

Adds ex_destroy_nic.

Also adjust codes to reflect that Azure returns 204 when attempting to
destroy a resource that doesn't exist.

Closes #1128

Signed-off-by: Quentin Pradet 


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3ffac42c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3ffac42c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3ffac42c

Branch: refs/heads/trunk
Commit: 3ffac42c2a950cb3ea0ad48f0cf67c2f194f5d41
Parents: a1c0e60
Author: Peter Amstutz 
Authored: Wed Oct 11 10:24:43 2017 -0400
Committer: Quentin Pradet 
Committed: Thu Oct 12 08:29:45 2017 +0400

--
 CHANGES.rst |  3 ++
 libcloud/compute/drivers/azure_arm.py   | 54 +++-
 libcloud/test/compute/test_azure_arm.py | 12 +++
 3 files changed, 47 insertions(+), 22 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ffac42c/CHANGES.rst
--
diff --git a/CHANGES.rst b/CHANGES.rst
index 9e37c80..e45a279 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -55,6 +55,9 @@ Compute
   (GITHUB-1120)
   [Lucas Di Pentima]
 
+- [ARM] Fix api version used to list and delete NICs (GITHUB-1128)
+  [Peter Amstutz]
+
 
 Changes in Apache Libcloud 2.2.1
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/3ffac42c/libcloud/compute/drivers/azure_arm.py
--
diff --git a/libcloud/compute/drivers/azure_arm.py 
b/libcloud/compute/drivers/azure_arm.py
index 3e5a3f1..78b97b4 100644
--- a/libcloud/compute/drivers/azure_arm.py
+++ b/libcloud/compute/drivers/azure_arm.py
@@ -700,7 +700,7 @@ class AzureNodeDriver(NodeDriver):
 :rtype: ``bool``
 """
 
-do_node_polling = True
+do_node_polling = (ex_destroy_nic or ex_destroy_vhd)
 
 # This returns a 202 (Accepted) which means that the delete happens
 # asynchronously.
@@ -714,13 +714,14 @@ class AzureNodeDriver(NodeDriver):
 except BaseHTTPError as h:
 if h.code == 202:
 pass
-elif h.code == 404:
-# No need to ask again, node already down.
+elif h.code == 204:
+# Returns 204 if node already deleted.
 do_node_polling = False
 else:
 raise
 
-# Need to poll until the node actually goes away.
+# Poll until the node actually goes away (otherwise attempt to delete
+# NIC and VHD will fail with "resource in use" errors).
 while do_node_polling:
 try:
 time.sleep(10)
@@ -728,7 +729,8 @@ class AzureNodeDriver(NodeDriver):
 node.id,
 params={"api-version": RESOURCE_API_VERSION})
 except BaseHTTPError as h:
-if h.code == 404:
+if h.code in (204, 404):
+# Node is gone
 break
 else:
 raise
@@ -741,16 +743,11 @@ class AzureNodeDriver(NodeDriver):
 for nic in interfaces:
 while True:
 try:
-self.connection.request(
-nic["id"],
-params={"api-version": RESOURCE_API_VERSION},
-method='DELETE')
+self.ex_destroy_nic(self._to_nic(nic))
 break
 except BaseHTTPError as h:
-if h.code == 202 or h.code == 404:
-break
-inuse = h.message.startswith("[NicInUse]")
-if h.code == 400 and inuse:
+if (h.code == 400 and
+h.message.startswith("[NicInUse]")):
 time.sleep(10)
 else:
 raise
@@ -1521,7 +1518,7 @@ class AzureNodeDriver(NodeDriver):
  (self.subscription_id, resource_group)
 r = self.connection.request(
 action,
-params={"api-version": RESOURCE_API_VERSION})
+params={"api-version": "2015-06-15"})
 return [self._to_nic(net) for net in r.object["value"]]
 
 def ex_get_nic(self, id):
@@ -1538,6 +1535,31 @@ class AzureNodeDriver(NodeDriver):
 r = self.connection.request(id, params={"api-version": "2015-06-15"})
 return self._to_nic(r.object)
 
+def ex_destroy_nic(self, nic):
+"""
+Destroy a

[GitHub] libcloud pull request #1128: Fix api version used to list and delete NICs.

2017-10-11 Thread tetron
GitHub user tetron opened a pull request:

https://github.com/apache/libcloud/pull/1128

Fix api version used to list and delete NICs.

## Fix api version used to list and delete NICs.

### Description

Adds ex_destroy_nic.

Also adjust codes to reflect that Azure returns 204 when attempting to 
destroy
a resource that doesn't exist.

### Status

done, ready for review

### Checklist (tick everything that applies)

- [ ] [Code 
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
 (required, can be done after the PR checks)
- [ ] Documentation
- [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [ ] 
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
 (required for bigger changes)


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/curoverse/libcloud fix_nic_delete

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/libcloud/pull/1128.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1128


commit 61cdd12652477094468eddd44bf8cfe7b30f82ac
Author: Peter Amstutz 
Date:   2017-10-11T14:24:43Z

Add ex_destroy_nic.  Fix api version used to list and delete NICs.

Also adjust codes to reflect that Azure returns 204 when attempting to 
destroy
a resource that doesn't exist.




---


libcloud git commit: Fix lint

2017-10-11 Thread quentinp
Repository: libcloud
Updated Branches:
  refs/heads/trunk 7d442a1ab -> a1c0e60fc


Fix lint


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a1c0e60f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a1c0e60f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a1c0e60f

Branch: refs/heads/trunk
Commit: a1c0e60fc628983acf923d5d3ab9e7a5d3afeb3d
Parents: 7d442a1
Author: Quentin Pradet 
Authored: Wed Oct 11 13:26:50 2017 +0400
Committer: Quentin Pradet 
Committed: Wed Oct 11 13:26:50 2017 +0400

--
 libcloud/test/compute/test_azure_arm.py | 1 -
 1 file changed, 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a1c0e60f/libcloud/test/compute/test_azure_arm.py
--
diff --git a/libcloud/test/compute/test_azure_arm.py 
b/libcloud/test/compute/test_azure_arm.py
index b4d4e8c..9e462d3 100644
--- a/libcloud/test/compute/test_azure_arm.py
+++ b/libcloud/test/compute/test_azure_arm.py
@@ -21,7 +21,6 @@ from datetime import datetime
 import mock
 
 from libcloud.common.exceptions import BaseHTTPError
-from libcloud.common.types import LibcloudError
 from libcloud.compute.base import (NodeLocation, NodeSize, VolumeSnapshot,
StorageVolume)
 from libcloud.compute.drivers.azure_arm import AzureImage, NodeAuthPassword



[GitHub] libcloud pull request #1127: [LIBCLOUD-954] ec2: Allow cn-north-1 even witho...

2017-10-11 Thread pquentin
GitHub user pquentin opened a pull request:

https://github.com/apache/libcloud/pull/1127

[LIBCLOUD-954] ec2: Allow cn-north-1 even without pricing

## ec2: Allow cn-north-1 even without pricing

### Description

See https://issues.apache.org/jira/browse/LIBCLOUD-954 and 
https://github.com/apache/libcloud/commit/1e1d77f320a2314e96c79011ab62ee028a835503

@fjros and @duanshiqiang, what do you think?

### Status

- done, ready for review

### Checklist (tick everything that applies)

- [x] [Code 
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
 (required, can be done after the PR checks)
- [ ] Documentation
- [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [x] 
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
 (required for bigger changes)


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/pquentin/libcloud allow-ec-cn-north-1

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/libcloud/pull/1127.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1127


commit bd28b40cb960cd6cfc10595d018115265e1ee5a9
Author: Quentin Pradet 
Date:   2017-10-11T07:07:45Z

[LIBCLOUD-954] ec2: Allow cn-north-1 even without pricing




---


[jira] [Commented] (LIBCLOUD-954) EC2 driver don't support cn-north-1

2017-10-11 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/LIBCLOUD-954?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16199898#comment-16199898
 ] 

ASF GitHub Bot commented on LIBCLOUD-954:
-

GitHub user pquentin opened a pull request:

https://github.com/apache/libcloud/pull/1127

[LIBCLOUD-954] ec2: Allow cn-north-1 even without pricing

## ec2: Allow cn-north-1 even without pricing

### Description

See https://issues.apache.org/jira/browse/LIBCLOUD-954 and 
https://github.com/apache/libcloud/commit/1e1d77f320a2314e96c79011ab62ee028a835503

@fjros and @duanshiqiang, what do you think?

### Status

- done, ready for review

### Checklist (tick everything that applies)

- [x] [Code 
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
 (required, can be done after the PR checks)
- [ ] Documentation
- [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [x] 
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
 (required for bigger changes)


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/pquentin/libcloud allow-ec-cn-north-1

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/libcloud/pull/1127.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1127


commit bd28b40cb960cd6cfc10595d018115265e1ee5a9
Author: Quentin Pradet 
Date:   2017-10-11T07:07:45Z

[LIBCLOUD-954] ec2: Allow cn-north-1 even without pricing




> EC2 driver don't support cn-north-1
> ---
>
> Key: LIBCLOUD-954
> URL: https://issues.apache.org/jira/browse/LIBCLOUD-954
> Project: Libcloud
>  Issue Type: Bug
>Reporter: Duan Shiqiang
>
> From 2.1.0, the support of AWS EC2 for region cn-north-1. See this commit: 
> [Remove cn-north-1 from VALID_EC2_REGIONS list in EC2 compute 
> driver|https://github.com/apache/libcloud/commit/1e1d77f320a2314e96c79011ab62ee028a835503].
> I don't know why this is happening, please add the support back as we 
> actually have work load on AWS china region and has been using apache 
> libcloud for a while. Thx



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)