本文整理汇总了Golang中github.com/LunaNode/lobster.VmInfo类的典型用法代码示例。如果您正苦于以下问题:Golang VmInfo类的具体用法?Golang VmInfo怎么用?Golang VmInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VmInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 (cs *CloudStack) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
details, err := cs.client.GetVirtualMachine(vm.Identification)
if err != nil {
return nil, err
}
status := details.State
if status == "Running" {
status = "Online"
} else if status == "Stopped" {
status = "Offline"
}
info := lobster.VmInfo{
Status: status,
LoginDetails: "password: " + vm.Metadata("password", "unknown"),
}
for _, nic := range details.Nics {
if ipaddr.IsPrivate(nic.Addr) {
info.PrivateIp = nic.Addr
} else {
info.Ip = nic.Addr
}
}
return &info, nil
}
开发者ID:carriercomm,项目名称:lobster,代码行数:28,代码来源:cloudstack.go
示例3: 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
示例4: VmInfo
func (this *Linode) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
linodeID, _ := strconv.Atoi(vm.Identification)
linode, err := this.client.GetLinode(linodeID)
if err != nil {
return nil, err
}
info := lobster.VmInfo{
Hostname: vm.Name,
LoginDetails: "password: " + vm.Metadata("password", "unknown"),
}
if linode.StatusString == "Running" {
info.Status = "Online"
} else if linode.StatusString == "Powered Off" {
info.Status = "Offline"
} else {
info.Status = linode.StatusString
}
ips, err := this.client.ListIP(linodeID)
if err == nil {
for _, ip := range ips {
if ip.IsPublic == 1 {
info.Ip = ip.Address
} else {
info.PrivateIp = ip.Address
}
}
}
return &info, nil
}
开发者ID:carriercomm,项目名称:lobster,代码行数:33,代码来源:linode.go
示例5: VmInfo
func (this *Vultr) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
server, err := this.client.GetServer(vm.Identification)
if err != nil {
return nil, err
}
info := lobster.VmInfo{
Ip: server.MainIP,
PrivateIp: server.InternalIP,
Hostname: server.Name,
BandwidthUsed: int64(server.CurrentBandwidth * 1024 * 1024 * 1024),
LoginDetails: "password: " + server.DefaultPassword,
}
if server.Status == "pending" {
info.Status = "Installing"
} else if server.Status == "active" {
if server.PowerStatus == "stopped" {
info.Status = "Offline"
} else if server.PowerStatus == "running" {
info.Status = "Online"
} else {
info.Status = server.PowerStatus
}
} else {
info.Status = fmt.Sprintf("%s (%s)", strings.Title(server.Status), strings.Title(server.PowerStatus))
}
return &info, nil
}
开发者ID:nhocconan,项目名称:lobster,代码行数:30,代码来源:vmvultr.go
示例6: VmInfo
func (this *OpenStack) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
server, err := servers.Get(this.ComputeClient, vm.Identification).Extract()
if err != nil {
return nil, err
}
status := server.Status
if status == "ACTIVE" {
status = "Online"
} else if status == "SHUTOFF" {
status = "Offline"
}
info := lobster.VmInfo{
Status: status,
Hostname: server.Name,
LoginDetails: "password: " + vm.Metadata("password", "unknown"),
}
servers.ListAddresses(this.ComputeClient, vm.Identification).EachPage(func(page pagination.Page) (bool, error) {
addresses, err := servers.ExtractAddresses(page)
if err != nil {
return false, err
}
for _, networkAddresses := range addresses {
for _, addr := range networkAddresses {
if ipaddr.IsPrivate(addr.Address) {
info.PrivateIp = addr.Address
} else {
info.Ip = addr.Address
}
}
}
return true, nil
})
return &info, nil
}
开发者ID:yashodhank,项目名称:lobster,代码行数:39,代码来源:openstack.go
示例7: VmInfo
func (this *DigitalOcean) VmInfo(vm *lobster.VirtualMachine) (*lobster.VmInfo, error) {
vmIdentification, _ := strconv.Atoi(vm.Identification)
droplet, _, err := this.client.Droplets.Get(vmIdentification)
if err != nil {
return nil, err
}
info := lobster.VmInfo{
Hostname: droplet.Name,
LoginDetails: "username: root; password: " + vm.Metadata("password", "unknown"),
}
for _, addr4 := range droplet.Networks.V4 {
if addr4.Type == "public" {
info.Ip = addr4.IPAddress
} else if addr4.Type == "private" {
info.PrivateIp = addr4.IPAddress
}
}
if droplet.Status == "active" {
info.Status = "Online"
} else if droplet.Status == "off" {
info.Status = "Offline"
} else {
info.Status = strings.Title(droplet.Status)
}
// list droplet actions
var pendingActions []string
actionList, _, err := this.client.Droplets.Actions(droplet.ID, &godo.ListOptions{PerPage: 25})
if err == nil {
for _, action := range actionList {
if action.Status == "in-progress" {
pendingActions = append(pendingActions, action.Type)
}
}
if len(pendingActions) >= 1 {
info.Details = make(map[string]string)
if len(pendingActions) == 1 {
info.Details["Pending action"] = pendingActions[0]
} else {
info.Details["Pending actions"] = strings.Join(pendingActions, ", ")
}
}
}
return &info, nil
}
开发者ID:yashodhank,项目名称:lobster,代码行数:47,代码来源:digitalocean.go
注:本文中的github.com/LunaNode/lobster.VmInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论