本文整理汇总了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
}
示例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
}
示例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
}
示例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
}