當前位置: 首頁>>代碼示例>>Golang>>正文


Golang crt.CRT類代碼示例

本文整理匯總了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
}
開發者ID:shwethab,項目名稱:netplugin,代碼行數:25,代碼來源:netd.go

示例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
}
開發者ID:shwethab,項目名稱:netplugin,代碼行數:26,代碼來源:netd.go

示例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
}
開發者ID:ChengTiesheng,項目名稱:netplugin,代碼行數:22,代碼來源:lldp.go


注:本文中的github.com/contiv/netplugin/crt.CRT類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。