blob: 772852e3949eae497c37904d93d6bcecef17ca05 [file] [log] [blame]
Samuel A. Falvo II2dd7d2f2014-06-30 16:18:08 -07001// +build acceptance,old
2
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -07003package main
4
5import (
Jon Perritt2be65d12013-12-13 17:21:09 -06006 "flag"
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -07007 "fmt"
Max Lincoln28b49562013-12-13 13:23:44 -03008 "github.com/rackspace/gophercloud"
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -07009)
10
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070011var quiet = flag.Bool("quiet", false, "Quiet mode, for acceptance testing. $? still indicates errors though.")
12
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070013func main() {
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070014 flag.Parse()
15
Samuel A. Falvo II887d7802013-07-29 17:55:37 -070016 withIdentity(false, func(acc gophercloud.AccessProvider) {
Samuel A. Falvo II41856d62013-07-29 15:48:22 -070017 withServerApi(acc, func(api gophercloud.CloudServersProvider) {
18 tryFullDetails(api)
19 tryLinksOnly(api)
20 })
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070021 })
Samuel A. Falvo IIa0a55842013-07-24 13:14:17 -070022}
23
24func tryLinksOnly(api gophercloud.CloudServersProvider) {
25 servers, err := api.ListServersLinksOnly()
26 if err != nil {
27 panic(err)
28 }
29
30 if !*quiet {
Jon Perritt2be65d12013-12-13 17:21:09 -060031 fmt.Println("Id,Name")
Samuel A. Falvo IIa0a55842013-07-24 13:14:17 -070032 for _, s := range servers {
Jon Perritt2be65d12013-12-13 17:21:09 -060033 if s.AccessIPv4 != "" {
34 panic("IPv4 not expected")
35 }
Samuel A. Falvo IIa0a55842013-07-24 13:14:17 -070036
Jon Perritt2be65d12013-12-13 17:21:09 -060037 if s.Status != "" {
38 panic("Status not expected")
39 }
Samuel A. Falvo IIa0a55842013-07-24 13:14:17 -070040
Jon Perritt2be65d12013-12-13 17:21:09 -060041 if s.Progress != 0 {
42 panic("Progress not expected")
43 }
Samuel A. Falvo IIa0a55842013-07-24 13:14:17 -070044
45 fmt.Printf("%s,\"%s\"\n", s.Id, s.Name)
46 }
47 }
48}
49
50func tryFullDetails(api gophercloud.CloudServersProvider) {
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070051 servers, err := api.ListServers()
52 if err != nil {
53 panic(err)
54 }
55
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070056 if !*quiet {
Jon Perritt2be65d12013-12-13 17:21:09 -060057 fmt.Println("Id,Name,AccessIPv4,Status,Progress")
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070058 for _, s := range servers {
Samuel A. Falvo IIa0a55842013-07-24 13:14:17 -070059 fmt.Printf("%s,\"%s\",%s,%s,%d\n", s.Id, s.Name, s.AccessIPv4, s.Status, s.Progress)
Samuel A. Falvo II02f5e832013-07-10 13:52:27 -070060 }
Samuel A. Falvo IIfca35b72013-07-02 18:30:28 -070061 }
62}