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
}
			expectedInf := NewOpenstackInfrastructure(
				metadataService,
				registry,
				platform,
				expectedDevicePathResolver,
				logger,
			)

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

		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(),
Beispiel #3
0
func (p Provider) createVsphereInfrastructure(platform boshplatform.Platform, logger boshlog.Logger) (inf Infrastructure) {
	devicePathResolver := boshdpresolv.NewVsphereDevicePathResolver(500*time.Millisecond, platform.GetFs())
	inf = NewVsphereInfrastructure(platform, devicePathResolver, logger)
	return
}