Beispiel #1
0
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
}
Beispiel #2
0
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: "******"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
}