当前位置: 首页>>代码示例>>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;未经允许,请勿转载。