當前位置: 首頁>>代碼示例>>Golang>>正文


Golang egoscale.Client類代碼示例

本文整理匯總了Golang中github.com/pyr/egoscale/src/egoscale.Client的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Client類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: waitForVM

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
}
開發者ID:al3xanderschmidt,項目名稱:machine,代碼行數:15,代碼來源:exoscale.go

示例2: jobIsDone

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
}
開發者ID:al3xanderschmidt,項目名稱:machine,代碼行數:15,代碼來源:exoscale.go

示例3: createDefaultSecurityGroup

func (d *Driver) createDefaultSecurityGroup(client *egoscale.Client, group string) (string, error) {
	rules := []egoscale.SecurityGroupRule{
		{
			SecurityGroupId: "",
			Cidr:            "0.0.0.0/0",
			Protocol:        "TCP",
			Port:            22,
		},
		{
			SecurityGroupId: "",
			Cidr:            "0.0.0.0/0",
			Protocol:        "TCP",
			Port:            2376,
		},
		{
			SecurityGroupId: "",
			Cidr:            "0.0.0.0/0",
			Protocol:        "TCP",
			Port:            3376,
		},
		{
			SecurityGroupId: "",
			Cidr:            "0.0.0.0/0",
			Protocol:        "ICMP",
			IcmpType:        8,
			IcmpCode:        0,
		},
	}
	sgresp, err := client.CreateSecurityGroupWithRules(
		group,
		rules,
		make([]egoscale.SecurityGroupRule, 0, 0))
	if err != nil {
		return "", err
	}
	sg := sgresp.Id
	return sg, nil
}
開發者ID:al3xanderschmidt,項目名稱:machine,代碼行數:38,代碼來源:exoscale.go

示例4: createDefaultAffinityGroup

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
}
開發者ID:bgokden,項目名稱:machine,代碼行數:21,代碼來源:exoscale.go


注:本文中的github.com/pyr/egoscale/src/egoscale.Client類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。