本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/settings.Network.Preconfigured方法的典型用法代碼示例。如果您正苦於以下問題:Golang Network.Preconfigured方法的具體用法?Golang Network.Preconfigured怎麽用?Golang Network.Preconfigured使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/settings.Network
的用法示例。
在下文中一共展示了Network.Preconfigured方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: describeUbuntuNetManager
//.........這裏部分代碼省略.........
Default: []string{"gateway"},
Netmask: "255.255.255.0",
Gateway: "3.4.5.6",
Mac: "fake-static-mac-address",
}
interfaceAddrsProvider.GetInterfaceAddresses = []boship.InterfaceAddress{
boship.NewSimpleInterfaceAddress("ethstatic", "1.2.3.4"),
}
fs.WriteFileString("/etc/resolv.conf", `
nameserver 8.8.8.8
nameserver 9.9.9.9
`)
expectedNetworkConfigurationForStaticAndDhcp = `# Generated by bosh-agent
auto lo
iface lo inet loopback
auto ethdhcp
iface ethdhcp inet dhcp
auto ethstatic
iface ethstatic inet static
address 1.2.3.4
network 1.2.3.0
netmask 255.255.255.0
broadcast 1.2.3.255
gateway 3.4.5.6
dns-nameservers 8.8.8.8 9.9.9.9`
})
Context("networks is preconfigured", func() {
var networks boshsettings.Networks
BeforeEach(func() {
dhcpNetwork.Preconfigured = true
staticNetwork.Preconfigured = true
networks = boshsettings.Networks{
"first": dhcpNetwork,
"second": staticNetwork,
}
Expect(networks.IsPreconfigured()).To(BeTrue())
})
Context("when there are configured DNS servers", func() {
BeforeEach(func() {
networks = boshsettings.Networks{
"first": dhcpNetwork,
}
})
It("writes DNS to /etc/resolvconf/resolv.conf.d/base", func() {
err := netManager.SetupNetworking(networks, nil)
Expect(err).ToNot(HaveOccurred())
resolvConfBase := fs.GetFileTestStat("/etc/resolvconf/resolv.conf.d/base")
Expect(resolvConfBase).ToNot(BeNil())
expectedResolvConfBase := `# Generated by bosh-agent
nameserver 8.8.8.8
nameserver 9.9.9.9
`
Expect(resolvConfBase.StringContents()).To(Equal(expectedResolvConfBase))
})
Context("when writing to ../resolv.conf.d/base fails", func() {
It("fails reporting the error", func() {