本文整理匯總了Golang中bosh/platform/fakes.FakePlatform.NormalizeDiskPathFound方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakePlatform.NormalizeDiskPathFound方法的具體用法?Golang FakePlatform.NormalizeDiskPathFound怎麽用?Golang FakePlatform.NormalizeDiskPathFound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bosh/platform/fakes.FakePlatform
的用法示例。
在下文中一共展示了FakePlatform.NormalizeDiskPathFound方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
Describe("Testing with Ginkgo", func() {
var (
vsphere Infrastructure
platform *fakeplatform.FakePlatform
)
BeforeEach(func() {
platform = fakeplatform.NewFakePlatform()
})
JustBeforeEach(func() {
vsphere = NewVsphereInfrastructure(platform)
})
It("vsphere get settings", func() {
platform.GetFileContentsFromCDROMContents = []byte(`{"agent_id": "123"}`)
settings, err := vsphere.GetSettings()
Expect(err).NotTo(HaveOccurred())
Expect(platform.GetFileContentsFromCDROMPath).To(Equal("env"))
Expect(settings.AgentId).To(Equal("123"))
})
It("vsphere setup networking", func() {
networks := boshsettings.Networks{"bosh": boshsettings.Network{}}
vsphere.SetupNetworking(networks)
Expect(platform.SetupManualNetworkingNetworks).To(Equal(networks))
})
It("vsphere get ephemeral disk path", func() {
platform.NormalizeDiskPathRealPath = "/dev/sdb"
platform.NormalizeDiskPathFound = true
realPath, found := vsphere.GetEphemeralDiskPath("does not matter")
Expect(found).To(Equal(true))
Expect(realPath).To(Equal("/dev/sdb"))
Expect(platform.NormalizeDiskPathPath).To(Equal("/dev/sdb"))
})
})
}
示例2: init
func init() {
Describe("awsInfrastructure", func() {
var (
metadataService *fakeinf.FakeMetadataService
registry *fakeinf.FakeRegistry
platform *fakeplatform.FakePlatform
devicePathResolver *fakedpresolv.FakeDevicePathResolver
aws Infrastructure
)
BeforeEach(func() {
metadataService = &fakeinf.FakeMetadataService{}
registry = &fakeinf.FakeRegistry{}
platform = fakeplatform.NewFakePlatform()
devicePathResolver = fakedpresolv.NewFakeDevicePathResolver()
logger := boshlog.NewLogger(boshlog.LevelNone)
aws = NewAwsInfrastructure(metadataService, registry, platform, devicePathResolver, logger)
})
Describe("SetupSSH", func() {
It("gets the public key and sets up ssh via the platform", func() {
metadataService.PublicKey = "fake-public-key"
err := aws.SetupSSH("vcap")
Expect(err).NotTo(HaveOccurred())
Expect(platform.SetupSSHPublicKey).To(Equal("fake-public-key"))
Expect(platform.SetupSSHUsername).To(Equal("vcap"))
})
It("returns error without configuring ssh on the platform if getting public key fails", func() {
metadataService.GetPublicKeyErr = errors.New("fake-get-public-key-err")
err := aws.SetupSSH("vcap")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-public-key-err"))
Expect(platform.SetupSSHCalled).To(BeFalse())
})
It("returns error if configuring ssh on the platform fails", func() {
platform.SetupSSHErr = errors.New("fake-setup-ssh-err")
err := aws.SetupSSH("vcap")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-setup-ssh-err"))
})
})
Describe("GetSettings", func() {
It("gets settings", func() {
settings := boshsettings.Settings{AgentID: "fake-agent-id"}
registry.Settings = settings
settings, err := aws.GetSettings()
Expect(err).ToNot(HaveOccurred())
Expect(settings).To(Equal(settings))
})
It("returns an error when registry fails to get settings", func() {
registry.GetSettingsErr = errors.New("fake-get-settings-err")
settings, err := aws.GetSettings()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-settings-err"))
Expect(settings).To(Equal(boshsettings.Settings{}))
})
})
Describe("SetupNetworking", func() {
It("sets up DHCP on the platform", func() {
networks := boshsettings.Networks{"bosh": boshsettings.Network{}}
err := aws.SetupNetworking(networks)
Expect(err).ToNot(HaveOccurred())
Expect(platform.SetupDhcpNetworks).To(Equal(networks))
})
It("returns error if configuring DHCP fails", func() {
platform.SetupDhcpErr = errors.New("fake-setup-dhcp-err")
err := aws.SetupNetworking(boshsettings.Networks{})
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-setup-dhcp-err"))
})
})
Describe("GetEphemeralDiskPath", func() {
It("returns the real disk path given an AWS EBS hint", func() {
platform.NormalizeDiskPathRealPath = "/dev/xvdb"
platform.NormalizeDiskPathFound = true
realPath, found := aws.GetEphemeralDiskPath("/dev/sdb")
Expect(found).To(Equal(true))
Expect(realPath).To(Equal("/dev/xvdb"))
Expect(platform.NormalizeDiskPathPath).To(Equal("/dev/sdb"))
//.........這裏部分代碼省略.........
示例3: init
//.........這裏部分代碼省略.........
instanceID := "123-456-789"
awsMetaDataHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expect(r.Method).To(Equal("GET"))
switch r.URL.Path {
case "/latest/user-data":
w.Write([]byte(expectedUserData))
case "/latest/meta-data/instance-id":
w.Write([]byte(instanceID))
}
})
metadataTs := httptest.NewServer(awsMetaDataHandler)
defer metadataTs.Close()
platform := fakeplatform.NewFakePlatform()
aws := NewAwsInfrastructure(metadataTs.URL, fakeDNSResolver, platform, fakeDevicePathResolver)
settings, err := aws.GetSettings()
Expect(err).NotTo(HaveOccurred())
Expect(settings).To(Equal(expectedSettings))
Expect(fakeDNSResolver.LookupHostHost).To(Equal("the.registry.name"))
Expect(fakeDNSResolver.LookupHostDNSServers).To(Equal([]string{"8.8.8.8", "9.9.9.9"}))
})
})
})
Describe("SetupNetworking", func() {
It("sets up DHCP on the platform", func() {
fakeDNSResolver := &FakeDNSResolver{}
platform := fakeplatform.NewFakePlatform()
aws := NewAwsInfrastructure("", fakeDNSResolver, platform, fakeDevicePathResolver)
networks := boshsettings.Networks{"bosh": boshsettings.Network{}}
aws.SetupNetworking(networks)
Expect(platform.SetupDhcpNetworks).To(Equal(networks))
})
})
Describe("GetEphemeralDiskPath", func() {
It("returns the real disk path given an AWS EBS hint", func() {
fakeDNSResolver := &FakeDNSResolver{}
platform := fakeplatform.NewFakePlatform()
aws := NewAwsInfrastructure("", fakeDNSResolver, platform, fakeDevicePathResolver)
platform.NormalizeDiskPathRealPath = "/dev/xvdb"
platform.NormalizeDiskPathFound = true
realPath, found := aws.GetEphemeralDiskPath("/dev/sdb")
Expect(found).To(Equal(true))
Expect(realPath).To(Equal("/dev/xvdb"))
Expect(platform.NormalizeDiskPathPath).To(Equal("/dev/sdb"))
})
})
Describe("MountPersistentDisk", func() {
It("mounts the persistent disk", func() {
fakePlatform := fakeplatform.NewFakePlatform()
fakeFormatter := fakePlatform.FakeDiskManager.FakeFormatter
fakePartitioner := fakePlatform.FakeDiskManager.FakePartitioner
fakeMounter := fakePlatform.FakeDiskManager.FakeMounter
fakePlatform.GetFs().WriteFile("/dev/vdf", []byte{})
fakeDNSResolver := &FakeDNSResolver{}
aws := NewAwsInfrastructure("", fakeDNSResolver, fakePlatform, fakeDevicePathResolver)
fakeDevicePathResolver.RealDevicePath = "/dev/vdf"
err := aws.MountPersistentDisk("/dev/sdf", "/mnt/point")
Expect(err).NotTo(HaveOccurred())
mountPoint := fakePlatform.Fs.GetFileTestStat("/mnt/point")
Expect(mountPoint.FileType).To(Equal(fakesys.FakeFileTypeDir))
Expect(mountPoint.FileMode).To(Equal(os.FileMode(0700)))
partition := fakePartitioner.PartitionPartitions[0]
Expect(fakePartitioner.PartitionDevicePath).To(Equal("/dev/vdf"))
Expect(len(fakePartitioner.PartitionPartitions)).To(Equal(1))
Expect(partition.Type).To(Equal(boshdisk.PartitionTypeLinux))
Expect(len(fakeFormatter.FormatPartitionPaths)).To(Equal(1))
Expect(fakeFormatter.FormatPartitionPaths[0]).To(Equal("/dev/vdf1"))
Expect(len(fakeFormatter.FormatFsTypes)).To(Equal(1))
Expect(fakeFormatter.FormatFsTypes[0]).To(Equal(boshdisk.FileSystemExt4))
Expect(len(fakeMounter.MountMountPoints)).To(Equal(1))
Expect(fakeMounter.MountMountPoints[0]).To(Equal("/mnt/point"))
Expect(len(fakeMounter.MountPartitionPaths)).To(Equal(1))
Expect(fakeMounter.MountPartitionPaths[0]).To(Equal("/dev/vdf1"))
})
})
})
}