當前位置: 首頁>>代碼示例>>Golang>>正文


Golang system.NewExecCmdRunner函數代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/bosh-utils/system.NewExecCmdRunner函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewExecCmdRunner函數的具體用法?Golang NewExecCmdRunner怎麽用?Golang NewExecCmdRunner使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewExecCmdRunner函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: loadCMDRunner

func (f *factory) loadCMDRunner() boshsys.CmdRunner {
	if f.runner != nil {
		return f.runner
	}
	f.runner = boshsys.NewExecCmdRunner(f.logger)
	return f.runner
}
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:7,代碼來源:factory.go

示例2: basicDeps

func basicDeps() (boshlog.Logger, boshsys.FileSystem, boshsys.CmdRunner) {
	logger := boshlog.NewWriterLogger(boshlog.LevelDebug, os.Stderr, os.Stderr)

	fs := boshsys.NewOsFileSystem(logger)

	cmdRunner := boshsys.NewExecCmdRunner(logger)

	return logger, fs, cmdRunner
}
開發者ID:CloudCredo,項目名稱:bosh-lattice-cpi,代碼行數:9,代碼來源:main.go

示例3: basicDeps

func basicDeps() (boshlog.Logger, boshsys.FileSystem, boshsys.CmdRunner, boshuuid.Generator) {
	logger := boshlog.NewWriterLogger(boshlog.LevelDebug, os.Stderr, os.Stderr)

	fs := boshsys.NewOsFileSystem(logger)

	runner := boshsys.NewExecCmdRunner(logger)

	uuidGen := boshuuid.NewGenerator()

	return logger, fs, runner, uuidGen
}
開發者ID:pcfdev-forks,項目名稱:bosh-provisioner,代碼行數:11,代碼來源:main.go

示例4: NewSSHCmdRunner

func NewSSHCmdRunner(
	vmUsername string,
	vmIP string,
	vmPort string,
	privateKeyPath string,
	logger boshlog.Logger,
) CmdRunner {
	return &sshCmdRunner{
		vmUsername:     vmUsername,
		vmIP:           vmIP,
		vmPort:         vmPort,
		privateKeyPath: privateKeyPath,
		runner:         boshsys.NewExecCmdRunner(logger),
	}
}
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:15,代碼來源:ssh_cmd_runner.go

示例5: TestIntegration

func TestIntegration(t *testing.T) {
	RegisterFailHandler(Fail)

	BeforeSuite(func() {
		logger := boshlog.NewLogger(boshlog.LevelDebug)
		cmdRunner := boshsys.NewExecCmdRunner(logger)
		testEnvironment = NewTestEnvironment(cmdRunner)

		// Required for reverse-compatibility with older bosh-lite
		// (remove once a new warden stemcell is built).
		err := testEnvironment.ConfigureAgentForGenericInfrastructure()
		Expect(err).ToNot(HaveOccurred())
	})

	RunSpecs(t, "Integration Suite")
}
開發者ID:EMC-CMD,項目名稱:bosh-agent,代碼行數:16,代碼來源:integration_suite_test.go

示例6: NewRemoteTestEnvironment

func NewRemoteTestEnvironment(
	vmUsername string,
	vmIP string,
	vmPort string,
	privateKeyPath string,
	fileSystem boshsys.FileSystem,
	logger boshlog.Logger,
) Environment {
	return remoteTestEnvironment{
		vmUsername:     vmUsername,
		vmIP:           vmIP,
		vmPort:         vmPort,
		privateKeyPath: privateKeyPath,
		cmdRunner:      boshsys.NewExecCmdRunner(logger),
		fileSystem:     fileSystem,
	}
}
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:17,代碼來源:remote_test_environment.go

示例7: NewInstanceSSH

func NewInstanceSSH(
	vmUsername string,
	vmIP string,
	vmPort string,
	privateKeyPath string,
	instanceUsername string,
	instanceIP string,
	instancePassword string,
	fileSystem boshsys.FileSystem,
	logger boshlog.Logger,
) InstanceSSH {
	return &instanceSSH{
		vmUsername:       vmUsername,
		vmIP:             vmIP,
		vmPort:           vmPort,
		privateKeyPath:   privateKeyPath,
		instanceUsername: instanceUsername,
		instanceIP:       instanceIP,
		instancePassword: instancePassword,
		runner:           boshsys.NewExecCmdRunner(logger),
		fileSystem:       fileSystem,
	}
}
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:23,代碼來源:instance_ssh.go

示例8: NegatedFailureMessage

func (m beDirMatcher) NegatedFailureMessage(actual interface{}) string {
	return fmt.Sprintf("Expected `%s' to not be a directory", actual)
}

var _ = Describe("tarballCompressor", func() {
	var (
		dstDir     string
		cmdRunner  boshsys.CmdRunner
		fs         boshsys.FileSystem
		compressor Compressor
	)

	BeforeEach(func() {
		logger := boshlog.NewLogger(boshlog.LevelNone)
		cmdRunner = boshsys.NewExecCmdRunner(logger)
		fs = boshsys.NewOsFileSystem(logger)
		tmpDir, err := fs.TempDir("tarballCompressor-test")
		Expect(err).NotTo(HaveOccurred())
		dstDir = filepath.Join(tmpDir, "TestCompressor")
		compressor = NewTarballCompressor(cmdRunner, fs)
	})

	BeforeEach(func() {
		fs.MkdirAll(dstDir, os.ModePerm)
	})

	AfterEach(func() {
		fs.RemoveAll(dstDir)
	})
開發者ID:mattcui,項目名稱:bosh-agent,代碼行數:29,代碼來源:tarball_compressor_test.go

示例9: NewDnsUpdater

func NewDnsUpdater(cfg config.Config, log logger.Logger) *DnsUpdater {
	fs := system.NewOsFileSystem(log)
	cmdRunner := system.NewExecCmdRunner(log)
	return &DnsUpdater{cfg: cfg, logger: log, fs: fs, cmdRunner: cmdRunner}
}
開發者ID:nimbus-cloud,項目名稱:postgresql-boshrelease,代碼行數:5,代碼來源:dns.go

示例10:

			var tempDir string
			var dirProvider boshdir.Provider
			var fs boshsys.FileSystem

			BeforeEach(func() {
				if runtime.GOOS != "windows" {
					Skip("Only run on Windows")
				}

				fs = boshsys.NewOsFileSystem(log)
				var err error
				tempDir, err = fs.TempDir("")
				Expect(err).To(BeNil())
				dirProvider = boshdir.NewProvider(tempDir)
				certManager = cert.NewWindowsCertManager(fs, boshsys.NewExecCmdRunner(log), dirProvider, log)
			})

			AfterEach(func() {
				for _, thumbprint := range certThumbprints {
					cmd := exec.Command("powershell", "-Command", fmt.Sprintf(removeCertScript, `Cert:\LocalMachine\Root\`+thumbprint))
					session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
					Expect(err).To(BeNil())
					Eventually(session).Should(gexec.Exit(0))
				}
				os.RemoveAll(tempDir)
			})

			It("should create the tmpDir if doesn't exist", func() {
				_, err := os.Stat(dirProvider.TmpDir())
				fmt.Println("BEfore", dirProvider.TmpDir(), err)
開發者ID:mattcui,項目名稱:bosh-agent,代碼行數:30,代碼來源:cert_manager_test.go

示例11: NewProvider

func NewProvider(logger boshlog.Logger, dirProvider boshdirs.Provider, statsCollector boshstats.Collector, fs boshsys.FileSystem, options Options, bootstrapState *BootstrapState, clock clock.Clock) Provider {
	runner := boshsys.NewExecCmdRunner(logger)
	linuxDiskManager := boshdisk.NewLinuxDiskManager(logger, runner, fs, options.Linux.BindMountPersistentDisk)

	udev := boshudev.NewConcreteUdevDevice(runner, logger)
	linuxCdrom := boshcdrom.NewLinuxCdrom("/dev/sr0", udev, runner)
	linuxCdutil := boshcdrom.NewCdUtil(dirProvider.SettingsDir(), fs, linuxCdrom, logger)

	compressor := boshcmd.NewTarballCompressor(runner, fs)
	copier := boshcmd.NewCpCopier(runner, fs, logger)

	// Kick of stats collection as soon as possible
	statsCollector.StartCollecting(SigarStatsCollectionInterval, nil)

	vitalsService := boshvitals.NewService(statsCollector, dirProvider)

	ipResolver := boship.NewResolver(boship.NetworkInterfaceToAddrsFunc)

	arping := bosharp.NewArping(runner, fs, logger, ArpIterations, ArpIterationDelay, ArpInterfaceCheckDelay)
	interfaceConfigurationCreator := boshnet.NewInterfaceConfigurationCreator(logger)

	interfaceAddressesProvider := boship.NewSystemInterfaceAddressesProvider()
	interfaceAddressesValidator := boship.NewInterfaceAddressesValidator(interfaceAddressesProvider)
	dnsValidator := boshnet.NewDNSValidator(fs)

	centosNetManager := boshnet.NewCentosNetManager(fs, runner, ipResolver, interfaceConfigurationCreator, interfaceAddressesValidator, dnsValidator, arping, logger)
	ubuntuNetManager := boshnet.NewUbuntuNetManager(fs, runner, ipResolver, interfaceConfigurationCreator, interfaceAddressesValidator, dnsValidator, arping, logger)

	windowsNetManager := boshnet.NewWindowsNetManager(runner, interfaceConfigurationCreator, boshnet.NewMACAddressDetector(), logger, clock)

	centosCertManager := boshcert.NewCentOSCertManager(fs, runner, 0, logger)
	ubuntuCertManager := boshcert.NewUbuntuCertManager(fs, runner, 60, logger)

	routesSearcher := boshnet.NewRoutesSearcher(runner)
	defaultNetworkResolver := boshnet.NewDefaultNetworkResolver(routesSearcher, ipResolver)

	monitRetryable := NewMonitRetryable(runner)
	monitRetryStrategy := boshretry.NewAttemptRetryStrategy(10, 1*time.Second, monitRetryable, logger)

	var devicePathResolver devicepathresolver.DevicePathResolver
	switch options.Linux.DevicePathResolutionType {
	case "virtio":
		udev := boshudev.NewConcreteUdevDevice(runner, logger)
		idDevicePathResolver := devicepathresolver.NewIDDevicePathResolver(500*time.Millisecond, options.Linux.VirtioDevicePrefix, udev, fs)
		mappedDevicePathResolver := devicepathresolver.NewMappedDevicePathResolver(30000*time.Millisecond, fs)
		devicePathResolver = devicepathresolver.NewVirtioDevicePathResolver(idDevicePathResolver, mappedDevicePathResolver, logger)
	case "scsi":
		scsiIDPathResolver := devicepathresolver.NewSCSIIDDevicePathResolver(50000*time.Millisecond, fs, logger)
		scsiVolumeIDPathResolver := devicepathresolver.NewSCSIVolumeIDDevicePathResolver(500*time.Millisecond, fs)
		scsiLunPathResolver := devicepathresolver.NewSCSILunDevicePathResolver(50000*time.Millisecond, fs, logger)
		devicePathResolver = devicepathresolver.NewScsiDevicePathResolver(scsiVolumeIDPathResolver, scsiIDPathResolver, scsiLunPathResolver)
	default:
		devicePathResolver = devicepathresolver.NewIdentityDevicePathResolver()
	}

	uuidGenerator := boshuuid.NewGenerator()

	centos := NewLinuxPlatform(
		fs,
		runner,
		statsCollector,
		compressor,
		copier,
		dirProvider,
		vitalsService,
		linuxCdutil,
		linuxDiskManager,
		centosNetManager,
		centosCertManager,
		monitRetryStrategy,
		devicePathResolver,
		bootstrapState,
		options.Linux,
		logger,
		defaultNetworkResolver,
		uuidGenerator,
	)

	ubuntu := NewLinuxPlatform(
		fs,
		runner,
		statsCollector,
		compressor,
		copier,
		dirProvider,
		vitalsService,
		linuxCdutil,
		linuxDiskManager,
		ubuntuNetManager,
		ubuntuCertManager,
		monitRetryStrategy,
		devicePathResolver,
		bootstrapState,
		options.Linux,
		logger,
		defaultNetworkResolver,
		uuidGenerator,
	)

	windows := NewWindowsPlatform(
//.........這裏部分代碼省略.........
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:101,代碼來源:provider.go

示例12: Setup


//.........這裏部分代碼省略.........
	if err != nil {
		return bosherr.WrapError(err, "Getting blobstore")
	}

	monitClientProvider := boshmonit.NewProvider(app.platform, app.logger)

	monitClient, err := monitClientProvider.Get()
	if err != nil {
		return bosherr.WrapError(err, "Getting monit client")
	}

	jobSupervisorProvider := boshjobsuper.NewProvider(
		app.platform,
		monitClient,
		app.logger,
		app.dirProvider,
		mbusHandler,
	)

	jobSupervisor, err := jobSupervisorProvider.Get(opts.JobSupervisor)
	if err != nil {
		return bosherr.WrapError(err, "Getting job supervisor")
	}

	notifier := boshnotif.NewNotifier(mbusHandler)

	applier, compiler := app.buildApplierAndCompiler(app.dirProvider, blobstore, jobSupervisor)

	uuidGen := boshuuid.NewGenerator()

	taskService := boshtask.NewAsyncTaskService(uuidGen, app.logger)

	taskManager := boshtask.NewManagerProvider().NewManager(
		app.logger,
		app.platform.GetFs(),
		app.dirProvider.BoshDir(),
	)

	specFilePath := filepath.Join(app.dirProvider.BoshDir(), "spec.json")
	specService := boshas.NewConcreteV1Service(
		app.platform.GetFs(),
		specFilePath,
	)

	timeService := clock.NewClock()

	jobScriptProvider := boshscript.NewConcreteJobScriptProvider(
		app.platform.GetRunner(),
		app.platform.GetFs(),
		app.platform.GetDirProvider(),
		timeService,
		app.logger,
	)

	cmdRunner := boshsys.NewExecCmdRunner(app.logger)
	arp := bosharp.NewArp(cmdRunner, app.logger)

	actionFactory := boshaction.NewFactory(
		settingsService,
		app.platform,
		blobstore,
		taskService,
		notifier,
		applier,
		compiler,
		jobSupervisor,
		specService,
		jobScriptProvider,
		app.logger,
		arp,
	)

	actionRunner := boshaction.NewRunner()

	actionDispatcher := boshagent.NewActionDispatcher(
		app.logger,
		taskService,
		taskManager,
		actionFactory,
		actionRunner,
	)

	syslogServer := boshsyslog.NewServer(33331, net.Listen, app.logger)

	app.agent = boshagent.New(
		app.logger,
		mbusHandler,
		app.platform,
		actionDispatcher,
		jobSupervisor,
		specService,
		syslogServer,
		time.Minute,
		settingsService,
		uuidGen,
		timeService,
	)

	return nil
}
開發者ID:teddyking,項目名稱:bosh-agent,代碼行數:101,代碼來源:app.go

示例13:

		Expect(generatedContext.ID).To(Equal("unknown"))
	})

	It("it has az available in the spec", func() {
		Expect(generatedContext.AZ).To(Equal("unknown"))
	})

	It("it has bootstrap available in the spec", func() {
		Expect(generatedContext.Bootstrap).To(Equal(true))
	})

	var erbRenderer erbrenderer.ERBRenderer
	getValueFor := func(key string) string {
		logger := boshlog.NewLogger(boshlog.LevelNone)
		fs := boshsys.NewOsFileSystem(logger)
		commandRunner := boshsys.NewExecCmdRunner(logger)
		erbRenderer = erbrenderer.NewERBRenderer(fs, commandRunner, logger)

		srcFile, err := ioutil.TempFile("", "source.txt.erb")
		Expect(err).ToNot(HaveOccurred())
		defer os.Remove(srcFile.Name())

		erbContents := fmt.Sprintf("<%%= p('%s') %%>", key)
		_, err = srcFile.WriteString(erbContents)
		Expect(err).ToNot(HaveOccurred())

		destFile, err := fs.TempFile("dest.txt")
		Expect(err).ToNot(HaveOccurred())
		err = destFile.Close()
		Expect(err).ToNot(HaveOccurred())
		defer os.Remove(destFile.Name())
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:31,代碼來源:job_evaluation_context_test.go

示例14: main

func main() {
	if len(os.Args) < 2 || len(os.Args) > 3 {
		println("Usage: blt path/to/config.json [path/to/state.json]")
		os.Exit(1)
	}

	logger := boshlog.NewLogger(boshlog.LevelDebug)
	fs := boshsys.NewOsFileSystem(logger)
	cmdRunner := boshsys.NewExecCmdRunner(logger)

	config := bltconfig.NewConfig(fs)
	err := config.Load(os.Args[1])
	if err != nil {
		panic(err)
	}

	assetsProvider := bltassets.NewProvider(config.AssetsPath)

	logger.Debug("main", "Setting up environment")
	environmentProvider := bltenv.NewProvider(config, fs, cmdRunner, assetsProvider)
	environment := environmentProvider.Get()
	err = environment.Setup()
	if err != nil {
		panic(err)
	}
	defer environment.Shutdown()
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, syscall.SIGTERM)
	go func() {
		<-c
		environment.Shutdown()
		os.Exit(1)
	}()

	logger.Debug("main", "Starting deploy")

	cliRunnerFactory := bltclirunner.NewFactory(config.CliCmd, cmdRunner, fs)

	directorInfo, err := bltaction.NewDirectorInfo(environment.DirectorURL(), cliRunnerFactory)
	if err != nil {
		panic(err)
	}

	actionFactory := bltaction.NewFactory(directorInfo, fs, assetsProvider)

	prepareActionFlow := bltflow.NewFlow(1, []bltflow.ActionInfo{{Name: "prepare"}}, actionFactory, cliRunnerFactory)
	err = prepareActionFlow.Run(false)
	if err != nil {
		panic(err)
	}

	if !config.UsingLegacyManifest {
		uploadCloudConfigActionFlow := bltflow.NewFlow(2, []bltflow.ActionInfo{{Name: "upload_cloud_config"}}, actionFactory, cliRunnerFactory)
		err := uploadCloudConfigActionFlow.Run(false)
		if err != nil {
			panic(err)
		}
	}

	randomizer := bltflow.NewRandomizer(actionFactory, cliRunnerFactory, fs, logger)
	if len(os.Args) == 3 {
		err := randomizer.Configure(os.Args[2])
		if err != nil {
			panic(err)
		}
	} else {
		err := randomizer.Prepare(config.Flows, config.NumberOfDeployments)
		if err != nil {
			panic(err)
		}
	}

	doneCh := make(chan error)
	for i := 0; i < config.NumberOfDeployments; i++ {
		go func(i int) {
			doneCh <- randomizer.RunFlow(i, config.UsingLegacyManifest)
		}(i)
	}

	for i := 0; i < config.NumberOfDeployments; i++ {
		err := <-doneCh
		if err != nil {
			panic(err)
		}
	}

	println("Done!")
}
開發者ID:cloudfoundry-incubator,項目名稱:bosh-load-tests,代碼行數:89,代碼來源:main.go

示例15: main

func main() {
	if len(os.Args) < 2 || len(os.Args) > 3 {
		println("Usage: bft path/to/config.json seed")
		os.Exit(1)
	}

	logger := boshlog.NewLogger(boshlog.LevelDebug)
	fs := boshsys.NewOsFileSystem(logger)
	cmdRunner := boshsys.NewExecCmdRunner(logger)

	testConfig := bftconfig.NewConfig(fs)
	err := testConfig.Load(os.Args[1])
	if err != nil {
		panic(err)
	}

	envConfig := bltconfig.NewConfig(fs)
	err = envConfig.Load(os.Args[1])
	if err != nil {
		panic(err)
	}

	assetsProvider := bltassets.NewProvider(envConfig.AssetsPath)

	logger.Debug("main", "Setting up environment")

	environmentProvider := bltenv.NewProvider(envConfig, fs, cmdRunner, assetsProvider)
	environment := environmentProvider.Get()

	if !testConfig.GenerateManifestOnly {
		err = environment.Setup()
		if err != nil {
			panic(err)
		}
		defer environment.Shutdown()
	}

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, syscall.SIGTERM)
	go func() {
		<-c
		environment.Shutdown()
		os.Exit(1)
	}()

	cliRunnerFactory := bltclirunner.NewFactory(envConfig.CliCmd, cmdRunner, fs)

	var directorInfo bltaction.DirectorInfo
	if testConfig.GenerateManifestOnly {
		directorInfo = bltaction.DirectorInfo{
			UUID: "blah",
			URL:  "xxx",
		}
	} else {
		directorInfo, err = bltaction.NewDirectorInfo(environment.DirectorURL(), cliRunnerFactory)
	}

	if err != nil {
		panic(err)
	}
	cliRunner := cliRunnerFactory.Create()
	cliRunner.Configure()
	defer cliRunner.Clean()

	if !testConfig.GenerateManifestOnly {
		logger.Debug("main", "Preparing to deploy")
		preparer := bftdeployment.NewPreparer(directorInfo, cliRunner, fs, assetsProvider)
		err = preparer.Prepare()
		if err != nil {
			panic(err)
		}
	}

	logger.Debug("main", "Starting deploy")
	renderer := bftdeployment.NewRenderer(fs)

	var seed int64
	if len(os.Args) == 3 {
		seed, _ = strconv.ParseInt(os.Args[2], 10, 64)
	} else {
		seed = time.Now().Unix()
	}

	logger.Info("main", "Seeding with %d", seed)
	rand.Seed(seed)

	nameGenerator := bftnamegen.NewNameGenerator()
	decider := bftdecider.NewRandomDecider()

	ipPoolProvider := bftnetwork.NewIpPoolProvider()
	networksAssigner := bftnetwork.NewAssigner(testConfig.Parameters.Networks, nameGenerator, ipPoolProvider, decider, logger)
	parameterProvider := bftparam.NewParameterProvider(testConfig.Parameters, nameGenerator, decider, networksAssigner, logger)
	inputGenerator := bftdeployment.NewInputGenerator(testConfig.Parameters, parameterProvider, testConfig.NumberOfConsequentDeploys, nameGenerator, decider, logger)
	analyzer := bftanalyzer.NewAnalyzer(logger)

	deployer := bftdeployment.NewDeployer(
		cliRunner,
		directorInfo,
		renderer,
//.........這裏部分代碼省略.........
開發者ID:cloudfoundry-incubator,項目名稱:bosh-fuzz-tests,代碼行數:101,代碼來源:main.go


注:本文中的github.com/cloudfoundry/bosh-utils/system.NewExecCmdRunner函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。