func (cmd *ls) Run(ctx context.Context, f *flag.FlagSet) error { c, err := cmd.Client() if err != nil { return err } var host *object.HostSystem if c.IsVC() { host, err = cmd.HostSystemIfSpecified() if err != nil { return err } } m := object.NewDiagnosticManager(c) desc, err := m.QueryDescriptions(ctx, host) if err != nil { return err } tw := tabwriter.NewWriter(os.Stdout, 2, 0, 2, ' ', 0) for _, d := range desc { fmt.Fprintf(tw, "%s\t%s\n", d.Key, d.FileName) } return tw.Flush() }
// NewDiagnosticManager returns a new DiagnosticManager object func NewDiagnosticManager(session *session.Session) *Manager { return &Manager{ DiagnosticManager: object.NewDiagnosticManager( session.Vim25(), ), Session: session, } }
func (cmd *logs) Run(f *flag.FlagSet) error { ctx := context.TODO() c, err := cmd.Client() if err != nil { return err } defaultKey := "hostd" var host *object.HostSystem if c.ServiceContent.About.ApiType == "VirtualCenter" { host, err = cmd.HostSystemIfSpecified() if err != nil { return err } if host == nil { defaultKey = "vpxd:vpxd.log" } } m := object.NewDiagnosticManager(c) key := cmd.Key if key == "" { key = defaultKey } // get LineEnd without any LineText h, err := m.BrowseLog(ctx, host, key, math.MaxInt32, 0) if err != nil { return err } start := h.LineEnd - cmd.Max h, err = m.BrowseLog(ctx, host, key, start, 0) if err != nil { return err } for _, line := range h.LineText { fmt.Println(line) } return nil }
func (cmd *download) Run(ctx context.Context, f *flag.FlagSet) error { finder, err := cmd.Finder() if err != nil { return err } var host []*object.HostSystem for _, arg := range f.Args() { hs, err := finder.HostSystemList(context.TODO(), arg) if err != nil { return err } host = append(host, hs...) } c, err := cmd.Client() if err != nil { return err } m := object.NewDiagnosticManager(c) bundles, err := cmd.GenerateLogBundles(m, host) if err != nil { return err } for _, bundle := range bundles { err := cmd.DownloadFile(c, bundle.Url) if err != nil { return err } } return nil }
func (r dlogReader) open() (entry, error) { defer trace.End(trace.Begin(r.name)) name := r.name if r.host != nil { name = fmt.Sprintf("%s-%s", path.Base(r.host.InventoryPath), r.name) } m := object.NewDiagnosticManager(r.c.Vim25()) ctx := context.Background() // Currently we collect the tail of diagnostic log files to avoid // reading the entire file into memory or writing local disk. // get LineEnd without any LineText h, err := m.BrowseLog(ctx, r.host, r.name, math.MaxInt32, 0) if err != nil { return nil, err } // DiagnosticManager::DEFAULT_MAX_LINES_PER_BROWSE = 1000 start := h.LineEnd - 1000 h, err = m.BrowseLog(ctx, r.host, r.name, start, 0) if err != nil { return nil, err } var buf bytes.Buffer for _, line := range h.LineText { buf.WriteString(line) buf.WriteString("\n") } return newBytesEntry(name+".log", buf.Bytes()), nil }