本文整理匯總了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
}