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