本文整理汇总了Golang中github.com/coreos/rkt/networking.Networking.GetNetworkParameters方法的典型用法代码示例。如果您正苦于以下问题:Golang Networking.GetNetworkParameters方法的具体用法?Golang Networking.GetNetworkParameters怎么用?Golang Networking.GetNetworkParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/rkt/networking.Networking
的用法示例。
在下文中一共展示了Networking.GetNetworkParameters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetKVMNetArgs
// GetKVMNetParams returns additional arguments that need to be passed to kernel and lkvm tool to configure networks properly
// parameters are based on Network configuration extracted from Networking struct
func GetKVMNetArgs(n *networking.Networking) ([]string, []string, error) {
lkvmArgs := []string{}
kernelParams := []string{}
for i, netParams := range n.GetNetworkParameters() {
// https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt
// ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>
var gw string
if netParams.IPMasq {
gw = netParams.HostIP.String()
}
kernelParams = append(kernelParams, "ip="+netParams.GuestIP.String()+"::"+gw+":"+netParams.Mask.String()+":"+fmt.Sprintf(networking.IfNamePattern, i)+":::")
lkvmArgs = append(lkvmArgs, "--network", "mode=tap,tapif="+netParams.IfName+",host_ip="+netParams.HostIP.String()+",guest_ip="+netParams.GuestIP.String())
}
return lkvmArgs, kernelParams, nil
}