Merge lp://staging/~wallyworld/goose/hpopenstack into lp://staging/goose

Proposed by Ian Booth
Status: Merged
Approved by: Ian Booth
Approved revision: 73
Merged at revision: 68
Proposed branch: lp://staging/~wallyworld/goose/hpopenstack
Merge into: lp://staging/goose
Diff against target: 841 lines (+411/-57)
15 files modified
identity/live_test.go (+5/-3)
identity/local_test.go (+15/-1)
identity/userpass.go (+14/-4)
identity/userpass_test.go (+33/-0)
nova/export_test.go (+5/-0)
nova/json.go (+160/-0)
nova/live_test.go (+49/-22)
nova/local_test.go (+19/-2)
nova/nova.go (+42/-16)
nova/nova_test.go (+41/-2)
testservices/identityservice/userpass.go (+2/-2)
testservices/identityservice/userpass_test.go (+1/-1)
testservices/novaservice/service.go (+2/-0)
testservices/novaservice/service_http.go (+18/-3)
testservices/openstackservice/openstack.go (+5/-1)
To merge this branch: bzr merge lp://staging/~wallyworld/goose/hpopenstack
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+147069@code.staging.launchpad.net

Commit message

Add HP Cloud support

A few major changes here. HP Cloud sends many core data structures over the wire with int IDs rather than string.
It also lacks a security groups API but instead adds the groups to the server detail record.

To make everything work in the least invasive way, I added custom json (un)marshallers to the affected data structures. The affected
data structures are Entity, ServerDetail, FloatingIP, FlavorDetail. The approach allows the built in marshalling to be used for everything except
the IDs, which are converted from int or string as required.

The live tests are enhanced to allow them to be run against HP Cloud or Canonistack as required:
go test -gocheck.v -live -vendor canonistack
or
go test -gocheck.v -live -vendor hpcloud

The local tests are configured to run twice - once with nemric ids and one with string ids.

Description of the change

Add HP Cloud support

A few major changes here. HP Cloud sends many core data structures over the wire with int IDs rather than string.
It also lacks a security groups API but instead adds the groups to the server detail record.

To make everything work in the least invasive way, I added custom json (un)marshallers to the affected data structures. The affected
data structures are Entity, ServerDetail, FloatingIP, FlavorDetail. The approach allows the built in marshalling to be used for everything except
the IDs, which are converted from int or string as required.

The live tests are enhanced to allow them to be run against HP Cloud or Canonistack as required:
go test -gocheck.v -live -vendor canonistack
or
go test -gocheck.v -live -vendor hpcloud

The local tests are configured to run twice - once with nemric ids and one with string ids.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

Quick note, it might be easier to review and land if we split out the "regionMatches" component from the rest of it.
However, I'll try to review it all together for now.

Revision history for this message
John A Meinel (jameinel) wrote :
Download full text (3.6 KiB)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-02-07 15:04, Ian Booth wrote:
> Ian Booth has proposed merging lp:~wallyworld/goose/hpopenstack
> into lp:goose.
>
> Requested reviews: The Go Language Gophers (gophers)
>
> For more details, see:
> https://code.launchpad.net/~wallyworld/goose/hpopenstack/+merge/147069
>
> Add HP Cloud support
>
> A few major changes here. HP Cloud sends many core data structures
> over the wire with int IDs rather than string. It also lacks a
> security groups API but instead adds the groups to the server
> detail record.
>
> To make everything work in the least invasive way, I added custom
> json (un)marshallers to the affected data structures. The affected
> data structures are Entity, ServerDetail, FloatingIP, FlavorDetail.
> The approach allows the built in marshalling to be used for
> everything except the IDs, which are converted from int or string
> as required.
>
> The live tests are enhanced to allow them to be run against HP
> Cloud or Canonistack as required: go test -gocheck.v -live -vendor
> canonistack or go test -gocheck.v -live -vendor hpcloud
>
> The local tests are configured to run twice - once with nemric ids
> and one with string ids.
>

1) Shouldn't there be direct tests (unit tests) of regionMatches?

2) useNumericIds seems like it should be in testservices/novaservice
rather than in nova/

I realize it is used in "convertId", but I would have thought we would
standardize that at the abstraction layer above goose, Id is always a
string (since it is sometimes a string). So while it might be an int
or a string on the wire, in memory we would just store it as a string.

Is it something where we have to pass it back to HP/Canonistack as the
same type? If so, then it sounds like something that would need to be
passed around, rather than a global state switch. (When we read it, if
we got an int, pass it back as an int.)

3) Could you have done this more simply with:

type Entity struct {
  Id string `json:"-"`
  GenericId interface{} `json:"id"`
  UUID string `json:"uuid"`
  Links []Link `json:"links"`
  Name string `json:"name"`
}

And then instead of having an UnmarshalJSON function, you can
unmarshal as normal, and just map it into the in-memory struct.

Combining it with (2) you might have:
type Entity struct {
  Id string `json:"-"`
  GenericId interface{} `json:"id"`
  IdWasInt bool `json:"-"`
  UUID string `json:"uuid"`
  Links []Link `json:"links"`
  Name string `json:"name"`
}

Or maybe another option is a new type for Id?

type GenericId interface{}

func (g *GenericId) String() {
}

func (g *GenericId) AsInt() {
}

And then we store it in memory as whatever we were given by JSON, but
we use String() to think about it.

I'm certainly not blocking on this, and it may be something you tried
but it was easier to do with custom UnmarshalJSON functions. You just
had to add an awful lot of them, and I was hoping we could avoid that.

677 +type JsonFloatingIP struct {
678 + FloatingIP `json:"-"`
679 +}
680 +

I'd like us to standardize on using JSON instead of Json (same with
HTTP and URL) in variable and class names. We've done that in some
places (though not all). It cert...

Read more...

review: Approve
71. By Ian Booth

Move JSON marshalling code to it's own module

72. By Ian Booth

Refactor json marshalling using type aliases

73. By Ian Booth

Add region matching tests

Revision history for this message
Ian Booth (wallyworld) wrote :

I've reworked the JSON serialisation implementation to significantly simplify it. By using type aliases, I can work directly on the API data types and totally eliminate the need to change any nova or test service code. The serialisation is moved to a separate module and so effectively can be thought of as orthogonal to the behaviour of the core business logic.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches