Samuel A. Falvo II | 2dd7d2f | 2014-06-30 16:18:08 -0700 | [diff] [blame^] | 1 | // +build acceptance,old |
| 2 | |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 3 | package main |
| 4 | |
| 5 | import ( |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 6 | "flag" |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 7 | "fmt" |
Max Lincoln | 28b4956 | 2013-12-13 13:23:44 -0300 | [diff] [blame] | 8 | "github.com/rackspace/gophercloud" |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 9 | ) |
| 10 | |
Samuel A. Falvo II | 02f5e83 | 2013-07-10 13:52:27 -0700 | [diff] [blame] | 11 | var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.") |
| 12 | |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 13 | func main() { |
Samuel A. Falvo II | 02f5e83 | 2013-07-10 13:52:27 -0700 | [diff] [blame] | 14 | flag.Parse() |
| 15 | |
Samuel A. Falvo II | 887d780 | 2013-07-29 17:55:37 -0700 | [diff] [blame] | 16 | withIdentity(false, func(acc gophercloud.AccessProvider) { |
Samuel A. Falvo II | 41856d6 | 2013-07-29 15:48:22 -0700 | [diff] [blame] | 17 | withServerApi(acc, func(api gophercloud.CloudServersProvider) { |
| 18 | tryFullDetails(api) |
| 19 | tryLinksOnly(api) |
| 20 | }) |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 21 | }) |
Samuel A. Falvo II | a0a5584 | 2013-07-24 13:14:17 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | func tryLinksOnly(api gophercloud.CloudServersProvider) { |
| 25 | servers, err := api.ListServersLinksOnly() |
| 26 | if err != nil { |
| 27 | panic(err) |
| 28 | } |
| 29 | |
| 30 | if !*quiet { |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 31 | fmt.Println("Id,Name") |
Samuel A. Falvo II | a0a5584 | 2013-07-24 13:14:17 -0700 | [diff] [blame] | 32 | for _, s := range servers { |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 33 | if s.AccessIPv4 != "" { |
| 34 | panic("IPv4 not expected") |
| 35 | } |
Samuel A. Falvo II | a0a5584 | 2013-07-24 13:14:17 -0700 | [diff] [blame] | 36 | |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 37 | if s.Status != "" { |
| 38 | panic("Status not expected") |
| 39 | } |
Samuel A. Falvo II | a0a5584 | 2013-07-24 13:14:17 -0700 | [diff] [blame] | 40 | |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 41 | if s.Progress != 0 { |
| 42 | panic("Progress not expected") |
| 43 | } |
Samuel A. Falvo II | a0a5584 | 2013-07-24 13:14:17 -0700 | [diff] [blame] | 44 | |
| 45 | fmt.Printf("%s,\"%s\"\n", s.Id, s.Name) |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func tryFullDetails(api gophercloud.CloudServersProvider) { |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 51 | servers, err := api.ListServers() |
| 52 | if err != nil { |
| 53 | panic(err) |
| 54 | } |
| 55 | |
Samuel A. Falvo II | 02f5e83 | 2013-07-10 13:52:27 -0700 | [diff] [blame] | 56 | if !*quiet { |
Jon Perritt | 2be65d1 | 2013-12-13 17:21:09 -0600 | [diff] [blame] | 57 | fmt.Println("Id,Name,AccessIPv4,Status,Progress") |
Samuel A. Falvo II | 02f5e83 | 2013-07-10 13:52:27 -0700 | [diff] [blame] | 58 | for _, s := range servers { |
Samuel A. Falvo II | a0a5584 | 2013-07-24 13:14:17 -0700 | [diff] [blame] | 59 | fmt.Printf("%s,\"%s\",%s,%s,%d\n", s.Id, s.Name, s.AccessIPv4, s.Status, s.Progress) |
Samuel A. Falvo II | 02f5e83 | 2013-07-10 13:52:27 -0700 | [diff] [blame] | 60 | } |
Samuel A. Falvo II | fca35b7 | 2013-07-02 18:30:28 -0700 | [diff] [blame] | 61 | } |
| 62 | } |