Exemple #1
0
func (command *commandDelete) Execute(resource *handler.Resource) {
	serverID := resource.Params.(*paramsDelete).server
	err := servers.Delete(command.Ctx.ServiceClient, serverID).ExtractErr()
	if err != nil {
		resource.Err = err
		return
	}
	resource.Result = fmt.Sprintf("Deleting instance [%s]\n", serverID)
}
Exemple #2
0
func (command *commandDelete) Execute(resource *handler.Resource) {
	serverID := resource.Params.(*paramsDelete).server
	err := servers.Delete(command.Ctx.ServiceClient, serverID).ExtractErr()
	if err != nil {
		resource.Err = err
		return
	}

	if resource.Params.(*paramsDelete).wait {
		i := 0
		for i < 120 {
			_, err := servers.Get(command.Ctx.ServiceClient, serverID).Extract()
			if err != nil {
				break
			}
			time.Sleep(5 * time.Second)
			i++
		}
		resource.Result = fmt.Sprintf("Deleted instance [%s]\n", serverID)
	} else {
		resource.Result = fmt.Sprintf("Deleting instance [%s]\n", serverID)
	}
}