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
}
		It("returns vsphere infrastructure", func() {
			expectedDevicePathResolver := boshdpresolv.NewVsphereDevicePathResolver(
				500*time.Millisecond,
				platform.GetFs(),
			)

			expectedInf := NewVsphereInfrastructure(platform, expectedDevicePathResolver, logger)

			inf, err := provider.Get("vsphere")
			Expect(err).ToNot(HaveOccurred())
			Expect(inf).To(Equal(expectedInf))
		})

		It("returns dummy infrastructure", func() {
			expectedDevicePathResolver := boshdpresolv.NewDummyDevicePathResolver()

			expectedInf := NewDummyInfrastructure(
				platform.GetFs(),
				platform.GetDirProvider(),
				platform,
				expectedDevicePathResolver,
			)

			inf, err := provider.Get("dummy")
			Expect(err).ToNot(HaveOccurred())
			Expect(inf).To(Equal(expectedInf))
		})

		It("returns warden infrastructure", func() {
			expectedDevicePathResolver := boshdpresolv.NewDummyDevicePathResolver()
Exemple #3
0
func (p Provider) createDummyInfrastructure(fs boshsys.FileSystem, dirProvider boshdir.DirectoriesProvider,
	platform boshplatform.Platform) (inf Infrastructure) {
	devicePathResolver := boshdpresolv.NewDummyDevicePathResolver(1*time.Millisecond, platform.GetFs())
	inf = NewDummyInfrastructure(fs, dirProvider, platform, devicePathResolver)
	return
}