Add ListFlavors() and acceptance test.
This is required to support server creation acceptance testing. Without
the ability to detect flavors automatically, it isn't possible to
automate acceptance testing, as then a human operator would be required
to manually intervene while testing.
diff --git a/acceptance/06-list-flavors.go b/acceptance/06-list-flavors.go
new file mode 100644
index 0000000..ad56988
--- /dev/null
+++ b/acceptance/06-list-flavors.go
@@ -0,0 +1,48 @@
+package main
+
+import (
+ "fmt"
+ "flag"
+ "github.com/rackspace/gophercloud"
+)
+
+var quiet = flag.Bool("quiet", false, "Quiet mode for acceptance testing. $? non-zero on error though.")
+var rgn = flag.String("r", "DFW", "Datacenter region to interrogate.")
+
+func main() {
+ provider, username, password := getCredentials()
+ flag.Parse()
+
+ auth, err := gophercloud.Authenticate(
+ provider,
+ gophercloud.AuthOptions{
+ Username: username,
+ Password: password,
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ servers, err := gophercloud.ServersApi(auth, gophercloud.ApiCriteria{
+ Name: "cloudServersOpenStack",
+ Region: *rgn,
+ VersionId: "2",
+ UrlChoice: gophercloud.PublicURL,
+ })
+ if err != nil {
+ panic(err)
+ }
+
+ flavors, err := servers.ListFlavors()
+ if err != nil {
+ panic(err)
+ }
+
+ if !*quiet {
+ fmt.Println("ID,Name,MinRam,MinDisk")
+ for _, f := range flavors {
+ fmt.Printf("%s,\"%s\",%d,%d\n", f.Id, f.Name, f.Ram, f.Disk)
+ }
+ }
+}