當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。