// ProvisioningInfo returns the provisioning information for each given machine entity.
346174
func (p *ProvisionerAPI) ProvisioningInfo(args params.Entities) (params.ProvisioningInfoResults, error) {
	result := params.ProvisioningInfoResults{
		Results: make([]params.ProvisioningInfoResult, len(args.Entities)),
	}
	canAccess, err := p.getAuthFunc()
	if err != nil {
		return result, errors.Trace(err)
	}
	env, err := environs.GetEnviron(p.configGetter, environs.New)
	if err != nil {
		return result, errors.Annotate(err, "could not get environ")
	}
	for i, entity := range args.Entities {
		tag, err := names.ParseMachineTag(entity.Tag)
		if err != nil {
			result.Results[i].Error = common.ServerError(common.ErrPerm)
			continue
		}
		machine, err := p.getMachine(canAccess, tag)
		if err == nil {
			result.Results[i].Result, err = p.getProvisioningInfo(machine, env)
		}
		result.Results[i].Error = common.ServerError(err)
	}
	return result, nil
}
937908
func (api *APIBase) ApplicationsInfo(in params.Entities) (params.ApplicationInfoResults, error) {
	out := make([]params.ApplicationInfoResult, len(in.Entities))
	for i, one := range in.Entities {
		tag, err := names.ParseApplicationTag(one.Tag)
		if err != nil {
			out[i].Error = common.ServerError(err)
			continue
		}
		app, err := api.backend.Application(tag.Name)
		if err != nil {
			out[i].Error = common.ServerError(err)
			continue
		}

		details, err := api.getConfig(params.ApplicationGet{ApplicationName: tag.Name}, describe)
		if err != nil {
			out[i].Error = common.ServerError(err)
			continue
		}

		bindings, err := app.EndpointBindings()
		if err != nil {
			out[i].Error = common.ServerError(err)
			continue
		}

		out[i].Result = &params.ApplicationInfo{
			Tag:              tag.String(),
			Charm:            details.Charm,
			Series:           details.Series,
			Channel:          details.Channel,
			Constraints:      details.Constraints,
			Principal:        app.IsPrincipal(),
			Exposed:          app.IsExposed(),
			Remote:           app.IsRemote(),
			EndpointBindings: bindings,
		}
	}
	return params.ApplicationInfoResults{out}, nil
}
932091
func (c *Client) ModelInfo() (params.ModelInfo, error) {
	if err := c.checkCanRead(); err != nil {
		return params.ModelInfo{}, err
	}
	state := c.api.stateAccessor
	conf, err := state.ModelConfig()
	if err != nil {
		return params.ModelInfo{}, err
	}
	model, err := state.Model()
	if err != nil {
		return params.ModelInfo{}, err
	}

	info := params.ModelInfo{
		DefaultSeries:  config.PreferredSeries(conf),
		CloudTag:       names.NewCloudTag(model.Cloud()).String(),
		CloudRegion:    model.CloudRegion(),
		ProviderType:   conf.Type(),
		Name:           conf.Name(),
		Type:           string(model.Type()),
		UUID:           model.UUID(),
		OwnerTag:       model.Owner().String(),
		Life:           params.Life(model.Life().String()),
		ControllerUUID: state.ControllerTag().String(),
		IsController:   state.IsController(),
	}
	if agentVersion, exists := conf.AgentVersion(); exists {
		info.AgentVersion = &agentVersion
	}
	if tag, ok := model.CloudCredential(); ok {
		info.CloudCredentialTag = tag.String()
	}
	info.SLA = &params.ModelSLAInfo{
		Level: model.SLALevel(),
		Owner: model.SLAOwner(),
	}
	return info, nil
}
476418
func (c *ModelPresenceContext) MachineStatus(machine MachineStatusGetter) (status.StatusInfo, error) {
	machineStatus, err := machine.Status()
	if err != nil {
		return status.StatusInfo{}, err
	}

	if !canMachineBeDown(machineStatus) {
		// The machine still being provisioned - there's no point in
		// enquiring about the agent liveness.
		return machineStatus, nil
	}

	agentAlive, err := c.machinePresence(machine)
	if err != nil {
		// We don't want any presence errors affecting status.
		logger.Debugf("error determining presence for machine %s: %v", machine.Id(), err)
		return machineStatus, nil
	}
	if machine.Life() != state.Dead && !agentAlive {
		machineStatus.Status = status.Down
		machineStatus.Message = "agent is not communicating with the server"
	}
	return machineStatus, nil
}
1145379
func (vm *VM) Provision() error {
	s, err := vm.getService()
	if err != nil {
		return err
	}

	return s.provision()
}
164365
func (engine *Engine) TableInfo(bean interface{}) *Table {
	v := rValue(bean)
	return &Table{engine.autoMapType(v), engine.tbName(v)}
}
1214790
func (c *Client) Provision(ctxt context.Context, typ, name, token string) error {
	if typ != allowedRecordType {
		return errors.New("only TXT records are supported")
	}

	// check name
	if !strings.HasSuffix(name, "."+c.domain) {
		return errors.New("invalid domain")
	}
	if n := strings.TrimSuffix(name, "."+c.domain); n == "" {
		return errors.New("invalid name")
	}
	name += "."

	// no nameservers supplied, use the nameservers from the managed zone
	if c.nameservers == nil {
		mz, err := c.dnsService.ManagedZones.Get(c.projectID, c.managedZone).Context(ctxt).Do()
		if err != nil {
			return fmt.Errorf("could not retrieve nameservers for %s/%s: %v", c.projectID, c.managedZone, err)
		}

		// add port to nameservers
		ns := make([]string, len(mz.NameServers))
		for i, n := range mz.NameServers {
			ns[i] = n + ":53"
		}
		c.nameservers = ns
	}

	// create dns record
	c.logf("provisioning (type: %s, name: %s, token: %s)", typ, name, token)

	// build deletions
	deletions, err := c.buildDeletions(ctxt, typ, name)
	if err != nil {
		return err
	}

	// do change
	var chg *dns.Change
	chg, err = c.dnsService.Changes.Create(
		c.projectID, c.managedZone,
		&dns.Change{
			Deletions: deletions,
			Additions: []*dns.ResourceRecordSet{
				&dns.ResourceRecordSet{
					Type:    typ,
					Name:    name,
					Rrdatas: []string{token},
					Ttl:     1,
				},
			},
		},
	).Context(ctxt).Do()
	if err != nil {
		c.errf("unable to provision (type: %s, name: %s, token: %s): %v", typ, name, token, err)
		return err
	} /*else {
		c.logf("successfully provisioned (type: %s, name: %s, token: %s)", typ, name, token)
	}*/

	// check pending status
	for chg.Status == "pending" {
		time.Sleep(1 * time.Second)
		chg, err = c.dnsService.Changes.Get(c.projectID, c.managedZone, chg.Id).Context(ctxt).Do()
		if err != nil {
			return err
		}
	}

	var cancel func()
	ctxt, cancel = context.WithTimeout(ctxt, c.propagationWait)
	defer cancel()

	eg, ctxt := errgroup.WithContext(ctxt)
	for _, nn := range c.nameservers {
		ns := nn
		eg.Go(func() error {
			// create dnsr client and question
			cl, m := new(dnsr.Client), new(dnsr.Msg)
			m.SetQuestion(name, dnsr.TypeTXT)
			for {
				select {
				case <-ctxt.Done():
					return ctxt.Err()
				default:
					// query nameserver
					res, _, err := cl.Exchange(m, ns)
					if err == nil && len(res.Answer) > 0 {
						for _, a := range res.Answer {
							if txtRecord, ok := a.(*dnsr.TXT); ok && contains(txtRecord.Txt, token) {
								c.logf("%s has propagated to %s", name, ns)
								return nil
							}
						}
					}
					time.Sleep(c.checkDelay)
				}
			}

			return nil
		})
	}

	if err = eg.Wait(); err != nil && !c.ignorePropagationErrors {
		return err
	} else if err != nil {
		c.errf("ignored propagated error: %v", err)
	}

	time.Sleep(c.provisionDelay)

	return nil
}
330472
func (c *Client) DynoInfo(appIdentity string, dynoIdentity string) (*Dyno, error) {
	var dyno Dyno
	return &dyno, c.Get(&dyno, "/apps/"+appIdentity+"/dynos/"+dynoIdentity)
}
1106416
func (c *Client) OAuthAuthorizationInfo(oauthAuthorizationIdentity string) (*OAuthAuthorization, error) {
	var oauthAuthorization OAuthAuthorization
	return &oauthAuthorization, c.Get(&oauthAuthorization, "/oauth/authorizations/"+oauthAuthorizationIdentity)
}
817029
func (m *ModelManagerAPI) ModelInfo(args params.Entities) (params.ModelInfoResults, error) {
	results := params.ModelInfoResults{
		Results: make([]params.ModelInfoResult, len(args.Entities)),
	}

	getModelInfo := func(arg params.Entity) (params.ModelInfo, error) {
		tag, err := names.ParseModelTag(arg.Tag)
		if err != nil {
			return params.ModelInfo{}, errors.Trace(err)
		}
		return m.getModelInfo(tag)
	}

	for i, arg := range args.Entities {
		modelInfo, err := getModelInfo(arg)
		if err != nil {
			results.Results[i].Error = common.ServerError(err)
			continue
		}
		results.Results[i].Result = &modelInfo
	}
	return results, nil
}
360723
func (uow *UnitOfWork) Provision(noCache bool, parallel int) {
	uow.Targeted().Provision(noCache, parallel)
}
14840
func (s *Service) AppSetupInfo(ctx context.Context, appSetupIdentity string) (*AppSetup, error) {
	var appSetup AppSetup
	return &appSetup, s.Get(ctx, &appSetup, fmt.Sprintf("/app-setups/%v", appSetupIdentity), nil, nil)
}
918787
func (p *ProvisionerAPI) PrepareContainerInterfaceInfo(args params.Entities) (
	params.MachineNetworkConfigResults,
	error,
) {
	return p.prepareOrGetContainerInterfaceInfo(args, false)
}
650628
func (s *Service) DynoInfo(ctx context.Context, appIdentity string, dynoIdentity string) (*Dyno, error) {
	var dyno Dyno
	return &dyno, s.Get(ctx, &dyno, fmt.Sprintf("/apps/%v/dynos/%v", appIdentity, dynoIdentity), nil, nil)
}
129364
func APIInfo(ctx context.ProviderCallContext, controllerUUID, modelUUID, caCert string, apiPort int, env Environ) (*api.Info, error) {
	instanceIds, err := env.ControllerInstances(ctx, controllerUUID)
	if err != nil {
		return nil, err
	}
	logger.Debugf("ControllerInstances returned: %v", instanceIds)
	addrs, err := waitAnyInstanceAddresses(env, ctx, instanceIds)
	if err != nil {
		return nil, err
	}
	apiAddrs := network.HostPortsToStrings(
		network.AddressesWithPort(addrs, apiPort),
	)
	modelTag := names.NewModelTag(modelUUID)
	apiInfo := &api.Info{Addrs: apiAddrs, CACert: caCert, ModelTag: modelTag}
	return apiInfo, nil
}
1074246
func (s *Server) CertificateInfo() *object.HostCertificateInfo {
	info := new(object.HostCertificateInfo)
	info.FromCertificate(s.Certificate())
	return info
}
527917
func (s *Service) OAuthAuthorizationInfo(ctx context.Context, oauthAuthorizationIdentity string) (*OAuthAuthorization, error) {
	var oauthAuthorization OAuthAuthorization
	return &oauthAuthorization, s.Get(ctx, &oauthAuthorization, fmt.Sprintf("/oauth/authorizations/%v", oauthAuthorizationIdentity), nil, nil)
}