本文整理汇总了Golang中k8s/io/kubernetes/pkg/util/exec.Interface.LookPath方法的典型用法代码示例。如果您正苦于以下问题:Golang Interface.LookPath方法的具体用法?Golang Interface.LookPath怎么用?Golang Interface.LookPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/util/exec.Interface
的用法示例。
在下文中一共展示了Interface.LookPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findPairInterfaceOfContainerInterface
func findPairInterfaceOfContainerInterface(e exec.Interface, containerInterfaceName, containerDesc string, nsenterArgs []string) (string, error) {
nsenterPath, err := e.LookPath("nsenter")
if err != nil {
return "", err
}
ethtoolPath, err := e.LookPath("ethtool")
if err != nil {
return "", err
}
nsenterArgs = append(nsenterArgs, "-F", "--", ethtoolPath, "--statistics", containerInterfaceName)
output, err := e.Command(nsenterPath, nsenterArgs...).CombinedOutput()
if err != nil {
return "", fmt.Errorf("Unable to query interface %s of container %s: %v: %s", containerInterfaceName, containerDesc, err, string(output))
}
// look for peer_ifindex
match := ethtoolOutputRegex.FindSubmatch(output)
if match == nil {
return "", fmt.Errorf("No peer_ifindex in interface statistics for %s of container %s", containerInterfaceName, containerDesc)
}
peerIfIndex, err := strconv.Atoi(string(match[1]))
if err != nil { // seems impossible (\d+ not numeric)
return "", fmt.Errorf("peer_ifindex wasn't numeric: %s: %v", match[1], err)
}
iface, err := net.InterfaceByIndex(peerIfIndex)
if err != nil {
return "", err
}
return iface.Name, nil
}
示例2: New
// New returns a new ovs.Interface
func New(execer exec.Interface, bridge string) (*Interface, error) {
if _, err := execer.LookPath(OVS_OFCTL); err != nil {
return nil, fmt.Errorf("OVS is not installed")
}
if _, err := execer.LookPath(OVS_VSCTL); err != nil {
return nil, fmt.Errorf("OVS is not installed")
}
return &Interface{execer: execer, bridge: bridge}, nil
}