本文整理汇总了Golang中minicli.Response.Data方法的典型用法代码示例。如果您正苦于以下问题:Golang Response.Data方法的具体用法?Golang Response.Data怎么用?Golang Response.Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类minicli.Response
的用法示例。
在下文中一共展示了Response.Data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cliVmScreenshot
func cliVmScreenshot(c *minicli.Command, resp *minicli.Response) error {
file := c.StringArgs["filename"]
var max int
if arg := c.StringArgs["maximum"]; arg != "" {
v, err := strconv.Atoi(arg)
if err != nil {
return err
}
max = v
}
vm := vms.FindVM(c.StringArgs["vm"])
if vm == nil {
return vmNotFound(c.StringArgs["vm"])
}
data, err := vm.Screenshot(max)
if err != nil {
return err
}
path := filepath.Join(*f_base, strconv.Itoa(vm.GetID()), "screenshot.png")
if file != "" {
path = file
}
// add user data in case this is going across meshage
err = ioutil.WriteFile(path, data, os.FileMode(0644))
if err != nil {
return err
}
resp.Data = data
return nil
}
示例2: Info
// Info populates resp with info about the VMs running in the active namespace.
func (vms VMs) Info(masks []string, resp *minicli.Response) {
vmLock.Lock()
defer vmLock.Unlock()
resp.Header = masks
res := VMs{} // for res.Data
for _, vm := range vms {
if !inNamespace(vm) {
continue
}
// Update dynamic fields before querying info
vm.UpdateNetworks()
// Copy the VM and use the copy from here on. This ensures that the
// Tabular info matches the Data field.
vm := vm.Copy()
res[vm.GetID()] = vm
row := []string{}
for _, mask := range masks {
if v, err := vm.Info(mask); err != nil {
// Field most likely not set for VM type
row = append(row, "N/A")
} else {
row = append(row, v)
}
}
resp.Tabular = append(resp.Tabular, row)
}
resp.Data = res
}