~thumper/juju-core/move-environs-tools

« back to all changes in this revision

Viewing changes to environs/azure/instance.go

  • Committer: Tarmac
  • Author(s): Raphael Badin
  • Date: 2013-07-08 08:34:47 UTC
  • mfrom: (1385.1.6 use-hosted-services)
  • Revision ID: tarmac-20130708083447-jmbwbyairfpi5rie
[r=rvb] Azure provider: map instances onto Azure services.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
package azure
5
5
 
6
6
import (
 
7
        "fmt"
7
8
        "launchpad.net/gwacl"
8
9
        "launchpad.net/juju-core/environs"
9
10
        "launchpad.net/juju-core/instance"
10
11
)
11
12
 
12
13
type azureInstance struct {
13
 
        gwacl.Deployment
 
14
        // An instance contains an Azure Service (instance==service).
 
15
        gwacl.HostedServiceDescriptor
14
16
}
15
17
 
16
18
// azureInstance implements Instance.
18
20
 
19
21
// Id is specified in the Instance interface.
20
22
func (azInstance *azureInstance) Id() instance.Id {
21
 
        return instance.Id(azInstance.Name)
 
23
        return instance.Id(azInstance.ServiceName)
22
24
}
23
25
 
 
26
var AZURE_DOMAIN_NAME = "cloudapp.net"
 
27
 
24
28
// DNSName is specified in the Instance interface.
25
29
func (azInstance *azureInstance) DNSName() (string, error) {
26
 
        // An Azure deployment gets its DNS name immediately when it's created.
27
 
        return azInstance.GetFQDN()
 
30
        // The hostname is stored in the hosted service's label.
 
31
        label, err := azInstance.GetLabel()
 
32
        if err != nil {
 
33
                return "", err
 
34
        }
 
35
        if label == "" {
 
36
                return "", instance.ErrNoDNSName
 
37
        }
 
38
        return fmt.Sprintf("%s.%s", label, AZURE_DOMAIN_NAME), nil
28
39
}
29
40
 
30
41
// WaitDNSName is specified in the Instance interface.