示例#1
0
func (d *Driver) jobIsDone(client *egoscale.Client, jobid string) (bool, error) {
	resp, err := client.PollAsyncJob(jobid)
	if err != nil {
		return true, err
	}
	switch resp.Jobstatus {
	case 0: // Job is still in progress
	case 1: // Job has successfully completed
		return true, nil
	case 2: // Job has failed to complete
		return true, fmt.Errorf("Operation failed to complete")
	default: // Some other code
	}
	return false, nil
}
示例#2
0
func (d *Driver) waitForVM(client *egoscale.Client, jobid string) (*egoscale.DeployVirtualMachineResponse, error) {
	if err := d.waitForJob(client, jobid); err != nil {
		return nil, err
	}
	resp, err := client.PollAsyncJob(jobid)
	if err != nil {
		return nil, err
	}
	vm, err := client.AsyncToVirtualMachine(*resp)
	if err != nil {
		return nil, err
	}

	return vm, nil
}
示例#3
0
func (d *Driver) createDefaultAffinityGroup(client *egoscale.Client, group string) (string, error) {
	jobid, err := client.CreateAffinityGroup(group)
	if err != nil {
		return "", err
	}
	var resp *egoscale.QueryAsyncJobResultResponse
	for i := 0; i <= 10; i++ {
		resp, err = client.PollAsyncJob(jobid)
		if err != nil {
			fmt.Printf("got error: %+v\n", err)
		}

		if resp.Jobstatus == 1 {
			break
		}
		time.Sleep(5 * time.Second)
	}
	affinitygroups, err := client.GetAffinityGroups()
	agid := affinitygroups[group]
	return agid, nil
}