当前位置: 首页>>代码示例>>Golang>>正文


Golang VmInfo.Actions方法代码示例

本文整理汇总了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
}
开发者ID:yashodhank,项目名称:lobster,代码行数:35,代码来源:lobster.go

示例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
}
开发者ID:nhocconan,项目名称:lobster,代码行数:30,代码来源:solusvm.go


注:本文中的github.com/LunaNode/lobster.VmInfo.Actions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。