本文整理汇总了Golang中github.com/LunaNode/lobster.VmInfo.Actions方法的典型用法代码示例。如果您正苦于以下问题:Golang VmInfo.Actions方法的具体用法?Golang VmInfo.Actions怎么用?Golang VmInfo.Actions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/LunaNode/lobster.VmInfo
的用法示例。
在下文中一共展示了VmInfo.Actions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: VmInfo
func (this *Lobster) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
vmIdentification, _ := strconv.Atoi(vm.Identification)
apiInfoResponse, err := this.client.VmInfo(vmIdentification)
if err != nil {
return nil, err
}
apiInfo := apiInfoResponse.Details
info := lobster.VmInfo{
Ip: apiInfo.Ip,
PrivateIp: apiInfo.PrivateIp,
Status: apiInfo.Status,
Hostname: apiInfo.Hostname,
BandwidthUsed: apiInfo.BandwidthUsed,
LoginDetails: apiInfo.LoginDetails,
Details: apiInfo.Details,
OverrideCapabilities: true,
CanVnc: apiInfo.CanVnc,
CanReimage: apiInfo.CanReimage,
CanResize: apiInfo.CanResize,
CanSnapshot: apiInfo.CanSnapshot,
CanAddresses: apiInfo.CanAddresses,
}
for _, srcAction := range apiInfo.Actions {
dstAction := new(lobster.VmActionDescriptor)
dstAction.Action = srcAction.Action
dstAction.Name = srcAction.Name
dstAction.Options = srcAction.Options
dstAction.Description = srcAction.Description
dstAction.Dangerous = srcAction.Dangerous
info.Actions = append(info.Actions, dstAction)
}
return &info, nil
}
示例2: VmInfo
func (this *SolusVM) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
vmIdentificationInt, _ := strconv.Atoi(vm.Identification)
apiInfo, err := this.Api.VmInfo(vmIdentificationInt)
if err != nil {
return nil, err
}
bwUsed, _ := strconv.ParseInt(strings.Split(apiInfo.Bandwidth, ",")[1], 10, 64)
info := lobster.VmInfo{
Ip: apiInfo.Ip,
PrivateIp: apiInfo.InternalIps,
Status: strings.Title(apiInfo.State),
BandwidthUsed: bwUsed,
LoginDetails: "username: root; password: " + vm.Metadata("password", "unknown"),
}
if this.VirtType == "openvz" {
info.Actions = append(info.Actions, &lobster.VmActionDescriptor{
Action: "tuntap",
Name: "TUN/TAP",
Description: "Enable or disable TUN/TAP.",
Options: map[string]string{
"enable": "On",
"disable": "Off",
},
})
}
return &info, nil
}