Esempio n. 1
0
func (mapper *OpenContrailMapper) onVhostAdded(node *graph.Node, itf collection.Element) {
	phyItf, err := itf.GetField("physical_interface")
	if err != nil {
		return
	}

	mapper.vHost = node

	m := graph.Metadata{"Name": phyItf}
	nodes := mapper.graph.LookupChildren(mapper.root, m, graph.Metadata{"RelationType": "ownership"})
	switch {
	case len(nodes) == 0:
		logging.GetLogger().Errorf("Physical interface %s not found", phyItf)
		return
	case len(nodes) > 1:
		logging.GetLogger().Errorf("Multiple physical interfaces found : %v", nodes)
		return
	}

	mapper.linkToVhost(nodes[0])

	for _, n := range mapper.pendingLinks {
		mapper.linkToVhost(n)
	}
	mapper.pendingLinks = mapper.pendingLinks[:0]

	mapper.graph.AddMetadata(nodes[0], "MPLSUDPPort", mapper.mplsUDPPort)
}
Esempio n. 2
0
func (mapper *OpenContrailMapper) retrieveExtIDs(metadata graph.Metadata, itf collection.Element) (*ExtIDs, error) {
	name := metadata["Name"].(string)

	logging.GetLogger().Debugf("Retrieving extIDs from OpenContrail for Name: %s", name)

	port_uuid, err := itf.GetField("uuid")
	if err != nil {
		return nil, err
	}

	mac, err := itf.GetField("mac_addr")
	if err != nil {
		return nil, err
	}

	logging.GetLogger().Debugf("Interface from contrail: port: %s mac: %s", port_uuid, mac)

	e := &ExtIDs{
		IfaceID:     port_uuid,
		AttachedMac: mac,
	}

	return e, nil
}