traefik/vendor/github.com/pyr/egoscale/exo.go

40 lines
720 B
Go
Raw Normal View History

2017-02-07 21:33:23 +00:00
package main
import (
"egoscale"
"fmt"
"flag"
2017-02-07 21:33:23 +00:00
"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")
2017-02-07 21:33:23 +00:00
func main() {
2017-02-07 21:33:23 +00:00
flag.Parse()
client := egoscale.NewClient(*endpoint, *apikey, *apisecret)
2017-02-07 21:33:23 +00:00
vms, err := client.ListVirtualMachines()
2017-02-07 21:33:23 +00:00
if err != nil {
fmt.Printf("got error: %s\n", err)
os.Exit(1)
2017-02-07 21:33:23 +00:00
}
for _, vm := range(vms) {
2017-02-07 21:33:23 +00:00
fmt.Println("vm:", vm.Displayname)
for _, nic := range(vm.Nic) {
fmt.Println("ip:", nic.Ipaddress)
2017-02-07 21:33:23 +00:00
}
for _, sg := range(vm.SecurityGroups) {
fmt.Println("securitygroup:", sg.Name)
2017-02-07 21:33:23 +00:00
}
}
os.Exit(0)
2017-02-07 21:33:23 +00:00
}