Merge lp:~gz/pyjuju/os_metadata_not_found_1061678 into lp:pyjuju
Proposed by
Martin Packman
Status: | Merged |
---|---|
Approved by: | Clint Byrum |
Approved revision: | 591 |
Merged at revision: | 590 |
Proposed branch: | lp:~gz/pyjuju/os_metadata_not_found_1061678 |
Merge into: | lp:pyjuju |
Diff against target: |
26 lines (+3/-2) 2 files modified
juju/unit/address.py (+2/-1) juju/unit/tests/test_address.py (+1/-1) |
To merge this branch: | bzr merge lp:~gz/pyjuju/os_metadata_not_found_1061678 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Clint Byrum (community) | Approve | ||
Review via email: mp+128056@code.launchpad.net |
Description of the change
Adapt openstack metadata service ipv4 for folsom
In essex, if an instance did not have a public ipv4 address the
metadata service would return an empty body with 200 http status
code. In folsom, it now returns a 404 instead. This branch catches
that and treats it in the same way as before - falling back to
checking local-ipv4 instead.
To post a comment you must log in.
Reviewers: mp+128056_ code.launchpad. net,
Message:
Please take a look.
Description:
Adapt openstack metadata service ipv4 for folsom
In essex, if an instance did not have a public ipv4 address the
metadata service would return an empty body with 200 http status
code. In folsom, it now returns a 404 instead. This branch catches
that and treats it in the same way as before - falling back to
checking local-ipv4 instead.
https:/ /code.launchpad .net/~gz/ juju/os_ metadata_ not_found_ 1061678/ +merge/ 128056
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6584085/
Affected files: address. py tests/test_ address. py
A [revision details]
M juju/unit/
M juju/unit/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: juju/unit/ address. py address. py' address. py 2012-05-22 14:43:41 +0000 address. py 2012-10-04 16:06:52 +0000
=== modified file 'juju/unit/
--- juju/unit/
+++ juju/unit/
@@ -4,7 +4,11 @@
from twisted. internet. defer import inlineCallbacks, returnValue, succeed internet. threads import deferToThread
from twisted.
-from twisted.web import client
+from twisted.web import (
+ client,
+ error,
+ http,
+ )
from juju.errors import JujuError environment import GlobalSettingsS tateManager
from juju.state.
@@ -78,7 +82,12 @@
@ inlineCallbacks address( self): metadata_ string( "public- ipv4") metadata_ string( "public- ipv4")
address = yield self.get_ private_ address( )
returnValue( address)
def get_public_
- address = yield self._get_
+ try:
+ address = yield self._get_
+ except error.Error as e:
+ if e.status != http.NOT_FOUND:
+ raise
+ address = None
if not address:
Index: juju/unit/ tests/test_ address. py tests/test_ address. py' tests/test_ address. py 2012-05-22 14:43:41 +0000 tests/test_ address. py 2012-10-04 16:05:44 +0000
=== modified file 'juju/unit/
--- juju/unit/
+++ juju/unit/
@@ -1,8 +1,12 @@
import subprocess
import zookeeper
-from twisted. internet. defer import inlineCallbacks, succeed, returnValue internet. defer import fail, inlineCallbacks, succeed,
-from twisted.web import client
+from twisted.
returnValue
+from twisted.web import (
+ client,
+ error,
+ http,
+ )
from juju.errors import JujuError metadata( self, url):
self. assertEqual( "http:// 169.254. 169.254/ 1.0/meta- data", head) self.meta. pop(tail) )
from juju.lib.testing import TestCase
@@ -128,7 +132,10 @@
def _fetch_
head, tail = url.rsplit("/", 1)
- return succeed(
+ result = self.meta.pop(tail)
+ if isinstance(result, Exception):
+ return fail(result)
+ return succeed(result)
@ inlineCallbacks private_ address( self):
self. assertEqual( "192.168. 0.2",
(yield self.address. get_public_ address( )))
def test_get_
@@ -147,6 +154,13 @@
+ @i...