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

« back to all changes in this revision

Viewing changes to src/launchpad.net/gwacl/helpers_apiobjects_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-11 17:18:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130711171827-vjqkg40r0dlf7ys2
Tags: 1.11.2-0ubuntu1
* New upstream release.
* Make juju-core the default juju (LP: #1190634):
  - d/control: Add virtual package juju -> juju-core.
  - d/juju-core.postinst.in: Bump priority of alternatives over that of
    python juju packages.
* Enable for all architectures (LP: #1172505):
  - d/control: Version BD on golang-go to >= 2:1.1.1 to ensure CGO
    support for non-x86 archs, make juju-core Arch: any.
  - d/README.source: Dropped - no longer required.
* d/watch: Updated for new upstream tarball naming.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Canonical Ltd.  This software is licensed under the
 
2
// GNU Lesser General Public License version 3 (see the file COPYING).
 
3
//
 
4
// Test helpers to fake objects that go into, or come out of, the Azure API.
 
5
 
 
6
package gwacl
 
7
 
 
8
import (
 
9
    "math/rand"
 
10
)
 
11
 
 
12
type endpointParams struct {
 
13
    setname   string
 
14
    localport int
 
15
    name      string
 
16
    port      int
 
17
    protocol  string
 
18
}
 
19
 
 
20
func makeEndpoint(params endpointParams) *InputEndpoint {
 
21
    if params.setname == "" {
 
22
        params.setname = MakeRandomString(10)
 
23
    }
 
24
    if params.name == "" {
 
25
        params.name = MakeRandomString(10)
 
26
    }
 
27
    if params.protocol == "" {
 
28
        params.protocol = MakeRandomString(10)
 
29
    }
 
30
    if params.localport == 0 {
 
31
        params.localport = rand.Intn(65535)
 
32
    }
 
33
    if params.port == 0 {
 
34
        params.port = rand.Intn(65535)
 
35
    }
 
36
 
 
37
    return &InputEndpoint{
 
38
        LoadBalancedEndpointSetName: params.setname,
 
39
        LocalPort:                   params.localport,
 
40
        Name:                        params.name,
 
41
        Port:                        params.port,
 
42
        Protocol:                    params.protocol}
 
43
}
 
44
 
 
45
func makeLinuxProvisioningConfiguration() *ConfigurationSet {
 
46
    hostname := MakeRandomString(10)
 
47
    username := MakeRandomString(10)
 
48
    password := MakeRandomString(10)
 
49
    userdata := MakeRandomString(10)
 
50
    disableSSH := BoolToString(MakeRandomBool())
 
51
    return NewLinuxProvisioningConfigurationSet(hostname, username, password, userdata, disableSSH)
 
52
}
 
53
 
 
54
func makeOSVirtualHardDisk() *OSVirtualHardDisk {
 
55
    HostCaching := BoolToString(MakeRandomBool())
 
56
    DiskLabel := MakeRandomString(10)
 
57
    DiskName := MakeRandomString(10)
 
58
    MediaLink := MakeRandomString(10)
 
59
    SourceImageName := MakeRandomString(10)
 
60
 
 
61
    return &OSVirtualHardDisk{
 
62
        HostCaching:     HostCaching,
 
63
        DiskLabel:       DiskLabel,
 
64
        DiskName:        DiskName,
 
65
        MediaLink:       MediaLink,
 
66
        SourceImageName: SourceImageName}
 
67
}
 
68
 
 
69
func makeRole() *Role {
 
70
    RoleSize := "ExtraSmall"
 
71
    RoleName := MakeRandomString(10)
 
72
    RoleType := "PersistentVMRole"
 
73
    config := makeLinuxProvisioningConfiguration()
 
74
    configset := []ConfigurationSet{*config}
 
75
 
 
76
    return &Role{
 
77
        RoleSize:          RoleSize,
 
78
        RoleName:          RoleName,
 
79
        RoleType:          RoleType,
 
80
        ConfigurationSets: configset}
 
81
}
 
82
 
 
83
func makeDnsServer() *DnsServer {
 
84
    name := MakeRandomString(10)
 
85
    address := MakeRandomString(10)
 
86
 
 
87
    return &DnsServer{
 
88
        Name:    name,
 
89
        Address: address}
 
90
}
 
91
 
 
92
func makeDeployment() *Deployment {
 
93
    Name := MakeRandomString(10)
 
94
    DeploymentSlot := "Staging"
 
95
    Label := MakeRandomString(10)
 
96
    VirtualNetworkName := MakeRandomString(10)
 
97
    role := makeRole()
 
98
    RoleList := []Role{*role}
 
99
    Dns := []DnsServer{*makeDnsServer()}
 
100
 
 
101
    return &Deployment{
 
102
        XMLNS:              XMLNS,
 
103
        XMLNS_I:            XMLNS_I,
 
104
        Name:               Name,
 
105
        DeploymentSlot:     DeploymentSlot,
 
106
        Label:              Label,
 
107
        RoleList:           RoleList,
 
108
        VirtualNetworkName: VirtualNetworkName,
 
109
        DNS:                Dns,
 
110
    }
 
111
}
 
112
 
 
113
func makeCreateStorageServiceInput() *CreateStorageServiceInput {
 
114
    ServiceName := MakeRandomString(10)
 
115
    Description := MakeRandomString(10)
 
116
    Label := MakeRandomString(10)
 
117
    AffinityGroup := MakeRandomString(10)
 
118
    Location := MakeRandomString(10)
 
119
    GeoReplicationEnabled := BoolToString(MakeRandomBool())
 
120
    ExtendedProperties := []ExtendedProperty{{
 
121
        Name:  MakeRandomString(10),
 
122
        Value: MakeRandomString(10)}}
 
123
 
 
124
    return &CreateStorageServiceInput{
 
125
        XMLNS:                 XMLNS,
 
126
        ServiceName:           ServiceName,
 
127
        Description:           Description,
 
128
        Label:                 Label,
 
129
        AffinityGroup:         AffinityGroup,
 
130
        Location:              Location,
 
131
        GeoReplicationEnabled: GeoReplicationEnabled,
 
132
        ExtendedProperties:    ExtendedProperties}
 
133
}