~allenap/gwacl/update-role

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2013 Canonical Ltd.  This software is licensed under the
// GNU Lesser General Public License version 3 (see the file COPYING).
//
// Test helpers to fake objects that go into, or come out of, the Azure API.

package gwacl

func populateEndpoint(endpoint *InputEndpoint) *InputEndpoint {
    if endpoint.LoadBalancedEndpointSetName == "" {
        endpoint.LoadBalancedEndpointSetName = MakeRandomString(10)
    }
    if endpoint.LocalPort == 0 {
        endpoint.LocalPort = MakeRandomPort()
    }
    if endpoint.Name == "" {
        endpoint.Name = MakeRandomString(10)
    }
    if endpoint.Port == 0 {
        endpoint.Port = MakeRandomPort()
    }
    if endpoint.LoadBalancerProbe == nil {
        endpoint.LoadBalancerProbe = &LoadBalancerProbe{}
    }
    if endpoint.LoadBalancerProbe.Path == "" {
        endpoint.LoadBalancerProbe.Path = MakeRandomString(10)
    }
    if endpoint.LoadBalancerProbe.Port == 0 {
        endpoint.LoadBalancerProbe.Port = MakeRandomPort()
    }
    if endpoint.LoadBalancerProbe.Protocol == "" {
        endpoint.LoadBalancerProbe.Protocol = MakeRandomString(10)
    }
    if endpoint.Protocol == "" {
        endpoint.Protocol = MakeRandomString(10)
    }
    if endpoint.VIP == "" {
        endpoint.VIP = MakeRandomString(10)
    }
    return endpoint
}

func makeLinuxProvisioningConfiguration() *ConfigurationSet {
    hostname := MakeRandomString(10)
    username := MakeRandomString(10)
    password := MakeRandomString(10)
    userdata := MakeRandomString(10)
    disableSSH := BoolToString(MakeRandomBool())
    return NewLinuxProvisioningConfigurationSet(hostname, username, password, userdata, disableSSH)
}

func makeOSVirtualHardDisk() *OSVirtualHardDisk {
    HostCaching := BoolToString(MakeRandomBool())
    DiskLabel := MakeRandomString(10)
    DiskName := MakeRandomString(10)
    MediaLink := MakeRandomString(10)
    SourceImageName := MakeRandomString(10)

    return &OSVirtualHardDisk{
        HostCaching:     HostCaching,
        DiskLabel:       DiskLabel,
        DiskName:        DiskName,
        MediaLink:       MediaLink,
        SourceImageName: SourceImageName}
}

func makeRole() *Role {
    RoleSize := "ExtraSmall"
    RoleName := MakeRandomString(10)
    RoleType := "PersistentVMRole"
    config := makeLinuxProvisioningConfiguration()
    configset := []ConfigurationSet{*config}

    return &Role{
        RoleSize:          RoleSize,
        RoleName:          RoleName,
        RoleType:          RoleType,
        ConfigurationSets: configset}
}

func makeDnsServer() *DnsServer {
    name := MakeRandomString(10)
    address := MakeRandomString(10)

    return &DnsServer{
        Name:    name,
        Address: address}
}

func makeDeployment() *Deployment {
    Name := MakeRandomString(10)
    DeploymentSlot := "Staging"
    Label := MakeRandomString(10)
    VirtualNetworkName := MakeRandomString(10)
    role := makeRole()
    RoleList := []Role{*role}
    Dns := []DnsServer{*makeDnsServer()}

    return &Deployment{
        XMLNS:              XMLNS,
        XMLNS_I:            XMLNS_I,
        Name:               Name,
        DeploymentSlot:     DeploymentSlot,
        Label:              Label,
        RoleList:           RoleList,
        VirtualNetworkName: VirtualNetworkName,
        DNS:                Dns,
    }
}

func makeCreateStorageServiceInput() *CreateStorageServiceInput {
    ServiceName := MakeRandomString(10)
    Description := MakeRandomString(10)
    Label := MakeRandomString(10)
    AffinityGroup := MakeRandomString(10)
    Location := MakeRandomString(10)
    GeoReplicationEnabled := BoolToString(MakeRandomBool())
    ExtendedProperties := []ExtendedProperty{{
        Name:  MakeRandomString(10),
        Value: MakeRandomString(10)}}

    return &CreateStorageServiceInput{
        XMLNS:                 XMLNS,
        ServiceName:           ServiceName,
        Description:           Description,
        Label:                 Label,
        AffinityGroup:         AffinityGroup,
        Location:              Location,
        GeoReplicationEnabled: GeoReplicationEnabled,
        ExtendedProperties:    ExtendedProperties}
}