Example #1
0
func (a *RebuildDroplet) Run() error {
	account := CurrentAccount()
	rsp, e := account.RebuildDroplet(a.DropletId, a.ImageId)
	if e != nil {
		return e
	}
	logger.Debugf("got response %+v", rsp)
	droplet := &digitalocean.Droplet{Id: a.DropletId, Account: account}
	return digitalocean.WaitForDroplet(droplet)
}
Example #2
0
func (a *CreateDroplet) Run() error {
	started := time.Now()
	droplet := &digitalocean.Droplet{
		Name:     a.Name,
		SizeId:   a.SizeId,
		RegionId: a.RegionId,
		ImageId:  a.ImageId,
		SshKey:   a.SshKeyId,
	}

	droplet, e := CurrentAccount().CreateDroplet(droplet)
	if e != nil {
		return e
	}
	droplet.Account = CurrentAccount()
	logger.Infof("created droplet with id %d", droplet.Id)
	e = digitalocean.WaitForDroplet(droplet)
	logger.Infof("droplet %d ready, ip: %s. total_time: %.1fs", droplet.Id, droplet.IpAddress, time.Now().Sub(started).Seconds())
	return e
}