blob: d1835e1f509b3d48d2a4e13d3df151bc5b781784 [file] [log] [blame]
Samuel A. Falvo IIe21808f2013-08-14 14:48:09 -07001package main
2
3import (
4 "fmt"
5 "flag"
6 "github.com/rackspace/gophercloud"
7)
8
9var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
10
11func main() {
12 flag.Parse()
13 withIdentity(false, func(acc gophercloud.AccessProvider) {
14 withServerApi(acc, func(servers gophercloud.CloudServersProvider) {
15 log("Creating server")
16 id, err := createServer(servers, "", "", "", "")
17 if err != nil {
18 panic(err)
19 }
20 waitForServerState(servers, id, "ACTIVE")
21 defer servers.DeleteServerById(id)
22
23 log("Getting list of addresses...")
24 addresses, err := servers.ListAddresses(id)
25 if (err != nil) && (err != gophercloud.WarnUnauthoritative) {
26 panic(err)
27 }
28 if err == gophercloud.WarnUnauthoritative {
29 log("Uh oh -- got a response back, but it's not authoritative for some reason.")
30 }
31 for _, addr := range addresses.Public {
32 log("Address:", addr.Addr, " IPv", addr.Version)
33 }
34
35 log("Done")
36 })
37 })
38}
39
40func log(s... interface{}) {
41 if !*quiet {
42 fmt.Println(s...)
43 }
44}