blob: 64ec4f67f824c365e1fbc0dae779dfdd3f274384 [file] [log] [blame]
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -07001package main
2
3import (
4 "fmt"
5 "github.com/rackspace/gophercloud"
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -07006 "flag"
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -07007)
8
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -07009var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
10
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070011func main() {
Samuel A. Falvo II704a7502013-07-10 15:23:43 -070012 provider, username, password := getCredentials()
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070013 flag.Parse()
14
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070015 acc, err := gophercloud.Authenticate(
16 provider,
17 gophercloud.AuthOptions{
18 Username: username,
19 Password: password,
20 },
21 )
22 if err != nil {
23 panic(err)
24 }
25
Samuel A. Falvo II1dd740a2013-07-08 15:48:40 -070026 api, err := gophercloud.ServersApi(acc, gophercloud.ApiCriteria{
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070027 Name: "cloudServersOpenStack",
28 Region: "DFW",
29 VersionId: "2",
30 UrlChoice: gophercloud.PublicURL,
31 })
32 if err != nil {
33 panic(err)
34 }
35
36 servers, err := api.ListServers()
37 if err != nil {
38 panic(err)
39 }
40
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070041 if !*quiet {
42 for _, s := range servers {
43 fmt.Printf("%s\n", s.Id)
44 }
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070045 }
46}