本文整理汇总了Golang中github.com/contiv/netplugin/crt.CRT类的典型用法代码示例。如果您正苦于以下问题:Golang CRT类的具体用法?Golang CRT怎么用?Golang CRT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRT类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: attachContainer
func attachContainer(stateDriver core.StateDriver, crt *crt.CRT, contName string) error {
epContexts, err := getContainerEPContextByContName(stateDriver, contName)
if err != nil {
log.Errorf("Error '%s' getting Ep context for container %s \n",
err, contName)
return err
}
for _, epCtx := range epContexts {
if epCtx.NewAttachUUID != "" || epCtx.InterfaceID == "" {
log.Errorf("## skipping attach on epctx %v \n", epCtx)
continue
} else {
log.Debugf("## trying attach on epctx %v \n", epCtx)
}
err = crt.AttachEndpoint(&epCtx)
if err != nil {
log.Errorf("Error '%s' attaching container to the network \n", err)
return err
}
}
return nil
}
示例2: handleContainerStart
func handleContainerStart(netPlugin *plugin.NetPlugin, crt *crt.CRT, opts *cliOpts,
contID string) error {
// var epContexts []crtclient.ContainerEPContext
contName, err := crt.GetContainerName(contID)
if err != nil {
log.Errorf("Could not find container name from container id %s \n", contID)
return err
}
contName = strings.TrimPrefix(contName, "/")
if opts.forceDeleteEp {
err = createContainerEpOper(netPlugin, contID, contName)
if err != nil {
log.Errorf("error updating container's uuid: %v \n", err)
return err
}
}
err = attachContainer(netPlugin.StateDriver, crt, contName)
if err != nil {
log.Errorf("error attaching container: %v\n", err)
}
return err
}
示例3: FetchLLDPInfo
// FetchLLDPInfo reads the lldp information using lldptool
// A native go lib could be done but it requires that lldpad daemon is
// accessible natively on the lldp ipc path
func FetchLLDPInfo(crt *crt.CRT, ifname string) (*LLDPNeighbor, error) {
lldp := &LLDPNeighbor{}
if crt.GetContainerID(lldpadContainerName) == "" {
log.Errorf("Unable to fetch %q container information - please check if it is running", lldpadContainerName)
return nil, core.Errorf("unable to fetch container %s info", lldpadContainerName)
}
cmdWithArgs := []string{"lldptool", "-n", "-t", "-i", ifname}
output, err := crt.ExecContainer(lldpadContainerName, cmdWithArgs...)
if err != nil {
log.Errorf("Error reading lldp information. Error: %s Output: \n%s", err, output)
return nil, err
}
err = parseLLDPArgs(string(output), lldp)
return lldp, err
}