示例#1
0
func (a *RenameServer) Run() error {
	account, e := hetzner.AccountFromEnv()
	if e != nil {
		return e
	}
	logger.Printf("renaming servers %s to %s", a.Ip, a.NewName)
	return account.RenameServer(a.Ip, a.NewName)
}
示例#2
0
func ListServers() error {
	account, e := hetzner.AccountFromEnv()
	if e != nil {
		return e
	}
	servers, e := account.Servers()
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("Number", "Name", "Product", "DC", "Ip", "Status")
	for _, server := range servers {
		table.Add(server.ServerNumber, server.ServerName, server.Product, server.Dc, server.ServerIp, server.Status)
	}
	fmt.Println(table)
	return nil
}
示例#3
0
func (a *DescribeServer) Run() error {
	account, e := hetzner.AccountFromEnv()
	if e != nil {
		return e
	}

	server, e := account.LoadServer(a.IP)
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("IP", server.ServerIp)
	table.Add("Number", server.ServerNumber)
	table.Add("Name", server.ServerName)
	table.Add("Product", server.Product)
	table.Add("DataCenter", server.Dc)
	table.Add("Status", server.Status)
	table.Add("Reset", server.Reset)
	table.Add("Rescue", server.Rescue)
	table.Add("VNC", server.Vnc)
	fmt.Println(table)
	return nil
}