traefik/vendor/github.com/pyr/egoscale/exo.go
Emile Vauge aeb17182b4
Merge v1.2.1-master
Signed-off-by: Emile Vauge <emile@vauge.com>
2017-04-11 22:36:56 +02:00

39 lines
720 B
Go

package main
import (
"egoscale"
"fmt"
"flag"
"os"
)
var apikey = flag.String("xk", "", "Exoscale API Key")
var apisecret = flag.String("xs", "", "Exoscale API Secret")
var endpoint = flag.String("xe", "https://api.exoscale.ch/compute", "Exoscale API Endpoint")
func main() {
flag.Parse()
client := egoscale.NewClient(*endpoint, *apikey, *apisecret)
vms, err := client.ListVirtualMachines()
if err != nil {
fmt.Printf("got error: %s\n", err)
os.Exit(1)
}
for _, vm := range(vms) {
fmt.Println("vm:", vm.Displayname)
for _, nic := range(vm.Nic) {
fmt.Println("ip:", nic.Ipaddress)
}
for _, sg := range(vm.SecurityGroups) {
fmt.Println("securitygroup:", sg.Name)
}
}
os.Exit(0)
}