Esempio n. 1
0
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
}
Esempio n. 2
0
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
}
Esempio n. 3
0
// 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
}