// Provision node somehow. TODO: actual docs
328595
func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error {
	ui.Say("Provisioning with Converge")

	// bootstrapping
	if err := p.maybeBootstrap(ui, comm); err != nil {
		return err // error messages are already user-friendly
	}

	// send module directories to the remote host
	if err := p.sendModuleDirectories(ui, comm); err != nil {
		return err // error messages are already user-friendly
	}

	// apply all the modules
	if err := p.applyModules(ui, comm); err != nil {
		return err // error messages are already user-friendly
	}

	return nil
}
709968
func (p *defaultProvisioner) provisionElectron(ctx context.Context, paths Paths, s ProvisionStatus, appName, os, arch string) error {
	return p.provisionPackage(ctx, paths, s.Electron[provisionStatusElectronKey(os, arch)], p.moverElectron, "Electron", VersionElectron, paths.ElectronUnzipSrc(), paths.ElectronDirectory(), func() (err error) {
		switch os {
		case "darwin":
			if err = p.provisionElectronFinishDarwin(appName, paths); err != nil {
				return errors.Wrap(err, "finishing provisioning electron for darwin systems failed")
			}
		default:
			astilog.Debug("System doesn't require finshing provisioning electron, moving on...")
		}
		return
	})
}
1145379
func (vm *VM) Provision() error {
	s, err := vm.getService()
	if err != nil {
		return err
	}

	return s.provision()
}
409036
func (p Provider) Provides(scheme string) bool {
	for _, i := range p.Schemes {
		if i == scheme {
			return true
		}
	}
	return false
}
126100
func (c *client) Node(name string) (*Node, error) {
	out := new(Node)
	uri := fmt.Sprintf(pathNode, c.addr, name)
	err := c.get(uri, out)
	return out, err
}
458485
func (svc *googleService) provision() error {
	zone, err := svc.service.Zones.Get(svc.vm.Project, svc.vm.Zone).Do()
	if err != nil {
		return err
	}

	machineType, err := svc.service.MachineTypes.Get(svc.vm.Project, zone.Name, svc.vm.MachineType).Do()
	if err != nil {
		return err
	}

	network, err := svc.service.Networks.Get(svc.vm.Project, svc.vm.Network).Do()
	if err != nil {
		return err
	}

	// validate network
	if !network.AutoCreateSubnetworks && len(network.Subnetworks) > 0 {
		// Network appears to be in "custom" mode, so a subnetwork is required
		// libretto doesn't handle the network creation
		if svc.vm.Subnetwork == "" {
			return fmt.Errorf("a subnetwork must be specified")
		}
	}

	subnetworkSelfLink := ""
	if svc.vm.Subnetwork != "" {
		subnetwork, err := svc.service.Subnetworks.Get(svc.vm.Project, svc.vm.region(), svc.vm.Subnetwork).Do()
		if err != nil {
			return err
		}
		subnetworkSelfLink = subnetwork.SelfLink
	}

	accessconfig := googlecloud.AccessConfig{
		Name: "External NAT for Libretto",
		Type: "ONE_TO_ONE_NAT",
	}

	md := svc.getSSHKey()

	disks, err := svc.createDisks()
	if err != nil {
		return err
	}

	instance := &googlecloud.Instance{
		Name:        svc.vm.Name,
		Description: svc.vm.Description,
		Disks:       disks,
		MachineType: machineType.SelfLink,
		Metadata: &googlecloud.Metadata{
			Items: []*googlecloud.MetadataItems{
				{
					Key:   "sshKeys",
					Value: &md,
				},
			},
		},
		NetworkInterfaces: []*googlecloud.NetworkInterface{
			{
				AccessConfigs: []*googlecloud.AccessConfig{
					&accessconfig,
				},
				Network:    network.SelfLink,
				Subnetwork: subnetworkSelfLink,
				NetworkIP:  svc.vm.PrivateIPAddress,
			},
		},
		Scheduling: &googlecloud.Scheduling{
			Preemptible: svc.vm.Preemptible,
		},
		ServiceAccounts: []*googlecloud.ServiceAccount{
			{
				Email:  "default",
				Scopes: svc.vm.Scopes,
			},
		},
		Tags: &googlecloud.Tags{
			Items: svc.vm.Tags,
		},
	}

	op, err := svc.service.Instances.Insert(svc.vm.Project, zone.Name, instance).Do()
	if err != nil {
		return err
	}

	if err = svc.waitForOperationReady(op.Name); err != nil {
		return err
	}

	_, err = svc.getInstance()
	return err
}
52340
func (n *node) create(path ...nodeContent) (*node, error) {
	if len(path) == 0 || path[0].key() != n.content.key() {
		return nil, errors.New(ErrNodeNotFound, errorMessages)
	}
	if len(path) == 1 {
		return n, nil
	}
	// Check children for the next path element.
	var found *node
	for _, child := range n.children {
		if path[1].key() == child.content.key() {
			found = child
			break
		}
	}
	if found == nil {
		child, err := n.addChild(path[1])
		if err != nil {
			return nil, errors.Annotate(err, ErrNodeAddChild, errorMessages)
		}
		return child.create(path[1:]...)
	}
	return found.create(path[1:]...)
}
772922
func (p *defaultProvisioner) provisionAstilectron(ctx context.Context, paths Paths, s ProvisionStatus) error {
	return p.provisionPackage(ctx, paths, s.Astilectron, p.moverAstilectron, "Astilectron", VersionAstilectron, paths.AstilectronUnzipSrc(), paths.AstilectronDirectory(), nil)
}
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
}
460502
func (p *iscsiProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) {
	if !util.AccessModesContainedInAll(p.getAccessModes(), options.PVC.Spec.AccessModes) {
		return nil, fmt.Errorf("invalid AccessModes %v: only AccessModes %v are supported", options.PVC.Spec.AccessModes, p.getAccessModes())
	}
	log.Debugln("new provision request received for pvc: ", options.PVName)
	vol, lun, pool, err := p.createVolume(options)
	if err != nil {
		log.Warnln(err)
		return nil, err
	}
	log.Debugln("volume created with vol and lun: ", vol, lun)

	annotations := make(map[string]string)
	annotations["volume_name"] = vol
	annotations["pool"] = pool
	annotations["initiators"] = options.Parameters["initiators"]

	var portals []string
	if len(options.Parameters["portals"]) > 0 {
		portals = strings.Split(options.Parameters["portals"], ",")
	}

	pv := &v1.PersistentVolume{
		ObjectMeta: metav1.ObjectMeta{
			Name:        options.PVName,
			Labels:      map[string]string{},
			Annotations: annotations,
		},
		Spec: v1.PersistentVolumeSpec{
			PersistentVolumeReclaimPolicy: options.PersistentVolumeReclaimPolicy,
			AccessModes:                   options.PVC.Spec.AccessModes,
			Capacity: v1.ResourceList{
				v1.ResourceName(v1.ResourceStorage): options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)],
			},
			// set volumeMode from PVC Spec
			VolumeMode: options.PVC.Spec.VolumeMode,
			PersistentVolumeSource: v1.PersistentVolumeSource{
				ISCSI: &v1.ISCSIPersistentVolumeSource{
					TargetPortal:      options.Parameters["targetPortal"],
					Portals:           portals,
					IQN:               options.Parameters["iqn"],
					ISCSIInterface:    options.Parameters["iscsiInterface"],
					Lun:               lun,
					ReadOnly:          getReadOnly(options.Parameters["readonly"]),
					FSType:            getFsType(options.Parameters["fsType"]),
					DiscoveryCHAPAuth: getBool(options.Parameters["chapAuthDiscovery"]),
					SessionCHAPAuth:   getBool(options.Parameters["chapAuthSession"]),
					SecretRef:         getSecretRef(getBool(options.Parameters["chapAuthDiscovery"]), getBool(options.Parameters["chapAuthSession"]), &v1.SecretReference{Name: viper.GetString("provisioner-name") + "-chap-secret"}),
				},
			},
		},
	}
	return pv, nil
}
60364
func (c *client) NodeCreate(in *Node) (*Node, error) {
	out := new(Node)
	uri := fmt.Sprintf(pathNodes, c.addr)
	err := c.post(uri, in, out)
	return out, err
}
658430
func (p *Provider) Provide(configurationChan chan<- config.Message, pool *safe.Pool) error {
	p.configurationChan = configurationChan
	return nil
}
583667
func PatchNode(client clientset.Interface, nodeName string, patchFn func(*v1.Node)) error {
	// wait.Poll will rerun the condition function every interval function if
	// the function returns false. If the condition function returns an error
	// then the retries end and the error is returned.
	return wait.Poll(constants.APICallRetryInterval, constants.PatchNodeTimeout, PatchNodeOnce(client, nodeName, patchFn))
}
712113
func (p *efsProvisioner) Provision(options controller.VolumeOptions) (*v1.PersistentVolume, error) {
	if options.PVC.Spec.Selector != nil {
		return nil, fmt.Errorf("claim.Spec.Selector is not supported")
	}

	gidAllocate := true
	for k, v := range options.Parameters {
		switch strings.ToLower(k) {
		case "gidmin":
		// Let allocator handle
		case "gidmax":
		// Let allocator handle
		case "gidallocate":
			b, err := strconv.ParseBool(v)
			if err != nil {
				return nil, fmt.Errorf("invalid value %s for parameter %s: %v", v, k, err)
			}
			gidAllocate = b
		}
	}

	var gid *int
	if gidAllocate {
		allocate, err := p.allocator.AllocateNext(options)
		if err != nil {
			return nil, err
		}
		gid = &allocate
	}

	err := p.createVolume(p.getLocalPath(options), gid)
	if err != nil {
		return nil, err
	}

	mountOptions := []string{"vers=4.1"}
	if options.MountOptions != nil {
		mountOptions = options.MountOptions
	}

	pv := &v1.PersistentVolume{
		ObjectMeta: metav1.ObjectMeta{
			Name: options.PVName,
		},
		Spec: v1.PersistentVolumeSpec{
			PersistentVolumeReclaimPolicy: options.PersistentVolumeReclaimPolicy,
			AccessModes:                   options.PVC.Spec.AccessModes,
			Capacity: v1.ResourceList{
				v1.ResourceName(v1.ResourceStorage): options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)],
			},
			PersistentVolumeSource: v1.PersistentVolumeSource{
				NFS: &v1.NFSVolumeSource{
					Server:   p.dnsName,
					Path:     p.getRemotePath(options),
					ReadOnly: false,
				},
			},
			MountOptions: mountOptions,
		},
	}

	if gidAllocate {
		pv.ObjectMeta.Annotations = map[string]string{
			gidallocator.VolumeGidAnnotationKey: strconv.FormatInt(int64(*gid), 10),
		}
	}

	return pv, nil
}
1249458
func (e *NodeService) Put(n Node) (node Node, err error) {
	url := fmt.Sprintf("nodes/%s", n.Name)
	body, err := JSONReader(n)
	if err != nil {
		return
	}

	err = e.client.magicRequestDecoder("PUT", url, body, &node)
	return
}
109059
func (c *Client) Node() *structs.Node {
	c.configLock.RLock()
	defer c.configLock.RUnlock()
	return c.configCopy.Node
}
389914
func (b *Bundler) provisionVendorElectron(oS, arch string) error {
	return b.provisionVendorZip(astilectron.ElectronDownloadSrc(oS, arch), filepath.Join(b.pathCache, fmt.Sprintf("electron-%s-%s-%s.zip", oS, arch, astilectron.VersionElectron)), filepath.Join(b.pathVendor, zipNameElectron))
}