Merge lp:~gz/juju-core/maas_missing_ip_addresses_1236734 into lp:~go-bot/juju-core/trunk
Proposed by
Martin Packman
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Martin Packman | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1959 | ||||
Proposed branch: | lp:~gz/juju-core/maas_missing_ip_addresses_1236734 | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
116 lines (+56/-24) 2 files modified
provider/maas/instance.go (+6/-1) provider/maas/instance_test.go (+50/-23) |
||||
To merge this branch: | bzr merge lp:~gz/juju-core/maas_missing_ip_addresses_1236734 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+189847@code.launchpad.net |
Commit message
provider/maas: Handle ip_addresses not existing
Older MAAS versions do not return the ip_addresses field in
their instance json. Update the provider to not treat this
as an error, but instead equivalent to having no further
addresses beyond the seperately exposed DNS name.
https:/
R=fwereade, rogpeppe
Description of the change
provider/maas: Handle ip_addresses not existing
Older MAAS versions do not return the ip_addresses field in
their instance json. Update the provider to not treat this
as an error, but instead equivalent to having no further
addresses beyond the seperately exposed DNS name.
To post a comment you must log in.
Reviewers: mp+189847_ code.launchpad. net,
Message:
Please take a look.
Description:
provider/maas: Handle ip_addresses not existing
Older MAAS versions do not return the ip_addresses field in
their instance json. Update the provider to not treat this
as an error, but instead equivalent to having no further
addresses beyond the seperately exposed DNS name.
https:/ /code.launchpad .net/~gz/ juju-core/ maas_missing_ ip_addresses_ 1236734/ +merge/ 189847
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/14543043/
Affected files (+59, -10 lines): maas/instance. go maas/instance_ test.go
A [revision details]
M provider/
M provider/
Index: [revision details] 20131008120312- vr5sryx6voukx4o 8
=== 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: tarmac-
+New revision: <email address hidden>
Index: provider/ maas/instance. go maas/instance. go' maas/instance. go 2013-09-30 19:40:06 +0000 maas/instance. go 2013-10-08 13:29:41 +0000
=== modified file 'provider/
--- provider/
+++ provider/
@@ -76,7 +76,12 @@
func (mi *maasInstance) ipAddresses() ([]string, error) { GetMap( )["ip_addresses "].GetArray( ) GetMap( )["ip_addresses "] IsNil() { GetArray( )
// we have to do this the hard way, since maasObject doesn't have this
built-in yet
- objs, err := mi.maasObject.
+ addressArray := mi.maasObject.
+ if addressArray.
+ // Older MAAS versions do not return ip_addresses.
+ return nil, nil
+ }
+ objs, err := addressArray.
if err != nil {
return nil, err
}
Index: provider/ maas/instance_ test.go maas/instance_ test.go' maas/instance_ test.go 2013-09-09 07:02:57 +0000 maas/instance_ test.go 2013-10-08 13:29:41 +0000 net/gocheck"
=== modified file 'provider/
--- provider/
+++ provider/
@@ -9,7 +9,6 @@
gc "launchpad.
"launchpad. net/juju- core/instance" net/juju- core/testing/ checkers"
- jc "launchpad.
)
type instanceTest struct {
@@ -88,6 +87,12 @@
expected := []instance.Address{ NetworkPublic, Ipv4Address, NetworkUnknown, NetworkPublic,
{
+ "DNS name",
+ instance.HostName,
+ "",
+ instance.
+ },
+ {
"1.2.3.4",
instance.
"",
@@ -99,16 +104,53 @@
"",
instance.
},
- {
- "DNS name",
- instance.HostName,
- "",
- instance.
- },
}
addr, err := inst.Addresses()
- c.Check(err, gc.IsNil) ssing(c *gc.C) { t.TestServer. NewNode( jsonValue) NetworkPublic} , valid(c *gc.C) {
- c.Check(addr, jc.SameContents, expected)
+ c.Assert(err, gc.IsNil)
+ c.Check(addr, gc.DeepEquals, expected)
+}
+
+func (s *instanceTest) TestAddressesMi
+ // Older MAAS versions do not have ip_addresses returned, for these
+ // just the DNS name should be returned without error.
+ jsonValue := `{
+ "hostname": "testing.invalid",
+ "system_id": "system_id"
+ }`
+ obj := s.testMAASObjec
+ inst := maasInstance{&obj, s.environ}
+
+ addr, err := inst.Addresses()
+ c.Assert(err, gc.IsNil)
+ c.Check(addr, gc.DeepEquals, []instance.Address{
+ {"testing.invalid", instance.HostName, "", instance.
+ })
+}
+
+func (s *instanceTest) TestAddressesIn
+ jsonV...