func NewFactory(
	settingsService boshsettings.Service,
	platform boshplatform.Platform,
	blobstore boshblob.Blobstore,
	taskService boshtask.Service,
	notifier boshnotif.Notifier,
	applier boshappl.Applier,
	compiler boshcomp.Compiler,
	jobSupervisor boshjobsuper.JobSupervisor,
	specService boshas.V1Service,
	drainScriptProvider boshdrain.DrainScriptProvider,
	logger boshlog.Logger,
) (factory Factory) {
	compressor := platform.GetCompressor()
	copier := platform.GetCopier()
	dirProvider := platform.GetDirProvider()
	vitalsService := platform.GetVitalsService()
	ntpService := boshntp.NewConcreteService(platform.GetFs(), dirProvider)

	factory = concreteFactory{
		availableActions: map[string]Action{
			// Task management
			"ping":        NewPing(),
			"get_task":    NewGetTask(taskService),
			"cancel_task": NewCancelTask(taskService),

			// VM admin
			"ssh":        NewSSH(settingsService, platform, dirProvider),
			"fetch_logs": NewFetchLogs(compressor, copier, blobstore, dirProvider),

			// Job management
			"prepare":    NewPrepare(applier),
			"apply":      NewApply(applier, specService, settingsService),
			"start":      NewStart(jobSupervisor),
			"stop":       NewStop(jobSupervisor),
			"drain":      NewDrain(notifier, specService, drainScriptProvider, jobSupervisor),
			"get_state":  NewGetState(settingsService, specService, jobSupervisor, vitalsService, ntpService),
			"run_errand": NewRunErrand(specService, dirProvider.JobsDir(), platform.GetRunner(), logger),

			// Compilation
			"compile_package":    NewCompilePackage(compiler),
			"release_apply_spec": NewReleaseApplySpec(platform),

			// Disk management
			"list_disk":    NewListDisk(settingsService, platform, logger),
			"migrate_disk": NewMigrateDisk(platform, dirProvider),
			"mount_disk":   NewMountDisk(settingsService, platform, platform, dirProvider),
			"unmount_disk": NewUnmountDisk(settingsService, platform),

			// Networking
			"prepare_network_change":     NewPrepareNetworkChange(platform.GetFs(), settingsService),
			"prepare_configure_networks": NewPrepareConfigureNetworks(platform, settingsService),
			"configure_networks":         NewConfigureNetworks(),
		},
	}
	return
}
Exemplo n.º 2
0
func NewProvider(logger boshlog.Logger, platform boshplatform.Platform) (p Provider) {
	digDnsResolver := NewDigDnsResolver(logger)

	p.infrastructures = map[string]Infrastructure{
		"aws":     p.createAwsInfrastructure("http://169.254.169.254", digDnsResolver, platform),
		"dummy":   p.createDummyInfrastructure(platform.GetFs(), platform.GetDirProvider(), platform),
		"vsphere": p.createVsphereInfrastructure(platform, logger),
	}
	return
}
Exemplo n.º 3
0
func NewProvider(logger boshlog.Logger, platform boshplatform.Platform) (p Provider) {
	metadataService := NewConcreteMetadataService(
		"http://169.254.169.254",
		NewDigDNSResolver(logger),
	)

	// Currently useServerNameAsID boolean setting is hard coded below
	// because we do not support arbitrary infrastructure configurations
	awsRegistry := NewConcreteRegistry(metadataService, false)
	openstackRegistry := NewConcreteRegistry(metadataService, true)

	fs := platform.GetFs()
	dirProvider := platform.GetDirProvider()

	mappedDevicePathResolver := boshdpresolv.NewMappedDevicePathResolver(500*time.Millisecond, fs)
	vsphereDevicePathResolver := boshdpresolv.NewVsphereDevicePathResolver(500*time.Millisecond, fs)
	dummyDevicePathResolver := boshdpresolv.NewDummyDevicePathResolver()

	awsInfrastructure := NewAwsInfrastructure(
		metadataService,
		awsRegistry,
		platform,
		mappedDevicePathResolver,
		logger,
	)

	openstackInfrastructure := NewOpenstackInfrastructure(
		metadataService,
		openstackRegistry,
		platform,
		mappedDevicePathResolver,
		logger,
	)

	p.infrastructures = map[string]Infrastructure{
		"aws":       awsInfrastructure,
		"openstack": openstackInfrastructure,
		"dummy":     NewDummyInfrastructure(fs, dirProvider, platform, dummyDevicePathResolver),
		"warden":    NewWardenInfrastructure(dirProvider, platform, dummyDevicePathResolver),
		"vsphere":   NewVsphereInfrastructure(platform, vsphereDevicePathResolver, logger),
	}
	return
}
Exemplo n.º 4
0
func NewFactory(
	settings boshsettings.Service,
	platform boshplatform.Platform,
	blobstore boshblob.Blobstore,
	taskService boshtask.Service,
	notifier boshnotif.Notifier,
	applier boshappl.Applier,
	compiler boshcomp.Compiler,
	jobSupervisor boshjobsuper.JobSupervisor,
	specService boshas.V1Service,
	drainScriptProvider boshdrain.DrainScriptProvider,
) (factory Factory) {
	compressor := platform.GetCompressor()
	copier := platform.GetCopier()
	dirProvider := platform.GetDirProvider()
	vitalsService := platform.GetVitalsService()
	ntpService := boshntp.NewConcreteService(platform.GetFs(), dirProvider)

	factory = concreteFactory{
		availableActions: map[string]Action{
			"apply":        NewApply(applier, specService),
			"drain":        NewDrain(notifier, specService, drainScriptProvider),
			"fetch_logs":   NewLogs(compressor, copier, blobstore, dirProvider),
			"get_task":     NewGetTask(taskService),
			"get_state":    NewGetState(settings, specService, jobSupervisor, vitalsService, ntpService),
			"list_disk":    NewListDisk(settings, platform),
			"migrate_disk": NewMigrateDisk(platform, dirProvider),
			"mount_disk":   NewMountDisk(settings, platform, dirProvider),
			"ping":         NewPing(),
			"prepare_network_change": NewPrepareNetworkChange(platform),
			"ssh":                NewSsh(settings, platform, dirProvider),
			"start":              NewStart(jobSupervisor),
			"stop":               NewStop(jobSupervisor),
			"unmount_disk":       NewUnmountDisk(settings, platform),
			"compile_package":    NewCompilePackage(compiler),
			"release_apply_spec": NewReleaseApplySpec(platform),
		},
	}
	return
}