// handleModulePost processes creation of a new Module func (s *HoverServer) handleModulePost(r *http.Request) routeResponse { var req api.Module if err := json.NewDecoder(r.Body).Decode(&req); err != nil { panic(err) } id := s.g.NewNodeID() stub := canvas.NewNodeBase(id, -1, "stub:", strconv.Itoa(id), 1) s.g.AddNode(&stub) adapter, err := canvas.NewAdapter(req.ModuleBase, s.g, id) if err != nil { panic(err) } node := canvas.NewAdapterNode(adapter) s.adapterEntries.Add(node) node.SetID(id) s.g.RemoveNode(&stub) s.g.AddNode(node) s.patchPanel.modules.Set(strconv.Itoa(node.ID()), strconv.Itoa(node.FD())) s.recomputePolicies() entry := adapterToModuleEntry(adapter) return routeResponse{body: entry} }
func NewExtInterface(link netlink.Link) *ExtInterface { return &ExtInterface{ NodeBase: canvas.NewNodeBase(-1, -1, link.Attrs().Name, "i:", 1), link: link, } }