Exemple #1
0
func DoListFlavors(c *client.Client, opts interface{}) error {
	if getField(opts, "All").Bool() {
		fmt.Printf("all\n")
	}
	flavors, err := flavor.List(c, "")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("flavors: %+v\n", flavors)
	for k, v := range flavors.Flavors {
		fmt.Printf("%d: %s\n", k, v.Id)
	}
	return nil
}
Exemple #2
0
func main() {
	options := struct {
		Debug   bool `goptions:"-x, --debug, description='Enable debugging'"`
		Verbose bool `goptions:"-v, --verbose, description='Be not quiet with output'"`
	}{
		Debug:   false,
		Verbose: false,
	}
	goptions.Parse(&options)

	// Propagate debug setting to packages
	client.Debug = &options.Debug

	// Get auth values from the environment
	var creds osclib.Creds
	c, err := client.NewClient(creds)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Print("Servers: \n")
	servers, err := server.List(c, "")
	if err != nil {
		log.Fatal(err)
	}
	if servers != nil {
		if options.Verbose == true {
			fmt.Printf("c: %+v\n\n", *servers)
		} else {
			fmt.Printf("c: %+v\n\n", *servers)
		}
	}

	flavors, err := flavor.List(c, "")
	if err != nil {
		log.Fatal(err)
	}
	//    osclib.OutputData([]string{"a","b","c"}, []interface{}(flavors))
	for k, v := range flavors.Flavors {
		fmt.Printf("%d: %s\n", k, v.Id)
	}

}