~gz/goose/novaservice_preserve_negative_ports

« back to all changes in this revision

Viewing changes to testservices/openstackservice/openstack.go

  • Committer: Tarmac
  • Author(s): Ian Booth
  • Date: 2013-02-08 02:38:12 UTC
  • mfrom: (66.1.7 hpopenstack)
  • Revision ID: tarmac-20130208023812-llhkeo6vitwmf3co
[r=wallyworld] 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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
        "launchpad.net/goose/testservices/novaservice"
7
7
        "launchpad.net/goose/testservices/swiftservice"
8
8
        "net/http"
 
9
        "strings"
9
10
)
10
11
 
11
12
// Openstack provides an Openstack service double implementation.
26
27
                panic("Openstack service double requires a tenant to be specified.")
27
28
        }
28
29
        openstack.Nova = novaservice.New(cred.URL, "v2", userInfo.TenantId, cred.Region, openstack.Identity)
29
 
        openstack.Swift = swiftservice.New(cred.URL, "v1", userInfo.TenantId, cred.Region, openstack.Identity)
 
30
        // Create the swift service using only the region base so we emulate real world deployments.
 
31
        regionParts := strings.Split(cred.Region, ".")
 
32
        baseRegion := regionParts[len(regionParts)-1]
 
33
        openstack.Swift = swiftservice.New(cred.URL, "v1", userInfo.TenantId, baseRegion, openstack.Identity)
30
34
        return &openstack
31
35
}
32
36