// printDatacenters prints datacenter data to stdout in tab-separated columns.
974645
func printDatacenters(tsv bool, datacenters ...*crimson.Datacenter) {
	if len(datacenters) > 0 {
		p := newStdoutPrinter(tsv)
		defer p.Flush()
		if !tsv {
			p.Row("Name", "Description")
		}
		for _, dc := range datacenters {
			p.Row(dc.Name, dc.Description)
		}
	}
}
707576
func backendPrintf(format string, args ...interface{}) {
	mux.Lock()
	defer mux.Unlock()
	printerBackend.Printf(format, args...)
}
496650
func (p *VersionedColumnPrinter) Print(out interface{}) ([]string, []byte, error) {
	var output []byte
	if obj, ok := out.(runtime.Object); ok {
		converted, err := p.convertor.ConvertToVersion(obj, p.version)
		if err != nil {
			if !runtime.IsNotRegisteredError(err) {
				return nil, nil, err
			}
			converted = obj
		}
		data, err := json.Marshal(converted)
		if err != nil {
			return nil, nil, err
		}
		output = data
		out = map[string]interface{}{}
		if err := json.Unmarshal(data, &out); err != nil {
			return nil, nil, err
		}
	}
	args, _, err := p.printer.Print(out)
	return args, output, err
}
772323
func (f *PrintFlags) ToPrinter() (printers.ResourcePrinter, error) {
	outputFormat := ""
	if f.OutputFormat != nil {
		outputFormat = *f.OutputFormat
	}

	noHeaders := false
	if f.NoHeaders != nil {
		noHeaders = *f.NoHeaders
	}
	f.HumanReadableFlags.NoHeaders = noHeaders
	f.CustomColumnsFlags.NoHeaders = noHeaders

	// for "get.go" we want to support a --template argument given, even when no --output format is provided
	if f.TemplateFlags.TemplateArgument != nil && len(*f.TemplateFlags.TemplateArgument) > 0 && len(outputFormat) == 0 {
		outputFormat = "go-template"
	}

	if p, err := f.TemplateFlags.ToPrinter(outputFormat); !genericclioptions.IsNoCompatiblePrinterError(err) {
		return p, err
	}

	if f.TemplateFlags.TemplateArgument != nil {
		f.CustomColumnsFlags.TemplateArgument = *f.TemplateFlags.TemplateArgument
	}

	if p, err := f.JSONYamlPrintFlags.ToPrinter(outputFormat); !genericclioptions.IsNoCompatiblePrinterError(err) {
		return p, err
	}

	if p, err := f.HumanReadableFlags.ToPrinter(outputFormat); !genericclioptions.IsNoCompatiblePrinterError(err) {
		return p, err
	}

	if p, err := f.CustomColumnsFlags.ToPrinter(outputFormat); !genericclioptions.IsNoCompatiblePrinterError(err) {
		return p, err
	}

	if p, err := f.NamePrintFlags.ToPrinter(outputFormat); !genericclioptions.IsNoCompatiblePrinterError(err) {
		return p, err
	}

	return nil, genericclioptions.NoCompatiblePrinterError{OutputFormat: &outputFormat, AllowedFormats: f.AllowedFormats()}
}
31914
func printVMSlots(tsv bool, hosts ...*crimson.PhysicalHost) {
	if len(hosts) > 0 {
		p := newStdoutPrinter(tsv)
		defer p.Flush()
		if !tsv {
			p.Row("Name", "VLAN", "VM Slots", "Virtual Datacenter", "State")
		}
		for _, h := range hosts {
			p.Row(h.Name, h.Vlan, h.VmSlots, h.VirtualDatacenter, h.State)
		}
	}
}
202220
func (s *stats) print() {
	fmt.Printf("Channel,EventID,Count\n")
	for c := range s.ChannelStats {
		for eid, cnt := range s.ChannelStats[c] {
			fmt.Printf("%s,%d,%d\n", c, eid, cnt)
		}
	}
	//fmt.Printf("Total Events: %d\n", s.EventCount)
}
800393
func (api *API) GetDatacenter(dc_id string) (*Datacenter, error) {
	result := new(Datacenter)
	url := createUrl(api, datacenterPathSegment, dc_id)
	err := api.Client.Get(url, &result, http.StatusOK)
	if err != nil {
		return nil, err
	}

	return result, nil
}
212653
func printDOT(w io.Writer, rpt *Report) error {
	g, c := GetDOT(rpt)
	graph.ComposeDot(w, g, &graph.DotAttributes{}, c)
	return nil
}
187607
func printKVMs(tsv bool, kvms ...*crimson.KVM) {
	if len(kvms) > 0 {
		p := newStdoutPrinter(tsv)
		defer p.Flush()
		if !tsv {
			p.Row("Name", "VLAN", "Platform", "Datacenter", "Rack", "Description", "MAC Address", "IP Address", "State")
		}
		for _, k := range kvms {
			p.Row(k.Name, k.Vlan, k.Platform, k.Datacenter, k.Rack, k.Description, k.MacAddress, k.Ipv4, k.State)
		}
	}
}
1106704
func (a *Agent) Datacenter() (string, error) {
	// Return from cache if we have it
	if a.datacenter != "" {
		return a.datacenter, nil
	}

	// Query the agent for the DC
	_, err := a.Self()
	return a.datacenter, err
}
355959
func (rm *RoleManager) PrintRoles() error {
	line := ""
	rm.allRoles.Range(func(_, value interface{}) bool {
		if text := value.(*Role).toString(); text != "" {
			if line == "" {
				line = text
			} else {
				line += ", " + text
			}
		}
		return true
	})
	log.LogPrint(line)
	return nil
}
505031
func importDatacenters(c context.Context, configSet config.Set, platformIds map[string]int64) error {
	cfg := &configPB.Datacenters{}
	metadata := &config.Meta{}
	if err := cfgclient.Get(c, cfgclient.AsService, configSet, datacentersFilename, textproto.Message(cfg), metadata); err != nil {
		return errors.Annotate(err, "failed to load %s", datacentersFilename).Err()
	}
	logging.Infof(c, "Found %s revision %q", datacentersFilename, metadata.Revision)

	ctx := &validation.Context{Context: c}
	ctx.SetFile(datacentersFilename)
	validateDatacentersCfg(ctx, cfg)
	if err := ctx.Finalize(); err != nil {
		return errors.Annotate(err, "invalid config").Err()
	}

	// cfgs will be a map of datacenter config filename to Datacenter.
	cfgs := make(map[string]*configPB.Datacenter, len(cfg.Datacenter))
	// datacenters will be a slice of Datacenters.
	datacenters := make([]*configPB.Datacenter, 0, len(cfg.Datacenter))
	for _, datacenterFile := range cfg.Datacenter {
		datacenter := &configPB.Datacenter{}
		if err := cfgclient.Get(c, cfgclient.AsService, configSet, datacenterFile, textproto.Message(datacenter), nil); err != nil {
			return errors.Annotate(err, "failed to load datacenter config %q", datacenterFile).Err()
		}
		cfgs[datacenterFile] = datacenter
		datacenters = append(datacenters, datacenter)
		logging.Infof(c, "Found configured datacenter %q", datacenter.Name)
	}

	validateDatacenters(ctx, cfgs)
	if err := ctx.Finalize(); err != nil {
		return errors.Annotate(err, "invalid config").Err()
	}

	datacenterIds, err := model.EnsureDatacenters(c, datacenters)
	if err != nil {
		return errors.Annotate(err, "failed to ensure datacenters").Err()
	}
	rackIds, err := model.EnsureRacks(c, datacenters, datacenterIds)
	if err != nil {
		return errors.Annotate(err, "failed to ensure racks").Err()
	}
	err = model.EnsureSwitches(c, datacenters, rackIds)
	if err != nil {
		return errors.Annotate(err, "failed to ensure switches").Err()
	}
	kvmIds, err := model.EnsureKVMs(c, datacenters, platformIds, rackIds)
	if err != nil {
		return errors.Annotate(err, "failed to ensure KVMs").Err()
	}
	// KVMs must reference the rack they exist in, while racks may optionally reference
	// a KVM that serves them. Because of this bidirectional foreign key constraint in
	// the database, we must first ensure that everything about racks except their KVM
	// matches the config, then ensure that KVMs match the config, then ensure the KVM
	// referred to by each rack matches the config.
	err = model.EnsureRackKVMs(c, datacenters, kvmIds)
	if err != nil {
		return errors.Annotate(err, "failed to ensure rack KVMs").Err()
	}
	return nil
}
1012800
func GetAllDatacenter(ctx context.Context, connection *VSphereConnection) ([]*Datacenter, error) {
	var dc []*Datacenter
	finder := find.NewFinder(connection.Client, false)
	datacenters, err := finder.DatacenterList(ctx, "*")
	if err != nil {
		klog.Errorf("Failed to find the datacenter. err: %+v", err)
		return nil, err
	}
	for _, datacenter := range datacenters {
		dc = append(dc, &(Datacenter{datacenter}))
	}

	return dc, nil
}
799556
func printVLANs(tsv bool, vlans ...*crimson.VLAN) {
	if len(vlans) > 0 {
		p := newStdoutPrinter(tsv)
		defer p.Flush()
		if !tsv {
			p.Row("ID", "Alias", "Description", "State", "CIDR Block")
		}
		for _, v := range vlans {
			p.Row(v.Id, v.Alias, v.Description, v.State, v.CidrBlock)
		}
	}
}
584311
func printHeader(w io.Writer, rpt *Report) {
	fmt.Fprintln(w, weblistPageHeader)

	var labels []string
	for _, l := range legendLabels(rpt) {
		labels = append(labels, template.HTMLEscapeString(l))
	}

	fmt.Fprintf(w, `<div class="legend">%s<br>Total: %s</div>`,
		strings.Join(labels, "<br>\n"),
		rpt.formatValue(rpt.total),
	)
}
503396
func (w *Wrapper) PrintColor(ctx *ansiterm.Context, value interface{}) {
	if ctx != nil {
		ctx.Fprintf(w.TabWriter, "%v\t", value)
	} else {
		fmt.Fprintf(w, "%v\t", value)
	}
}
1349310
func printPlatforms(tsv bool, platforms ...*crimson.Platform) {
	if len(platforms) > 0 {
		p := newStdoutPrinter(tsv)
		defer p.Flush()
		if !tsv {
			p.Row("Name", "Description", "Manufacturer")
		}
		for _, plat := range platforms {
			p.Row(plat.Name, plat.Description, plat.Manufacturer)
		}
	}
}