本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/infrastructure/devicepathresolver.NewIdentityDevicePathResolver函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewIdentityDevicePathResolver函數的具體用法?Golang NewIdentityDevicePathResolver怎麽用?Golang NewIdentityDevicePathResolver使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewIdentityDevicePathResolver函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
//.........這裏部分代碼省略.........
"readlink -f /dev/vda1",
fakesys.FakeCmdResult{Stdout: "/dev/vda1"},
)
diskManager.FakeRootDevicePartitioner.GetDeviceSizeInBytesSizes["/dev/vda"] = 1024 * 1024 * 1024
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)
sigarCollector := boshsigar.NewSigarStatsCollector(&sigar.ConcreteSigar{})
vitalsService := boshvitals.NewService(sigarCollector, dirProvider)
ipResolver := boship.NewResolver(boship.NetworkInterfaceToAddrsFunc)
arping := bosharp.NewArping(runner, fs, logger, boshplatform.ArpIterations, boshplatform.ArpIterationDelay, boshplatform.ArpInterfaceCheckDelay)
interfaceConfigurationCreator := boshnet.NewInterfaceConfigurationCreator(logger)
interfaceAddrsProvider = &fakeip.FakeInterfaceAddressesProvider{}
interfaceAddressesValidator := boship.NewInterfaceAddressesValidator(interfaceAddrsProvider)
dnsValidator := boshnet.NewDNSValidator(fs)
fs.WriteFileString("/etc/resolv.conf", "8.8.8.8 4.4.4.4")
ubuntuNetManager := boshnet.NewUbuntuNetManager(fs, runner, ipResolver, interfaceConfigurationCreator, interfaceAddressesValidator, dnsValidator, arping, logger)
ubuntuCertManager := boshcert.NewUbuntuCertManager(fs, runner, 1, logger)
monitRetryable := boshplatform.NewMonitRetryable(runner)
monitRetryStrategy := boshretry.NewAttemptRetryStrategy(10, 1*time.Second, monitRetryable, logger)
devicePathResolver := devicepathresolver.NewIdentityDevicePathResolver()
routesSearcher := boshnet.NewCmdRoutesSearcher(runner)
defaultNetworkResolver = boshnet.NewDefaultNetworkResolver(routesSearcher, ipResolver)
state, err := boshplatform.NewBootstrapState(fs, "/tmp/agent_state.json")
Expect(err).NotTo(HaveOccurred())
platform = boshplatform.NewLinuxPlatform(
fs,
runner,
sigarCollector,
compressor,
copier,
dirProvider,
vitalsService,
linuxCdutil,
diskManager,
ubuntuNetManager,
ubuntuCertManager,
monitRetryStrategy,
devicePathResolver,
500*time.Millisecond,
state,
linuxOptions,
logger,
defaultNetworkResolver,
)
})
JustBeforeEach(func() {
settingsPath := filepath.Join("bosh", "settings.json")
var settings boshsettings.Settings
示例2: 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(
//.........這裏部分代碼省略.........
示例3: init
func init() {
Describe("App", func() {
var (
baseDir string
agentConfPath string
agentConfJSON string
app App
)
BeforeEach(func() {
var err error
baseDir, err = ioutil.TempDir("", "go-agent-test")
Expect(err).ToNot(HaveOccurred())
err = os.Mkdir(filepath.Join(baseDir, "bosh"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
})
BeforeEach(func() {
agentConfPath = filepath.Join(baseDir, "bosh", "agent.json")
agentConfJSON = `{
"Infrastructure": { "Settings": { "Sources": [{ "Type": "CDROM", "FileName": "/fake-file-name" }] } }
}`
settingsPath := filepath.Join(baseDir, "bosh", "settings.json")
settingsJSON := `{
"agent_id": "my-agent-id",
"blobstore": {
"options": {
"bucket_name": "george",
"encryption_key": "optional encryption key",
"access_key_id": "optional access key id",
"secret_access_key": "optional secret access key"
},
"provider": "dummy"
},
"disks": {
"ephemeral": "/dev/sdb",
"persistent": {
"vol-xxxxxx": "/dev/sdf"
},
"system": "/dev/sda1"
},
"env": {
"bosh": {
"password": "some encrypted password"
}
},
"networks": {
"netA": {
"default": ["dns", "gateway"],
"ip": "ww.ww.ww.ww",
"dns": [
"xx.xx.xx.xx",
"yy.yy.yy.yy"
]
},
"netB": {
"dns": [
"zz.zz.zz.zz"
]
}
},
"Mbus": "https://vcap:[email protected]:6868",
"ntp": [
"0.north-america.pool.ntp.org",
"1.north-america.pool.ntp.org"
],
"vm": {
"name": "vm-abc-def"
}
}`
err := ioutil.WriteFile(settingsPath, []byte(settingsJSON), 0640)
Expect(err).ToNot(HaveOccurred())
})
JustBeforeEach(func() {
err := ioutil.WriteFile(agentConfPath, []byte(agentConfJSON), 0640)
Expect(err).ToNot(HaveOccurred())
logger := boshlog.NewLogger(boshlog.LevelNone)
fakefs := boshsys.NewOsFileSystem(logger)
app = New(logger, fakefs)
})
AfterEach(func() {
os.RemoveAll(baseDir)
})
It("Sets up device path resolver on platform specific to infrastructure", func() {
err := app.Setup([]string{"bosh-agent", "-P", "dummy", "-C", agentConfPath, "-b", baseDir})
Expect(err).ToNot(HaveOccurred())
Expect(app.GetPlatform().GetDevicePathResolver()).To(Equal(devicepathresolver.NewIdentityDevicePathResolver()))
})
//.........這裏部分代碼省略.........
示例4: init
func init() {
Describe("App", func() {
var (
baseDir string
agentConfPath string
agentConfJSON string
app App
)
BeforeEach(func() {
var err error
baseDir, err = ioutil.TempDir("", "go-agent-test")
Expect(err).ToNot(HaveOccurred())
err = os.Mkdir(filepath.Join(baseDir, "bosh"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
})
BeforeEach(func() {
agentConfPath = filepath.Join(baseDir, "bosh", "agent.json")
agentConfJSON = `{
"Infrastructure": { "Settings": { "Sources": [{ "Type": "CDROM", "FileName": "/fake-file-name" }] } }
}`
settingsPath := filepath.Join(baseDir, "bosh", "settings.json")
settingsJSON := `{
"agent_id": "my-agent-id",
"blobstore": {
"options": {
"bucket_name": "george",
"encryption_key": "optional encryption key",
"access_key_id": "optional access key id",
"secret_access_key": "optional secret access key"
},
"provider": "dummy"
},
"disks": {
"ephemeral": "/dev/sdb",
"persistent": {
"vol-xxxxxx": "/dev/sdf"
},
"system": "/dev/sda1"
},
"env": {
"bosh": {
"password": "some encrypted password"
}
},
"networks": {
"netA": {
"default": ["dns", "gateway"],
"ip": "ww.ww.ww.ww",
"dns": [
"xx.xx.xx.xx",
"yy.yy.yy.yy"
]
},
"netB": {
"dns": [
"zz.zz.zz.zz"
]
}
},
"Mbus": "https://vcap:[email protected]:6868",
"ntp": [
"0.north-america.pool.ntp.org",
"1.north-america.pool.ntp.org"
],
"vm": {
"name": "vm-abc-def"
}
}`
err := ioutil.WriteFile(settingsPath, []byte(settingsJSON), 0640)
Expect(err).ToNot(HaveOccurred())
})
JustBeforeEach(func() {
err := ioutil.WriteFile(agentConfPath, []byte(agentConfJSON), 0640)
Expect(err).ToNot(HaveOccurred())
logger := boshlog.NewLogger(boshlog.LevelNone)
app = New(logger)
})
AfterEach(func() {
os.RemoveAll(baseDir)
})
It("Sets up device path resolver on platform specific to infrastructure", func() {
err := app.Setup([]string{"bosh-agent", "-P", "dummy", "-C", agentConfPath, "-b", baseDir})
Expect(err).ToNot(HaveOccurred())
Expect(app.GetPlatform().GetDevicePathResolver()).To(Equal(devicepathresolver.NewIdentityDevicePathResolver()))
})
Context("when DevicePathResolutionType is 'virtio'", func() {
//.........這裏部分代碼省略.........