~ubuntu-branches/ubuntu/saucy/juju-core/saucy

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/environs/openstack/export_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 16:02:16 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130820160216-5yu1llasa2e2youn
Tags: 1.13.1-0ubuntu1
* New upstream release.
  - Build and install juju metadata plugin.
  - d/NEWS: Add some guidance on upgrading environments from 1.11.x
    to 1.13.x.
* d/NEWS: Add details about lack of upgrade path from juju < 1.11
  and how to interact with older juju environments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import (
7
7
        "bytes"
8
8
        "fmt"
 
9
        "strings"
 
10
        "text/template"
 
11
 
9
12
        "launchpad.net/goose/identity"
10
13
        "launchpad.net/goose/nova"
11
14
        "launchpad.net/goose/swift"
 
15
 
 
16
        "launchpad.net/juju-core/agent/tools"
12
17
        "launchpad.net/juju-core/constraints"
13
18
        "launchpad.net/juju-core/environs"
14
19
        "launchpad.net/juju-core/environs/imagemetadata"
15
20
        "launchpad.net/juju-core/environs/instances"
16
21
        "launchpad.net/juju-core/environs/jujutest"
17
 
        "launchpad.net/juju-core/environs/tools"
18
 
        "net/http"
19
 
        "strings"
20
 
        "text/template"
 
22
        "launchpad.net/juju-core/instance"
21
23
)
22
24
 
23
25
// This provides the content for code accessing test:///... URLs. This allows
26
28
var testRoundTripper = &jujutest.ProxyRoundTripper{}
27
29
 
28
30
func init() {
29
 
        http.DefaultTransport.(*http.Transport).RegisterProtocol("test", testRoundTripper)
 
31
        testRoundTripper.RegisterForScheme("test")
30
32
}
31
33
 
32
34
var origMetadataHost = metadataHost
38
40
// A group of canned responses for the "metadata server". These match
39
41
// reasonably well with the results of making those requests on a Folsom+
40
42
// Openstack service
41
 
var MetadataTesting = []jujutest.FileContent{
42
 
        {"/latest/meta-data/local-ipv4", "10.1.1.2"},
43
 
        {"/latest/meta-data/public-ipv4", "203.1.1.2"},
44
 
        {"/openstack/2012-08-10/meta_data.json", metadataContent},
 
43
var MetadataTesting = map[string]string{
 
44
        "/latest/meta-data/local-ipv4":         "10.1.1.2",
 
45
        "/latest/meta-data/public-ipv4":        "203.1.1.2",
 
46
        "/openstack/2012-08-10/meta_data.json": metadataContent,
45
47
}
46
48
 
47
49
// Set Metadata requests to be served by the filecontent supplied.
48
 
func UseTestMetadata(metadata []jujutest.FileContent) {
 
50
func UseTestMetadata(metadata map[string]string) {
49
51
        if len(metadata) != 0 {
50
 
                testRoundTripper.Sub = jujutest.NewVirtualRoundTripper(metadata, nil)
 
52
                testRoundTripper.Sub = jujutest.NewCannedRoundTripper(metadata, nil)
51
53
                metadataHost = "test:"
52
54
        } else {
53
55
                testRoundTripper.Sub = nil
55
57
        }
56
58
}
57
59
 
58
 
var ShortAttempt = &shortAttempt
 
60
var (
 
61
        ShortAttempt   = &shortAttempt
 
62
        StorageAttempt = &storageAttempt
 
63
)
59
64
 
60
65
func SetFakeToolsStorage(useFake bool) {
61
66
        if useFake {
82
87
        }
83
88
        return writablePublicStorage
84
89
}
85
 
func InstanceAddress(addresses map[string][]nova.IPAddress) (string, error) {
86
 
        return instanceAddress(addresses)
 
90
 
 
91
func InstanceAddress(addresses map[string][]nova.IPAddress) string {
 
92
        return instance.SelectPublicAddress(convertNovaAddresses(addresses))
87
93
}
88
94
 
89
95
var publicBucketIndexData = `