本文整理匯總了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
}