id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
8,000
contiv/netplugin
drivers/ovsd/ovsdriver.go
InspectNameserver
func (d *OvsDriver) InspectNameserver() ([]byte, error) { if d.nameServer == nil { return []byte{}, nil } ns, err := d.nameServer.InspectState() jsonState, err := json.Marshal(ns) if err != nil { log.Errorf("Error encoding nameserver state. Err: %v", err) return []byte{}, err } return jsonState, nil }
go
func (d *OvsDriver) InspectNameserver() ([]byte, error) { if d.nameServer == nil { return []byte{}, nil } ns, err := d.nameServer.InspectState() jsonState, err := json.Marshal(ns) if err != nil { log.Errorf("Error encoding nameserver state. Err: %v", err) return []byte{}, err } return jsonState, nil }
[ "func", "(", "d", "*", "OvsDriver", ")", "InspectNameserver", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "d", ".", "nameServer", "==", "nil", "{", "return", "[", "]", "byte", "{", "}", ",", "nil", "\n", "}", "\n\n", "ns", ",...
// InspectNameserver returns nameserver state as json string
[ "InspectNameserver", "returns", "nameserver", "state", "as", "json", "string" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdriver.go#L853-L866
8,001
contiv/netplugin
objdb/consulClient.go
NewClient
func (cp *consulPlugin) NewClient(endpoints []string) (API, error) { cc := new(ConsulClient) if len(endpoints) == 0 { endpoints = []string{"127.0.0.1:8500"} } // default consul config cc.consulConfig = api.Config{Address: strings.TrimPrefix(endpoints[0], "http://")} // Initialize service DB cc.serviceDb = m...
go
func (cp *consulPlugin) NewClient(endpoints []string) (API, error) { cc := new(ConsulClient) if len(endpoints) == 0 { endpoints = []string{"127.0.0.1:8500"} } // default consul config cc.consulConfig = api.Config{Address: strings.TrimPrefix(endpoints[0], "http://")} // Initialize service DB cc.serviceDb = m...
[ "func", "(", "cp", "*", "consulPlugin", ")", "NewClient", "(", "endpoints", "[", "]", "string", ")", "(", "API", ",", "error", ")", "{", "cc", ":=", "new", "(", "ConsulClient", ")", "\n\n", "if", "len", "(", "endpoints", ")", "==", "0", "{", "endpo...
// Init initializes the consul client
[ "Init", "initializes", "the", "consul", "client" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulClient.go#L52-L98
8,002
contiv/netplugin
objdb/consulClient.go
GetObj
func (cp *ConsulClient) GetObj(key string, retVal interface{}) error { key = processKey("/contiv.io/obj/" + processKey(key)) resp, _, err := cp.client.KV().Get(key, &api.QueryOptions{RequireConsistent: true}) if err != nil { if api.IsServerError(err) || strings.Contains(err.Error(), "EOF") || strings.Contains(...
go
func (cp *ConsulClient) GetObj(key string, retVal interface{}) error { key = processKey("/contiv.io/obj/" + processKey(key)) resp, _, err := cp.client.KV().Get(key, &api.QueryOptions{RequireConsistent: true}) if err != nil { if api.IsServerError(err) || strings.Contains(err.Error(), "EOF") || strings.Contains(...
[ "func", "(", "cp", "*", "ConsulClient", ")", "GetObj", "(", "key", "string", ",", "retVal", "interface", "{", "}", ")", "error", "{", "key", "=", "processKey", "(", "\"", "\"", "+", "processKey", "(", "key", ")", ")", "\n\n", "resp", ",", "_", ",",...
// GetObj reads the object
[ "GetObj", "reads", "the", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulClient.go#L106-L142
8,003
contiv/netplugin
objdb/consulClient.go
ListDir
func (cp *ConsulClient) ListDir(key string) ([]string, error) { key = processKey("/contiv.io/obj/" + processKey(key)) kvs, _, err := cp.client.KV().List(key, nil) if err != nil { if api.IsServerError(err) || strings.Contains(err.Error(), "EOF") || strings.Contains(err.Error(), "connection refused") { for i ...
go
func (cp *ConsulClient) ListDir(key string) ([]string, error) { key = processKey("/contiv.io/obj/" + processKey(key)) kvs, _, err := cp.client.KV().List(key, nil) if err != nil { if api.IsServerError(err) || strings.Contains(err.Error(), "EOF") || strings.Contains(err.Error(), "connection refused") { for i ...
[ "func", "(", "cp", "*", "ConsulClient", ")", "ListDir", "(", "key", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "key", "=", "processKey", "(", "\"", "\"", "+", "processKey", "(", "key", ")", ")", "\n\n", "kvs", ",", "_", ",", ...
// ListDir returns a list of keys in a directory
[ "ListDir", "returns", "a", "list", "of", "keys", "in", "a", "directory" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulClient.go#L145-L180
8,004
contiv/netplugin
objdb/consulClient.go
SetObj
func (cp *ConsulClient) SetObj(key string, value interface{}) error { key = processKey("/contiv.io/obj/" + processKey(key)) // JSON format the object jsonVal, err := json.Marshal(value) if err != nil { log.Errorf("Json conversion error. Err %v", err) return err } _, err = cp.client.KV().Put(&api.KVPair{Key:...
go
func (cp *ConsulClient) SetObj(key string, value interface{}) error { key = processKey("/contiv.io/obj/" + processKey(key)) // JSON format the object jsonVal, err := json.Marshal(value) if err != nil { log.Errorf("Json conversion error. Err %v", err) return err } _, err = cp.client.KV().Put(&api.KVPair{Key:...
[ "func", "(", "cp", "*", "ConsulClient", ")", "SetObj", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "key", "=", "processKey", "(", "\"", "\"", "+", "processKey", "(", "key", ")", ")", "\n\n", "// JSON format the object", ...
// SetObj writes an object
[ "SetObj", "writes", "an", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulClient.go#L183-L210
8,005
contiv/netplugin
objdb/consulClient.go
DelObj
func (cp *ConsulClient) DelObj(key string) error { key = processKey("/contiv.io/obj/" + processKey(key)) _, err := cp.client.KV().Delete(key, nil) if err != nil { if api.IsServerError(err) || strings.Contains(err.Error(), "EOF") || strings.Contains(err.Error(), "connection refused") { for i := 0; i < maxCons...
go
func (cp *ConsulClient) DelObj(key string) error { key = processKey("/contiv.io/obj/" + processKey(key)) _, err := cp.client.KV().Delete(key, nil) if err != nil { if api.IsServerError(err) || strings.Contains(err.Error(), "EOF") || strings.Contains(err.Error(), "connection refused") { for i := 0; i < maxCons...
[ "func", "(", "cp", "*", "ConsulClient", ")", "DelObj", "(", "key", "string", ")", "error", "{", "key", "=", "processKey", "(", "\"", "\"", "+", "processKey", "(", "key", ")", ")", "\n", "_", ",", "err", ":=", "cp", ".", "client", ".", "KV", "(", ...
// DelObj deletes an object
[ "DelObj", "deletes", "an", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulClient.go#L213-L232
8,006
contiv/netplugin
state/consulstatedriver.go
ClearState
func (d *ConsulStateDriver) ClearState(key string) error { key = processKey(key) _, err := d.Client.KV().Delete(key, nil) return err }
go
func (d *ConsulStateDriver) ClearState(key string) error { key = processKey(key) _, err := d.Client.KV().Delete(key, nil) return err }
[ "func", "(", "d", "*", "ConsulStateDriver", ")", "ClearState", "(", "key", "string", ")", "error", "{", "key", "=", "processKey", "(", "key", ")", "\n", "_", ",", "err", ":=", "d", ".", "Client", ".", "KV", "(", ")", ".", "Delete", "(", "key", ",...
// ClearState removes key from etcd.
[ "ClearState", "removes", "key", "from", "etcd", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/state/consulstatedriver.go#L283-L287
8,007
contiv/netplugin
state/consulstatedriver.go
ReadState
func (d *ConsulStateDriver) ReadState(key string, value core.State, unmarshal func([]byte, interface{}) error) error { key = processKey(key) encodedState, err := d.Read(key) if err != nil { return err } return unmarshal(encodedState, value) }
go
func (d *ConsulStateDriver) ReadState(key string, value core.State, unmarshal func([]byte, interface{}) error) error { key = processKey(key) encodedState, err := d.Read(key) if err != nil { return err } return unmarshal(encodedState, value) }
[ "func", "(", "d", "*", "ConsulStateDriver", ")", "ReadState", "(", "key", "string", ",", "value", "core", ".", "State", ",", "unmarshal", "func", "(", "[", "]", "byte", ",", "interface", "{", "}", ")", "error", ")", "error", "{", "key", "=", "process...
// ReadState reads key into a core.State with the unmarshaling function.
[ "ReadState", "reads", "key", "into", "a", "core", ".", "State", "with", "the", "unmarshaling", "function", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/state/consulstatedriver.go#L290-L299
8,008
contiv/netplugin
state/consulstatedriver.go
ReadAllState
func (d *ConsulStateDriver) ReadAllState(baseKey string, sType core.State, unmarshal func([]byte, interface{}) error) ([]core.State, error) { baseKey = processKey(baseKey) return readAllStateCommon(d, baseKey, sType, unmarshal) }
go
func (d *ConsulStateDriver) ReadAllState(baseKey string, sType core.State, unmarshal func([]byte, interface{}) error) ([]core.State, error) { baseKey = processKey(baseKey) return readAllStateCommon(d, baseKey, sType, unmarshal) }
[ "func", "(", "d", "*", "ConsulStateDriver", ")", "ReadAllState", "(", "baseKey", "string", ",", "sType", "core", ".", "State", ",", "unmarshal", "func", "(", "[", "]", "byte", ",", "interface", "{", "}", ")", "error", ")", "(", "[", "]", "core", ".",...
// ReadAllState Reads all the state from baseKey and returns a list of core.State.
[ "ReadAllState", "Reads", "all", "the", "state", "from", "baseKey", "and", "returns", "a", "list", "of", "core", ".", "State", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/state/consulstatedriver.go#L302-L306
8,009
contiv/netplugin
objdb/modeldb/modeldb.go
AddLink
func AddLink(link *Link, obj ModelObj) { link.ObjType = obj.GetType() link.ObjKey = obj.GetKey() }
go
func AddLink(link *Link, obj ModelObj) { link.ObjType = obj.GetType() link.ObjKey = obj.GetKey() }
[ "func", "AddLink", "(", "link", "*", "Link", ",", "obj", "ModelObj", ")", "{", "link", ".", "ObjType", "=", "obj", ".", "GetType", "(", ")", "\n", "link", ".", "ObjKey", "=", "obj", ".", "GetKey", "(", ")", "\n", "}" ]
// AddLink adds a one way link to target object
[ "AddLink", "adds", "a", "one", "way", "link", "to", "target", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L41-L44
8,010
contiv/netplugin
objdb/modeldb/modeldb.go
AddLinkSet
func AddLinkSet(linkSet *(map[string]Link), obj ModelObj) error { // Allocate the linkset if its nil if *linkSet == nil { *linkSet = make(map[string]Link) } // add the link to map (*linkSet)[obj.GetKey()] = Link{ ObjType: obj.GetType(), ObjKey: obj.GetKey(), } return nil }
go
func AddLinkSet(linkSet *(map[string]Link), obj ModelObj) error { // Allocate the linkset if its nil if *linkSet == nil { *linkSet = make(map[string]Link) } // add the link to map (*linkSet)[obj.GetKey()] = Link{ ObjType: obj.GetType(), ObjKey: obj.GetKey(), } return nil }
[ "func", "AddLinkSet", "(", "linkSet", "*", "(", "map", "[", "string", "]", "Link", ")", ",", "obj", "ModelObj", ")", "error", "{", "// Allocate the linkset if its nil", "if", "*", "linkSet", "==", "nil", "{", "*", "linkSet", "=", "make", "(", "map", "[",...
// AddLinkSet Aadds a link into linkset. initialize the linkset if required
[ "AddLinkSet", "Aadds", "a", "link", "into", "linkset", ".", "initialize", "the", "linkset", "if", "required" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L53-L66
8,011
contiv/netplugin
objdb/modeldb/modeldb.go
RemoveLinkSet
func RemoveLinkSet(linkSet *(map[string]Link), obj ModelObj) error { // check is linkset is nil if *linkSet == nil { return nil } // remove the link from map delete(*linkSet, obj.GetKey()) return nil }
go
func RemoveLinkSet(linkSet *(map[string]Link), obj ModelObj) error { // check is linkset is nil if *linkSet == nil { return nil } // remove the link from map delete(*linkSet, obj.GetKey()) return nil }
[ "func", "RemoveLinkSet", "(", "linkSet", "*", "(", "map", "[", "string", "]", "Link", ")", ",", "obj", "ModelObj", ")", "error", "{", "// check is linkset is nil", "if", "*", "linkSet", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// remove the l...
// RemoveLinkSet removes a link from linkset
[ "RemoveLinkSet", "removes", "a", "link", "from", "linkset" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L69-L79
8,012
contiv/netplugin
objdb/modeldb/modeldb.go
WriteObj
func WriteObj(objType, objKey string, value interface{}) error { key := "/modeldb/" + objType + "/" + objKey err := cdb.SetObj(key, value) if err != nil { log.Errorf("Error storing object %s. Err: %v", key, err) return err } return nil }
go
func WriteObj(objType, objKey string, value interface{}) error { key := "/modeldb/" + objType + "/" + objKey err := cdb.SetObj(key, value) if err != nil { log.Errorf("Error storing object %s. Err: %v", key, err) return err } return nil }
[ "func", "WriteObj", "(", "objType", ",", "objKey", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "key", ":=", "\"", "\"", "+", "objType", "+", "\"", "\"", "+", "objKey", "\n", "err", ":=", "cdb", ".", "SetObj", "(", "key", ",", ...
// WriteObj writes the model to DB
[ "WriteObj", "writes", "the", "model", "to", "DB" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L90-L99
8,013
contiv/netplugin
objdb/modeldb/modeldb.go
ReadObj
func ReadObj(objType, objKey string, retVal interface{}) error { key := "/modeldb/" + objType + "/" + objKey err := cdb.GetObj(key, retVal) if err != nil { log.Errorf("Error reading object: %s. Err: %v", key, err) return err } return nil }
go
func ReadObj(objType, objKey string, retVal interface{}) error { key := "/modeldb/" + objType + "/" + objKey err := cdb.GetObj(key, retVal) if err != nil { log.Errorf("Error reading object: %s. Err: %v", key, err) return err } return nil }
[ "func", "ReadObj", "(", "objType", ",", "objKey", "string", ",", "retVal", "interface", "{", "}", ")", "error", "{", "key", ":=", "\"", "\"", "+", "objType", "+", "\"", "\"", "+", "objKey", "\n", "err", ":=", "cdb", ".", "GetObj", "(", "key", ",", ...
// ReadObj reads an object from DB
[ "ReadObj", "reads", "an", "object", "from", "DB" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L102-L111
8,014
contiv/netplugin
objdb/modeldb/modeldb.go
DeleteObj
func DeleteObj(objType, objKey string) error { key := "/modeldb/" + objType + "/" + objKey err := cdb.DelObj(key) if err != nil { log.Errorf("Error deleting object: %s. Err: %v", key, err) } return nil }
go
func DeleteObj(objType, objKey string) error { key := "/modeldb/" + objType + "/" + objKey err := cdb.DelObj(key) if err != nil { log.Errorf("Error deleting object: %s. Err: %v", key, err) } return nil }
[ "func", "DeleteObj", "(", "objType", ",", "objKey", "string", ")", "error", "{", "key", ":=", "\"", "\"", "+", "objType", "+", "\"", "\"", "+", "objKey", "\n", "err", ":=", "cdb", ".", "DelObj", "(", "key", ")", "\n", "if", "err", "!=", "nil", "{...
// DeleteObj deletes and object from DB
[ "DeleteObj", "deletes", "and", "object", "from", "DB" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L114-L122
8,015
contiv/netplugin
objdb/modeldb/modeldb.go
ReadAllObj
func ReadAllObj(objType string) ([]string, error) { key := "/modeldb/" + objType + "/" return cdb.ListDir(key) }
go
func ReadAllObj(objType string) ([]string, error) { key := "/modeldb/" + objType + "/" return cdb.ListDir(key) }
[ "func", "ReadAllObj", "(", "objType", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "key", ":=", "\"", "\"", "+", "objType", "+", "\"", "\"", "\n", "return", "cdb", ".", "ListDir", "(", "key", ")", "\n", "}" ]
// ReadAllObj reads all objects of a type
[ "ReadAllObj", "reads", "all", "objects", "of", "a", "type" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/modeldb/modeldb.go#L125-L128
8,016
contiv/netplugin
netmaster/mastercfg/endpointGroupState.go
GetEndpointGroupID
func GetEndpointGroupID(stateDriver core.StateDriver, groupName, tenantName string) (int, error) { // If service name is not specified, we are done if groupName == "" { return 0, nil } epgKey := GetEndpointGroupKey(groupName, tenantName) cfgEpGroup := &EndpointGroupState{} cfgEpGroup.StateDriver = stateDriver ...
go
func GetEndpointGroupID(stateDriver core.StateDriver, groupName, tenantName string) (int, error) { // If service name is not specified, we are done if groupName == "" { return 0, nil } epgKey := GetEndpointGroupKey(groupName, tenantName) cfgEpGroup := &EndpointGroupState{} cfgEpGroup.StateDriver = stateDriver ...
[ "func", "GetEndpointGroupID", "(", "stateDriver", "core", ".", "StateDriver", ",", "groupName", ",", "tenantName", "string", ")", "(", "int", ",", "error", ")", "{", "// If service name is not specified, we are done", "if", "groupName", "==", "\"", "\"", "{", "ret...
// GetEndpointGroupID returns endpoint group Id for a service // It autocreates the endpoint group if it doesnt exist
[ "GetEndpointGroupID", "returns", "endpoint", "group", "Id", "for", "a", "service", "It", "autocreates", "the", "endpoint", "group", "if", "it", "doesnt", "exist" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/mastercfg/endpointGroupState.go#L87-L104
8,017
contiv/netplugin
netmaster/objApi/infraproxy.go
getGwCIDR
func getGwCIDR(epgObj *contivModel.EndpointGroup, stateDriver core.StateDriver) (string, error) { // get the subnet info and add it to ans nwCfg := &mastercfg.CfgNetworkState{} nwCfg.StateDriver = stateDriver networkID := epgObj.NetworkName + "." + epgObj.TenantName nErr := nwCfg.Read(networkID) if nErr != nil { ...
go
func getGwCIDR(epgObj *contivModel.EndpointGroup, stateDriver core.StateDriver) (string, error) { // get the subnet info and add it to ans nwCfg := &mastercfg.CfgNetworkState{} nwCfg.StateDriver = stateDriver networkID := epgObj.NetworkName + "." + epgObj.TenantName nErr := nwCfg.Read(networkID) if nErr != nil { ...
[ "func", "getGwCIDR", "(", "epgObj", "*", "contivModel", ".", "EndpointGroup", ",", "stateDriver", "core", ".", "StateDriver", ")", "(", "string", ",", "error", ")", "{", "// get the subnet info and add it to ans", "nwCfg", ":=", "&", "mastercfg", ".", "CfgNetworkS...
// getGwCIDR utility that reads the gw information
[ "getGwCIDR", "utility", "that", "reads", "the", "gw", "information" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/infraproxy.go#L162-L175
8,018
contiv/netplugin
netmaster/objApi/infraproxy.go
addPolicyContracts
func addPolicyContracts(csMap map[string]*contrSpec, epg *epgSpec, policy *contivModel.Policy) error { for ruleName := range policy.LinkSets.Rules { rule := contivModel.FindRule(ruleName) if rule == nil { errStr := fmt.Sprintf("rule %v not found", ruleName) return errors.New(errStr) } if rule.FromIpAdd...
go
func addPolicyContracts(csMap map[string]*contrSpec, epg *epgSpec, policy *contivModel.Policy) error { for ruleName := range policy.LinkSets.Rules { rule := contivModel.FindRule(ruleName) if rule == nil { errStr := fmt.Sprintf("rule %v not found", ruleName) return errors.New(errStr) } if rule.FromIpAdd...
[ "func", "addPolicyContracts", "(", "csMap", "map", "[", "string", "]", "*", "contrSpec", ",", "epg", "*", "epgSpec", ",", "policy", "*", "contivModel", ".", "Policy", ")", "error", "{", "for", "ruleName", ":=", "range", "policy", ".", "LinkSets", ".", "R...
// addPolicyContracts adds contracts defined by attached policy // additionally, it adds contract links from this epg to those contracts
[ "addPolicyContracts", "adds", "contracts", "defined", "by", "attached", "policy", "additionally", "it", "adds", "contract", "links", "from", "this", "epg", "to", "those", "contracts" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/infraproxy.go#L191-L235
8,019
contiv/netplugin
netmaster/objApi/infraproxy.go
CreateAppNw
func CreateAppNw(app *contivModel.AppProfile) error { aciPresent, aErr := master.IsAciConfigured() if aErr != nil { log.Errorf("Couldn't read global config %v", aErr) return aErr } if !aciPresent { log.Debugf("ACI not configured") return nil } // Get the state driver stateDriver, uErr := utils.GetState...
go
func CreateAppNw(app *contivModel.AppProfile) error { aciPresent, aErr := master.IsAciConfigured() if aErr != nil { log.Errorf("Couldn't read global config %v", aErr) return aErr } if !aciPresent { log.Debugf("ACI not configured") return nil } // Get the state driver stateDriver, uErr := utils.GetState...
[ "func", "CreateAppNw", "(", "app", "*", "contivModel", ".", "AppProfile", ")", "error", "{", "aciPresent", ",", "aErr", ":=", "master", ".", "IsAciConfigured", "(", ")", "\n", "if", "aErr", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", ...
//CreateAppNw Fill in the Nw spec and launch the nw infra
[ "CreateAppNw", "Fill", "in", "the", "Nw", "spec", "and", "launch", "the", "nw", "infra" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/infraproxy.go#L342-L408
8,020
contiv/netplugin
netmaster/objApi/infraproxy.go
DeleteAppNw
func DeleteAppNw(app *contivModel.AppProfile) error { aciPresent, aErr := master.IsAciConfigured() if aErr != nil { log.Errorf("Couldn't read global config %v", aErr) return aErr } if !aciPresent { log.Debugf("ACI not configured") return nil } ans := &appNwSpec{} ans.TenantName = app.TenantName ans.Ap...
go
func DeleteAppNw(app *contivModel.AppProfile) error { aciPresent, aErr := master.IsAciConfigured() if aErr != nil { log.Errorf("Couldn't read global config %v", aErr) return aErr } if !aciPresent { log.Debugf("ACI not configured") return nil } ans := &appNwSpec{} ans.TenantName = app.TenantName ans.Ap...
[ "func", "DeleteAppNw", "(", "app", "*", "contivModel", ".", "AppProfile", ")", "error", "{", "aciPresent", ",", "aErr", ":=", "master", ".", "IsAciConfigured", "(", ")", "\n", "if", "aErr", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", ...
//DeleteAppNw deletes the app profile from infra
[ "DeleteAppNw", "deletes", "the", "app", "profile", "from", "infra" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/infraproxy.go#L411-L440
8,021
contiv/netplugin
objdb/consulLock.go
NewLock
func (cp *ConsulClient) NewLock(name string, myID string, ttl uint64) (LockInterface, error) { // Create a lock return &consulLock{ name: name, keyName: "contiv.io/lock/" + name, myID: myID, ttl: fmt.Sprintf("%ds", ttl), eventChan: make(chan LockEvent, 1), stopChan: make(chan struct{}, ...
go
func (cp *ConsulClient) NewLock(name string, myID string, ttl uint64) (LockInterface, error) { // Create a lock return &consulLock{ name: name, keyName: "contiv.io/lock/" + name, myID: myID, ttl: fmt.Sprintf("%ds", ttl), eventChan: make(chan LockEvent, 1), stopChan: make(chan struct{}, ...
[ "func", "(", "cp", "*", "ConsulClient", ")", "NewLock", "(", "name", "string", ",", "myID", "string", ",", "ttl", "uint64", ")", "(", "LockInterface", ",", "error", ")", "{", "// Create a lock", "return", "&", "consulLock", "{", "name", ":", "name", ",",...
// NewLock returns a new lock instance
[ "NewLock", "returns", "a", "new", "lock", "instance" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulLock.go#L43-L55
8,022
contiv/netplugin
objdb/consulLock.go
IsReleased
func (lk *consulLock) IsReleased() bool { lk.mutex.Lock() defer lk.mutex.Unlock() return lk.isReleased }
go
func (lk *consulLock) IsReleased() bool { lk.mutex.Lock() defer lk.mutex.Unlock() return lk.isReleased }
[ "func", "(", "lk", "*", "consulLock", ")", "IsReleased", "(", ")", "bool", "{", "lk", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "lk", ".", "mutex", ".", "Unlock", "(", ")", "\n", "return", "lk", ".", "isReleased", "\n", "}" ]
// IsReleased Checks if the lock is released
[ "IsReleased", "Checks", "if", "the", "lock", "is", "released" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulLock.go#L151-L155
8,023
contiv/netplugin
objdb/consulLock.go
createSession
func (lk *consulLock) createSession() error { // session configuration sessCfg := api.SessionEntry{ Name: lk.keyName, Behavior: "delete", LockDelay: 10 * time.Millisecond, TTL: lk.ttl, } // Create consul session sessionID, _, err := lk.client.Session().CreateNoChecks(&sessCfg, nil) if err != ...
go
func (lk *consulLock) createSession() error { // session configuration sessCfg := api.SessionEntry{ Name: lk.keyName, Behavior: "delete", LockDelay: 10 * time.Millisecond, TTL: lk.ttl, } // Create consul session sessionID, _, err := lk.client.Session().CreateNoChecks(&sessCfg, nil) if err != ...
[ "func", "(", "lk", "*", "consulLock", ")", "createSession", "(", ")", "error", "{", "// session configuration", "sessCfg", ":=", "api", ".", "SessionEntry", "{", "Name", ":", "lk", ".", "keyName", ",", "Behavior", ":", "\"", "\"", ",", "LockDelay", ":", ...
// createSession creates a consul-session for the lock
[ "createSession", "creates", "a", "consul", "-", "session", "for", "the", "lock" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulLock.go#L256-L280
8,024
contiv/netplugin
objdb/consulLock.go
renewSession
func (lk *consulLock) renewSession() { for { err := lk.client.Session().RenewPeriodic(lk.ttl, lk.sessionID, nil, lk.stopChan) if err == nil || lk.IsReleased() { // If lock was released, exit this go routine return } // Create new consul session err = lk.createSession() if err != nil { log.Errorf(...
go
func (lk *consulLock) renewSession() { for { err := lk.client.Session().RenewPeriodic(lk.ttl, lk.sessionID, nil, lk.stopChan) if err == nil || lk.IsReleased() { // If lock was released, exit this go routine return } // Create new consul session err = lk.createSession() if err != nil { log.Errorf(...
[ "func", "(", "lk", "*", "consulLock", ")", "renewSession", "(", ")", "{", "for", "{", "err", ":=", "lk", ".", "client", ".", "Session", "(", ")", ".", "RenewPeriodic", "(", "lk", ".", "ttl", ",", "lk", ".", "sessionID", ",", "nil", ",", "lk", "."...
// renewSession keeps the session alive.. If a session expires, it creates new one..
[ "renewSession", "keeps", "the", "session", "alive", "..", "If", "a", "session", "expires", "it", "creates", "new", "one", ".." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/objdb/consulLock.go#L283-L298
8,025
contiv/netplugin
utils/stateutils.go
GetEndpoint
func GetEndpoint(epID string) (*drivers.OperEndpointState, error) { // Get hold of the state driver stateDriver, err := GetStateDriver() if err != nil { return nil, err } operEp := &drivers.OperEndpointState{} operEp.StateDriver = stateDriver err = operEp.Read(epID) if err != nil { return nil, err } ret...
go
func GetEndpoint(epID string) (*drivers.OperEndpointState, error) { // Get hold of the state driver stateDriver, err := GetStateDriver() if err != nil { return nil, err } operEp := &drivers.OperEndpointState{} operEp.StateDriver = stateDriver err = operEp.Read(epID) if err != nil { return nil, err } ret...
[ "func", "GetEndpoint", "(", "epID", "string", ")", "(", "*", "drivers", ".", "OperEndpointState", ",", "error", ")", "{", "// Get hold of the state driver", "stateDriver", ",", "err", ":=", "GetStateDriver", "(", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// GetEndpoint is a utility that reads the EP oper state
[ "GetEndpoint", "is", "a", "utility", "that", "reads", "the", "EP", "oper", "state" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/utils/stateutils.go#L9-L24
8,026
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
NewOvsdbDriver
func NewOvsdbDriver(bridgeName string, failMode string, vxlanUDPPort int) (*OvsdbDriver, error) { // Create a new driver instance d := new(OvsdbDriver) d.bridgeName = bridgeName d.vxlanUDPPort = fmt.Sprintf("%d", vxlanUDPPort) // Connect to OVS ovs, err := libovsdb.ConnectUnix("") if err != nil { log.Fatalf("...
go
func NewOvsdbDriver(bridgeName string, failMode string, vxlanUDPPort int) (*OvsdbDriver, error) { // Create a new driver instance d := new(OvsdbDriver) d.bridgeName = bridgeName d.vxlanUDPPort = fmt.Sprintf("%d", vxlanUDPPort) // Connect to OVS ovs, err := libovsdb.ConnectUnix("") if err != nil { log.Fatalf("...
[ "func", "NewOvsdbDriver", "(", "bridgeName", "string", ",", "failMode", "string", ",", "vxlanUDPPort", "int", ")", "(", "*", "OvsdbDriver", ",", "error", ")", "{", "// Create a new driver instance", "d", ":=", "new", "(", "OvsdbDriver", ")", "\n", "d", ".", ...
// NewOvsdbDriver creates a new OVSDB driver instance. // Create one ovsdb driver instance per OVS bridge that needs to be managed
[ "NewOvsdbDriver", "creates", "a", "new", "OVSDB", "driver", "instance", ".", "Create", "one", "ovsdb", "driver", "instance", "per", "OVS", "bridge", "that", "needs", "to", "be", "managed" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L49-L91
8,027
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
Update
func (d *OvsdbDriver) Update(context interface{}, tableUpdates libovsdb.TableUpdates) { d.populateCache(tableUpdates) intfUpds, ok := tableUpdates.Updates["Interface"] if !ok { return } for _, intfUpd := range intfUpds.Rows { intf := intfUpd.New.Fields["name"] oldLacpStatus, ok := intfUpd.Old.Fields["lacp_c...
go
func (d *OvsdbDriver) Update(context interface{}, tableUpdates libovsdb.TableUpdates) { d.populateCache(tableUpdates) intfUpds, ok := tableUpdates.Updates["Interface"] if !ok { return } for _, intfUpd := range intfUpds.Rows { intf := intfUpd.New.Fields["name"] oldLacpStatus, ok := intfUpd.Old.Fields["lacp_c...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "Update", "(", "context", "interface", "{", "}", ",", "tableUpdates", "libovsdb", ".", "TableUpdates", ")", "{", "d", ".", "populateCache", "(", "tableUpdates", ")", "\n", "intfUpds", ",", "ok", ":=", "tableUpdate...
// Update updates the ovsdb with the libovsdb.TableUpdates.
[ "Update", "updates", "the", "ovsdb", "with", "the", "libovsdb", ".", "TableUpdates", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L142-L170
8,028
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
createDeleteBridge
func (d *OvsdbDriver) createDeleteBridge(bridgeName, failMode string, op oper) error { namedUUIDStr := "netplugin" brUUID := []libovsdb.UUID{{GoUuid: namedUUIDStr}} protocols := []string{"OpenFlow10", "OpenFlow11", "OpenFlow12", "OpenFlow13"} opStr := "insert" if op != operCreateBridge { opStr = "delete" } //...
go
func (d *OvsdbDriver) createDeleteBridge(bridgeName, failMode string, op oper) error { namedUUIDStr := "netplugin" brUUID := []libovsdb.UUID{{GoUuid: namedUUIDStr}} protocols := []string{"OpenFlow10", "OpenFlow11", "OpenFlow12", "OpenFlow13"} opStr := "insert" if op != operCreateBridge { opStr = "delete" } //...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "createDeleteBridge", "(", "bridgeName", ",", "failMode", "string", ",", "op", "oper", ")", "error", "{", "namedUUIDStr", ":=", "\"", "\"", "\n", "brUUID", ":=", "[", "]", "libovsdb", ".", "UUID", "{", "{", "G...
// Create or delete an OVS bridge instance
[ "Create", "or", "delete", "an", "OVS", "bridge", "instance" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L212-L275
8,029
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
GetPortOrIntfNameFromID
func (d *OvsdbDriver) GetPortOrIntfNameFromID(id string, isPort bool) (string, error) { table := portTable if !isPort { table = interfaceTable } d.cacheLock.RLock() defer d.cacheLock.RUnlock() // walk thru all ports for _, row := range d.cache[table] { if extIDs, ok := row.Fields["external_ids"]; ok { e...
go
func (d *OvsdbDriver) GetPortOrIntfNameFromID(id string, isPort bool) (string, error) { table := portTable if !isPort { table = interfaceTable } d.cacheLock.RLock() defer d.cacheLock.RUnlock() // walk thru all ports for _, row := range d.cache[table] { if extIDs, ok := row.Fields["external_ids"]; ok { e...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "GetPortOrIntfNameFromID", "(", "id", "string", ",", "isPort", "bool", ")", "(", "string", ",", "error", ")", "{", "table", ":=", "portTable", "\n", "if", "!", "isPort", "{", "table", "=", "interfaceTable", "\n"...
// GetPortOrIntfNameFromID gets interface name from id
[ "GetPortOrIntfNameFromID", "gets", "interface", "name", "from", "id" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L278-L297
8,030
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
CreatePort
func (d *OvsdbDriver) CreatePort(intfName, intfType, id string, tag, burst int, bandwidth int64) error { // intfName is assumed to be unique enough to become uuid portUUIDStr := intfName intfUUIDStr := fmt.Sprintf("Intf%s", intfName) portUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}} intfUUID := []libovsdb.UUID{{G...
go
func (d *OvsdbDriver) CreatePort(intfName, intfType, id string, tag, burst int, bandwidth int64) error { // intfName is assumed to be unique enough to become uuid portUUIDStr := intfName intfUUIDStr := fmt.Sprintf("Intf%s", intfName) portUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}} intfUUID := []libovsdb.UUID{{G...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "CreatePort", "(", "intfName", ",", "intfType", ",", "id", "string", ",", "tag", ",", "burst", "int", ",", "bandwidth", "int64", ")", "error", "{", "// intfName is assumed to be unique enough to become uuid", "portUUIDStr...
// CreatePort creates an OVS port
[ "CreatePort", "creates", "an", "OVS", "port" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L300-L374
8,031
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
GetInterfacesInPort
func (d *OvsdbDriver) GetInterfacesInPort(portName string) []string { var intfList []string d.cacheLock.RLock() defer d.cacheLock.RUnlock() for _, row := range d.cache["Port"] { name := row.Fields["name"].(string) if name == portName { // Port found // Iterate over the list of interfaces switch (row.F...
go
func (d *OvsdbDriver) GetInterfacesInPort(portName string) []string { var intfList []string d.cacheLock.RLock() defer d.cacheLock.RUnlock() for _, row := range d.cache["Port"] { name := row.Fields["name"].(string) if name == portName { // Port found // Iterate over the list of interfaces switch (row.F...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "GetInterfacesInPort", "(", "portName", "string", ")", "[", "]", "string", "{", "var", "intfList", "[", "]", "string", "\n", "d", ".", "cacheLock", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "cacheLock",...
// GetInterfacesInPort gets list of interfaces in a port in sorted order
[ "GetInterfacesInPort", "gets", "list", "of", "interfaces", "in", "a", "port", "in", "sorted", "order" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L377-L411
8,032
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
GetIntfInfo
func (d *OvsdbDriver) GetIntfInfo(uuid libovsdb.UUID) libovsdb.Row { d.cacheLock.RLock() defer d.cacheLock.RUnlock() for intfUUID, row := range d.cache["Interface"] { if intfUUID == uuid { return row } } return libovsdb.Row{} }
go
func (d *OvsdbDriver) GetIntfInfo(uuid libovsdb.UUID) libovsdb.Row { d.cacheLock.RLock() defer d.cacheLock.RUnlock() for intfUUID, row := range d.cache["Interface"] { if intfUUID == uuid { return row } } return libovsdb.Row{} }
[ "func", "(", "d", "*", "OvsdbDriver", ")", "GetIntfInfo", "(", "uuid", "libovsdb", ".", "UUID", ")", "libovsdb", ".", "Row", "{", "d", ".", "cacheLock", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "cacheLock", ".", "RUnlock", "(", ")", "\n\n", ...
// GetIntfInfo gets interface information from "Interface" table
[ "GetIntfInfo", "gets", "interface", "information", "from", "Interface", "table" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L414-L425
8,033
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
CreatePortBond
func (d *OvsdbDriver) CreatePortBond(intfList []string, bondName string) error { var err error var ops []libovsdb.Operation var intfUUIDList []libovsdb.UUID opStr := "insert" // Add all the interfaces to the interface table for _, intf := range intfList { intfUUIDStr := fmt.Sprintf("Intf%s", intf) intfUUID ...
go
func (d *OvsdbDriver) CreatePortBond(intfList []string, bondName string) error { var err error var ops []libovsdb.Operation var intfUUIDList []libovsdb.UUID opStr := "insert" // Add all the interfaces to the interface table for _, intf := range intfList { intfUUIDStr := fmt.Sprintf("Intf%s", intf) intfUUID ...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "CreatePortBond", "(", "intfList", "[", "]", "string", ",", "bondName", "string", ")", "error", "{", "var", "err", "error", "\n", "var", "ops", "[", "]", "libovsdb", ".", "Operation", "\n", "var", "intfUUIDList"...
//CreatePortBond creates port bond in OVS
[ "CreatePortBond", "creates", "port", "bond", "in", "OVS" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L428-L501
8,034
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
DeletePortBond
func (d *OvsdbDriver) DeletePortBond(bondName string, intfList []string) error { var ops []libovsdb.Operation var condition []interface{} portUUIDStr := bondName portUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}} opStr := "delete" for _, intfName := range intfList { // insert/delete a row in Interface table ...
go
func (d *OvsdbDriver) DeletePortBond(bondName string, intfList []string) error { var ops []libovsdb.Operation var condition []interface{} portUUIDStr := bondName portUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}} opStr := "delete" for _, intfName := range intfList { // insert/delete a row in Interface table ...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "DeletePortBond", "(", "bondName", "string", ",", "intfList", "[", "]", "string", ")", "error", "{", "var", "ops", "[", "]", "libovsdb", ".", "Operation", "\n", "var", "condition", "[", "]", "interface", "{", ...
// DeletePortBond deletes a port bond from OVS
[ "DeletePortBond", "deletes", "a", "port", "bond", "from", "OVS" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L504-L557
8,035
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
UpdatePolicingRate
func (d *OvsdbDriver) UpdatePolicingRate(intfName string, burst int, bandwidth int64) error { bw := int(bandwidth) intf := make(map[string]interface{}) intf["ingress_policing_rate"] = bw intf["ingress_policing_burst"] = burst condition := libovsdb.NewCondition("name", "==", intfName) if condition == nil { retu...
go
func (d *OvsdbDriver) UpdatePolicingRate(intfName string, burst int, bandwidth int64) error { bw := int(bandwidth) intf := make(map[string]interface{}) intf["ingress_policing_rate"] = bw intf["ingress_policing_burst"] = burst condition := libovsdb.NewCondition("name", "==", intfName) if condition == nil { retu...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "UpdatePolicingRate", "(", "intfName", "string", ",", "burst", "int", ",", "bandwidth", "int64", ")", "error", "{", "bw", ":=", "int", "(", "bandwidth", ")", "\n", "intf", ":=", "make", "(", "map", "[", "strin...
//UpdatePolicingRate will update the ingress policing rate in interface table.
[ "UpdatePolicingRate", "will", "update", "the", "ingress", "policing", "rate", "in", "interface", "table", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L560-L580
8,036
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
CreateVtep
func (d *OvsdbDriver) CreateVtep(intfName string, vtepRemoteIP string) error { portUUIDStr := intfName intfUUIDStr := fmt.Sprintf("Intf%s", intfName) portUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}} intfUUID := []libovsdb.UUID{{GoUuid: intfUUIDStr}} opStr := "insert" intfType := "vxlan" var err error // inse...
go
func (d *OvsdbDriver) CreateVtep(intfName string, vtepRemoteIP string) error { portUUIDStr := intfName intfUUIDStr := fmt.Sprintf("Intf%s", intfName) portUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}} intfUUID := []libovsdb.UUID{{GoUuid: intfUUIDStr}} opStr := "insert" intfType := "vxlan" var err error // inse...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "CreateVtep", "(", "intfName", "string", ",", "vtepRemoteIP", "string", ")", "error", "{", "portUUIDStr", ":=", "intfName", "\n", "intfUUIDStr", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "intfName", ")", ...
// CreateVtep creates a VTEP port on the OVS
[ "CreateVtep", "creates", "a", "VTEP", "port", "on", "the", "OVS" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L632-L699
8,037
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
GetOfpPortNo
func (d *OvsdbDriver) GetOfpPortNo(intfName string) (uint32, error) { retryNo := 0 condition := libovsdb.NewCondition("name", "==", intfName) selectOp := libovsdb.Operation{ Op: "select", Table: "Interface", Where: []interface{}{condition}, } for { row, err := d.ovs.Transact(ovsDataBase, selectOp) i...
go
func (d *OvsdbDriver) GetOfpPortNo(intfName string) (uint32, error) { retryNo := 0 condition := libovsdb.NewCondition("name", "==", intfName) selectOp := libovsdb.Operation{ Op: "select", Table: "Interface", Where: []interface{}{condition}, } for { row, err := d.ovs.Transact(ovsDataBase, selectOp) i...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "GetOfpPortNo", "(", "intfName", "string", ")", "(", "uint32", ",", "error", ")", "{", "retryNo", ":=", "0", "\n", "condition", ":=", "libovsdb", ".", "NewCondition", "(", "\"", "\"", ",", "\"", "\"", ",", "...
// GetOfpPortNo returns OFP port number for an interface
[ "GetOfpPortNo", "returns", "OFP", "port", "number", "for", "an", "interface" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L828-L858
8,038
contiv/netplugin
drivers/ovsd/ovsdbDriver.go
IsVtepPresent
func (d *OvsdbDriver) IsVtepPresent(remoteIP string) (bool, string) { d.cacheLock.RLock() defer d.cacheLock.RUnlock() // walk the local cache for tName, table := range d.cache { if tName == "Interface" { for _, row := range table { options := row.Fields["options"] switch optMap := options.(type) { ...
go
func (d *OvsdbDriver) IsVtepPresent(remoteIP string) (bool, string) { d.cacheLock.RLock() defer d.cacheLock.RUnlock() // walk the local cache for tName, table := range d.cache { if tName == "Interface" { for _, row := range table { options := row.Fields["options"] switch optMap := options.(type) { ...
[ "func", "(", "d", "*", "OvsdbDriver", ")", "IsVtepPresent", "(", "remoteIP", "string", ")", "(", "bool", ",", "string", ")", "{", "d", ".", "cacheLock", ".", "RLock", "(", ")", "\n", "defer", "d", ".", "cacheLock", ".", "RUnlock", "(", ")", "\n\n", ...
// IsVtepPresent checks if VTEP already exists
[ "IsVtepPresent", "checks", "if", "VTEP", "already", "exists" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/drivers/ovsd/ovsdbDriver.go#L861-L890
8,039
contiv/netplugin
netmaster/master/netmaster.go
SetClusterMode
func SetClusterMode(cm string) error { switch cm { case core.Docker, core.Kubernetes, core.SwarmMode: case core.Test: // internal mode used for integration testing break default: return core.Errorf("%s not a valid cluster mode {%s | %s | %s}", cm, core.Docker, core.Kubernetes, core.SwarmMode) } masterRTCf...
go
func SetClusterMode(cm string) error { switch cm { case core.Docker, core.Kubernetes, core.SwarmMode: case core.Test: // internal mode used for integration testing break default: return core.Errorf("%s not a valid cluster mode {%s | %s | %s}", cm, core.Docker, core.Kubernetes, core.SwarmMode) } masterRTCf...
[ "func", "SetClusterMode", "(", "cm", "string", ")", "error", "{", "switch", "cm", "{", "case", "core", ".", "Docker", ",", "core", ".", "Kubernetes", ",", "core", ".", "SwarmMode", ":", "case", "core", ".", "Test", ":", "// internal mode used for integration...
// SetClusterMode sets the cluster mode for the contiv plugin
[ "SetClusterMode", "sets", "the", "cluster", "mode", "for", "the", "contiv", "plugin" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/netmaster.go#L44-L56
8,040
contiv/netplugin
netmaster/master/netmaster.go
CreateGlobal
func CreateGlobal(stateDriver core.StateDriver, gc *intent.ConfigGlobal) error { log.Infof("Received global create with intent {%v}", gc) var err error gcfgUpdateList := []string{} masterGc := &mastercfg.GlobConfig{} masterGc.StateDriver = stateDriver masterGc.Read("global") gstate.GlobalMutex.Lock() defer gs...
go
func CreateGlobal(stateDriver core.StateDriver, gc *intent.ConfigGlobal) error { log.Infof("Received global create with intent {%v}", gc) var err error gcfgUpdateList := []string{} masterGc := &mastercfg.GlobConfig{} masterGc.StateDriver = stateDriver masterGc.Read("global") gstate.GlobalMutex.Lock() defer gs...
[ "func", "CreateGlobal", "(", "stateDriver", "core", ".", "StateDriver", ",", "gc", "*", "intent", ".", "ConfigGlobal", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "gc", ")", "\n", "var", "err", "error", "\n", "gcfgUpdateList", ":=", "...
// CreateGlobal sets the global state
[ "CreateGlobal", "sets", "the", "global", "state" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/netmaster.go#L94-L181
8,041
contiv/netplugin
netmaster/master/netmaster.go
DeleteGlobal
func DeleteGlobal(stateDriver core.StateDriver) error { masterGc := &mastercfg.GlobConfig{} masterGc.StateDriver = stateDriver err := masterGc.Read("") if err == nil { err = masterGc.Clear() if err != nil { return err } } // Setup global state gCfg := &gstate.Cfg{} gCfg.StateDriver = stateDriver err ...
go
func DeleteGlobal(stateDriver core.StateDriver) error { masterGc := &mastercfg.GlobConfig{} masterGc.StateDriver = stateDriver err := masterGc.Read("") if err == nil { err = masterGc.Clear() if err != nil { return err } } // Setup global state gCfg := &gstate.Cfg{} gCfg.StateDriver = stateDriver err ...
[ "func", "DeleteGlobal", "(", "stateDriver", "core", ".", "StateDriver", ")", "error", "{", "masterGc", ":=", "&", "mastercfg", ".", "GlobConfig", "{", "}", "\n", "masterGc", ".", "StateDriver", "=", "stateDriver", "\n", "err", ":=", "masterGc", ".", "Read", ...
// DeleteGlobal delete global state
[ "DeleteGlobal", "delete", "global", "state" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/netmaster.go#L277-L320
8,042
contiv/netplugin
netmaster/master/netmaster.go
DeleteTenant
func DeleteTenant(stateDriver core.StateDriver, tenant *intent.ConfigTenant) error { return validateTenantConfig(tenant) }
go
func DeleteTenant(stateDriver core.StateDriver, tenant *intent.ConfigTenant) error { return validateTenantConfig(tenant) }
[ "func", "DeleteTenant", "(", "stateDriver", "core", ".", "StateDriver", ",", "tenant", "*", "intent", ".", "ConfigTenant", ")", "error", "{", "return", "validateTenantConfig", "(", "tenant", ")", "\n", "}" ]
// DeleteTenant deletes a tenant from the state store based on its ConfigTenant.
[ "DeleteTenant", "deletes", "a", "tenant", "from", "the", "state", "store", "based", "on", "its", "ConfigTenant", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/netmaster.go#L328-L330
8,043
contiv/netplugin
netmaster/master/netmaster.go
IsAciConfigured
func IsAciConfigured() (res bool, err error) { // Get the state driver stateDriver, uErr := utils.GetStateDriver() if uErr != nil { log.Warnf("Couldn't read global config %v", uErr) return false, uErr } // read global config masterGc := &mastercfg.GlobConfig{} masterGc.StateDriver = stateDriver uErr = mast...
go
func IsAciConfigured() (res bool, err error) { // Get the state driver stateDriver, uErr := utils.GetStateDriver() if uErr != nil { log.Warnf("Couldn't read global config %v", uErr) return false, uErr } // read global config masterGc := &mastercfg.GlobConfig{} masterGc.StateDriver = stateDriver uErr = mast...
[ "func", "IsAciConfigured", "(", ")", "(", "res", "bool", ",", "err", "error", ")", "{", "// Get the state driver", "stateDriver", ",", "uErr", ":=", "utils", ".", "GetStateDriver", "(", ")", "\n", "if", "uErr", "!=", "nil", "{", "log", ".", "Warnf", "(",...
// IsAciConfigured returns true if aci is configured on netmaster.
[ "IsAciConfigured", "returns", "true", "if", "aci", "is", "configured", "on", "netmaster", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/netmaster.go#L333-L361
8,044
contiv/netplugin
netmaster/daemon/utils.go
getVersion
func getVersion(w http.ResponseWriter, r *http.Request) { ver := version.Get() resp, err := json.Marshal(ver) if err != nil { http.Error(w, core.Errorf("marshaling json failed. Error: %s", err).Error(), http.StatusInternalServerError) return } w.Write(resp) return }
go
func getVersion(w http.ResponseWriter, r *http.Request) { ver := version.Get() resp, err := json.Marshal(ver) if err != nil { http.Error(w, core.Errorf("marshaling json failed. Error: %s", err).Error(), http.StatusInternalServerError) return } w.Write(resp) return }
[ "func", "getVersion", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "ver", ":=", "version", ".", "Get", "(", ")", "\n\n", "resp", ",", "err", ":=", "json", ".", "Marshal", "(", "ver", ")", "\n", "if", "...
// get current version
[ "get", "current", "version" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/utils.go#L36-L48
8,045
contiv/netplugin
netmaster/daemon/utils.go
slaveProxyHandler
func slaveProxyHandler(w http.ResponseWriter, r *http.Request) { log.Infof("proxy handler for %q ", r.URL.Path) localIP, err := netutils.GetDefaultAddr() if err != nil { log.Fatalf("Error getting local IP address. Err: %v", err) } // get current holder of master lock masterNode := leaderLock.GetHolder() if m...
go
func slaveProxyHandler(w http.ResponseWriter, r *http.Request) { log.Infof("proxy handler for %q ", r.URL.Path) localIP, err := netutils.GetDefaultAddr() if err != nil { log.Fatalf("Error getting local IP address. Err: %v", err) } // get current holder of master lock masterNode := leaderLock.GetHolder() if m...
[ "func", "slaveProxyHandler", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "r", ".", "URL", ".", "Path", ")", "\n\n", "localIP", ",", "err", ":=", "netutils", "....
// slaveProxyHandler redirects to current master
[ "slaveProxyHandler", "redirects", "to", "current", "master" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/utils.go#L51-L84
8,046
contiv/netplugin
netmaster/mastercfg/endpointstate.go
ReadAll
func (s *CfgEndpointState) ReadAll() ([]core.State, error) { return s.StateDriver.ReadAllState(endpointConfigPathPrefix, s, json.Unmarshal) }
go
func (s *CfgEndpointState) ReadAll() ([]core.State, error) { return s.StateDriver.ReadAllState(endpointConfigPathPrefix, s, json.Unmarshal) }
[ "func", "(", "s", "*", "CfgEndpointState", ")", "ReadAll", "(", ")", "(", "[", "]", "core", ".", "State", ",", "error", ")", "{", "return", "s", ".", "StateDriver", ".", "ReadAllState", "(", "endpointConfigPathPrefix", ",", "s", ",", "json", ".", "Unma...
// ReadAll reads all state objects for the endpoints.
[ "ReadAll", "reads", "all", "state", "objects", "for", "the", "endpoints", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/mastercfg/endpointstate.go#L58-L60
8,047
contiv/netplugin
netmaster/mastercfg/endpointstate.go
WatchAll
func (s *CfgEndpointState) WatchAll(rsps chan core.WatchState) error { return s.StateDriver.WatchAllState(endpointConfigPathPrefix, s, json.Unmarshal, rsps) }
go
func (s *CfgEndpointState) WatchAll(rsps chan core.WatchState) error { return s.StateDriver.WatchAllState(endpointConfigPathPrefix, s, json.Unmarshal, rsps) }
[ "func", "(", "s", "*", "CfgEndpointState", ")", "WatchAll", "(", "rsps", "chan", "core", ".", "WatchState", ")", "error", "{", "return", "s", ".", "StateDriver", ".", "WatchAllState", "(", "endpointConfigPathPrefix", ",", "s", ",", "json", ".", "Unmarshal", ...
// WatchAll fills a channel on each state event related to endpoints.
[ "WatchAll", "fills", "a", "channel", "on", "each", "state", "event", "related", "to", "endpoints", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/mastercfg/endpointstate.go#L63-L66
8,048
contiv/netplugin
netmaster/daemon/daemon.go
Init
func (d *MasterDaemon) Init() { // set cluster mode err := master.SetClusterMode(d.ClusterMode) if err != nil { log.Fatalf("Failed to set cluster-mode %q. Error: %s", d.ClusterMode, err) } // initialize state driver d.stateDriver, err = utils.NewStateDriver(d.ClusterStoreDriver, &core.InstanceInfo{DbURL: d.Clu...
go
func (d *MasterDaemon) Init() { // set cluster mode err := master.SetClusterMode(d.ClusterMode) if err != nil { log.Fatalf("Failed to set cluster-mode %q. Error: %s", d.ClusterMode, err) } // initialize state driver d.stateDriver, err = utils.NewStateDriver(d.ClusterStoreDriver, &core.InstanceInfo{DbURL: d.Clu...
[ "func", "(", "d", "*", "MasterDaemon", ")", "Init", "(", ")", "{", "// set cluster mode", "err", ":=", "master", ".", "SetClusterMode", "(", "d", ".", "ClusterMode", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ","...
// Init initializes the master daemon
[ "Init", "initializes", "the", "master", "daemon" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L74-L98
8,049
contiv/netplugin
netmaster/daemon/daemon.go
agentDiscoveryLoop
func (d *MasterDaemon) agentDiscoveryLoop() { // Create channels for watch thread agentEventCh := make(chan objdb.WatchServiceEvent, 1) watchStopCh := make(chan bool, 1) // Start a watch on netplugin service err := d.objdbClient.WatchService("netplugin", agentEventCh, watchStopCh) if err != nil { log.Fatalf("...
go
func (d *MasterDaemon) agentDiscoveryLoop() { // Create channels for watch thread agentEventCh := make(chan objdb.WatchServiceEvent, 1) watchStopCh := make(chan bool, 1) // Start a watch on netplugin service err := d.objdbClient.WatchService("netplugin", agentEventCh, watchStopCh) if err != nil { log.Fatalf("...
[ "func", "(", "d", "*", "MasterDaemon", ")", "agentDiscoveryLoop", "(", ")", "{", "// Create channels for watch thread", "agentEventCh", ":=", "make", "(", "chan", "objdb", ".", "WatchServiceEvent", ",", "1", ")", "\n", "watchStopCh", ":=", "make", "(", "chan", ...
// Find all netplugin nodes and add them to ofnet master
[ "Find", "all", "netplugin", "nodes", "and", "add", "them", "to", "ofnet", "master" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L141-L178
8,050
contiv/netplugin
netmaster/daemon/daemon.go
getPluginAddress
func (d *MasterDaemon) getPluginAddress(hostName string) (string, error) { srvList, err := d.objdbClient.GetService("netplugin.vtep") if err != nil { log.Errorf("Error getting netplugin nodes. Err: %v", err) return "", err } for _, srv := range srvList { if srv.Hostname == hostName { return srv.HostAddr, ...
go
func (d *MasterDaemon) getPluginAddress(hostName string) (string, error) { srvList, err := d.objdbClient.GetService("netplugin.vtep") if err != nil { log.Errorf("Error getting netplugin nodes. Err: %v", err) return "", err } for _, srv := range srvList { if srv.Hostname == hostName { return srv.HostAddr, ...
[ "func", "(", "d", "*", "MasterDaemon", ")", "getPluginAddress", "(", "hostName", "string", ")", "(", "string", ",", "error", ")", "{", "srvList", ",", "err", ":=", "d", ".", "objdbClient", ".", "GetService", "(", "\"", "\"", ")", "\n", "if", "err", "...
// getPluginAddress gets the adrress of the netplugin agent given the host name
[ "getPluginAddress", "gets", "the", "adrress", "of", "the", "netplugin", "agent", "given", "the", "host", "name" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L215-L229
8,051
contiv/netplugin
netmaster/daemon/daemon.go
ClearEndpoints
func (d *MasterDaemon) ClearEndpoints(stateDriver core.StateDriver, epCfgs *[]core.State, id, matchField string) error { for _, epCfg := range *epCfgs { ep := epCfg.(*mastercfg.CfgEndpointState) if (matchField == "net" && ep.NetID == id) || (matchField == "group" && ep.ServiceName == id) || (matchField == "e...
go
func (d *MasterDaemon) ClearEndpoints(stateDriver core.StateDriver, epCfgs *[]core.State, id, matchField string) error { for _, epCfg := range *epCfgs { ep := epCfg.(*mastercfg.CfgEndpointState) if (matchField == "net" && ep.NetID == id) || (matchField == "group" && ep.ServiceName == id) || (matchField == "e...
[ "func", "(", "d", "*", "MasterDaemon", ")", "ClearEndpoints", "(", "stateDriver", "core", ".", "StateDriver", ",", "epCfgs", "*", "[", "]", "core", ".", "State", ",", "id", ",", "matchField", "string", ")", "error", "{", "for", "_", ",", "epCfg", ":=",...
// ClearEndpoints clears all the endpoints
[ "ClearEndpoints", "clears", "all", "the", "endpoints" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L232-L258
8,052
contiv/netplugin
netmaster/daemon/daemon.go
runLeader
func (d *MasterDaemon) runLeader() { router := mux.NewRouter() // Create a new api controller apiConfig := &objApi.APIControllerConfig{ NetForwardMode: d.NetForwardMode, NetInfraType: d.NetInfraType, } d.apiController = objApi.NewAPIController(router, d.objdbClient, apiConfig) //Restore state from cluster...
go
func (d *MasterDaemon) runLeader() { router := mux.NewRouter() // Create a new api controller apiConfig := &objApi.APIControllerConfig{ NetForwardMode: d.NetForwardMode, NetInfraType: d.NetInfraType, } d.apiController = objApi.NewAPIController(router, d.objdbClient, apiConfig) //Restore state from cluster...
[ "func", "(", "d", "*", "MasterDaemon", ")", "runLeader", "(", ")", "{", "router", ":=", "mux", ".", "NewRouter", "(", ")", "\n\n", "// Create a new api controller", "apiConfig", ":=", "&", "objApi", ".", "APIControllerConfig", "{", "NetForwardMode", ":", "d", ...
// runLeader runs leader loop
[ "runLeader", "runs", "leader", "loop" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L408-L433
8,053
contiv/netplugin
netmaster/daemon/daemon.go
runFollower
func (d *MasterDaemon) runFollower() { router := mux.NewRouter() router.PathPrefix("/").HandlerFunc(slaveProxyHandler) // Register netmaster service d.registerService() // just wait on stop channel log.Infof("Listening in follower mode") d.startListeners(router, d.stopFollowerChan) log.Info("Exiting follower...
go
func (d *MasterDaemon) runFollower() { router := mux.NewRouter() router.PathPrefix("/").HandlerFunc(slaveProxyHandler) // Register netmaster service d.registerService() // just wait on stop channel log.Infof("Listening in follower mode") d.startListeners(router, d.stopFollowerChan) log.Info("Exiting follower...
[ "func", "(", "d", "*", "MasterDaemon", ")", "runFollower", "(", ")", "{", "router", ":=", "mux", ".", "NewRouter", "(", ")", "\n", "router", ".", "PathPrefix", "(", "\"", "\"", ")", ".", "HandlerFunc", "(", "slaveProxyHandler", ")", "\n\n", "// Register ...
// runFollower runs the follower FSM loop
[ "runFollower", "runs", "the", "follower", "FSM", "loop" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L436-L448
8,054
contiv/netplugin
netmaster/daemon/daemon.go
becomeLeader
func (d *MasterDaemon) becomeLeader() { // ask listener to stop d.stopFollowerChan <- true // set current state d.currState = "leader" // Run the HTTP listener go d.runLeader() }
go
func (d *MasterDaemon) becomeLeader() { // ask listener to stop d.stopFollowerChan <- true // set current state d.currState = "leader" // Run the HTTP listener go d.runLeader() }
[ "func", "(", "d", "*", "MasterDaemon", ")", "becomeLeader", "(", ")", "{", "// ask listener to stop", "d", ".", "stopFollowerChan", "<-", "true", "\n\n", "// set current state", "d", ".", "currState", "=", "\"", "\"", "\n\n", "// Run the HTTP listener", "go", "d...
// becomeLeader changes daemon FSM state to master
[ "becomeLeader", "changes", "daemon", "FSM", "state", "to", "master" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L496-L505
8,055
contiv/netplugin
netmaster/daemon/daemon.go
becomeFollower
func (d *MasterDaemon) becomeFollower() { // ask listener to stop d.stopLeaderChan <- true time.Sleep(time.Second) // set current state d.currState = "follower" // run follower loop go d.runFollower() }
go
func (d *MasterDaemon) becomeFollower() { // ask listener to stop d.stopLeaderChan <- true time.Sleep(time.Second) // set current state d.currState = "follower" // run follower loop go d.runFollower() }
[ "func", "(", "d", "*", "MasterDaemon", ")", "becomeFollower", "(", ")", "{", "// ask listener to stop", "d", ".", "stopLeaderChan", "<-", "true", "\n", "time", ".", "Sleep", "(", "time", ".", "Second", ")", "\n\n", "// set current state", "d", ".", "currStat...
// becomeFollower changes FSM state to follower
[ "becomeFollower", "changes", "FSM", "state", "to", "follower" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L508-L518
8,056
contiv/netplugin
netmaster/daemon/daemon.go
InitServices
func (d *MasterDaemon) InitServices() { if d.ClusterMode == "kubernetes" { isLeader := func() bool { return d.currState == "leader" } networkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader) } }
go
func (d *MasterDaemon) InitServices() { if d.ClusterMode == "kubernetes" { isLeader := func() bool { return d.currState == "leader" } networkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader) } }
[ "func", "(", "d", "*", "MasterDaemon", ")", "InitServices", "(", ")", "{", "if", "d", ".", "ClusterMode", "==", "\"", "\"", "{", "isLeader", ":=", "func", "(", ")", "bool", "{", "return", "d", ".", "currState", "==", "\"", "\"", "\n", "}", "\n", ...
// InitServices init watch services
[ "InitServices", "init", "watch", "services" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L521-L528
8,057
contiv/netplugin
netmaster/daemon/daemon.go
RunMasterFsm
func (d *MasterDaemon) RunMasterFsm() { var err error masterURL := strings.Split(d.ControlURL, ":") masterIP, masterPort := masterURL[0], masterURL[1] if len(masterURL) != 2 { log.Fatalf("Invalid netmaster URL") } // create new ofnet master d.ofnetMaster = ofnet.NewOfnetMaster(masterIP, ofnet.OFNET_MASTER_PO...
go
func (d *MasterDaemon) RunMasterFsm() { var err error masterURL := strings.Split(d.ControlURL, ":") masterIP, masterPort := masterURL[0], masterURL[1] if len(masterURL) != 2 { log.Fatalf("Invalid netmaster URL") } // create new ofnet master d.ofnetMaster = ofnet.NewOfnetMaster(masterIP, ofnet.OFNET_MASTER_PO...
[ "func", "(", "d", "*", "MasterDaemon", ")", "RunMasterFsm", "(", ")", "{", "var", "err", "error", "\n\n", "masterURL", ":=", "strings", ".", "Split", "(", "d", ".", "ControlURL", ",", "\"", "\"", ")", "\n", "masterIP", ",", "masterPort", ":=", "masterU...
// RunMasterFsm runs netmaster FSM
[ "RunMasterFsm", "runs", "netmaster", "FSM" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L531-L588
8,058
contiv/netplugin
netmaster/daemon/daemon.go
getMasterInfo
func (d *MasterDaemon) getMasterInfo() (map[string]interface{}, error) { info := make(map[string]interface{}) // get local ip localIP, err := netutils.GetDefaultAddr() if err != nil { return nil, errors.New("error getting local IP address") } // get current holder of master lock leader := leaderLock.GetHolde...
go
func (d *MasterDaemon) getMasterInfo() (map[string]interface{}, error) { info := make(map[string]interface{}) // get local ip localIP, err := netutils.GetDefaultAddr() if err != nil { return nil, errors.New("error getting local IP address") } // get current holder of master lock leader := leaderLock.GetHolde...
[ "func", "(", "d", "*", "MasterDaemon", ")", "getMasterInfo", "(", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "info", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ")", "\n\n", "// get ...
// getMasterInfo returns information about cluster
[ "getMasterInfo", "returns", "information", "about", "cluster" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/daemon/daemon.go#L598-L647
8,059
contiv/netplugin
netmaster/master/policy.go
PolicyAttach
func PolicyAttach(epg *contivModel.EndpointGroup, policy *contivModel.Policy) error { // Dont install policies in ACI mode if !isPolicyEnabled() { return nil } epgpKey := epg.Key + ":" + policy.Key // See if it already exists gp := mastercfg.FindEpgPolicy(epgpKey) if gp != nil { log.Errorf("EPG policy %s a...
go
func PolicyAttach(epg *contivModel.EndpointGroup, policy *contivModel.Policy) error { // Dont install policies in ACI mode if !isPolicyEnabled() { return nil } epgpKey := epg.Key + ":" + policy.Key // See if it already exists gp := mastercfg.FindEpgPolicy(epgpKey) if gp != nil { log.Errorf("EPG policy %s a...
[ "func", "PolicyAttach", "(", "epg", "*", "contivModel", ".", "EndpointGroup", ",", "policy", "*", "contivModel", ".", "Policy", ")", "error", "{", "// Dont install policies in ACI mode", "if", "!", "isPolicyEnabled", "(", ")", "{", "return", "nil", "\n", "}", ...
// PolicyAttach attaches a policy to an endpoint and adds associated rules to policyDB
[ "PolicyAttach", "attaches", "a", "policy", "to", "an", "endpoint", "and", "adds", "associated", "rules", "to", "policyDB" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/policy.go#L42-L77
8,060
contiv/netplugin
netmaster/master/policy.go
PolicyDetach
func PolicyDetach(epg *contivModel.EndpointGroup, policy *contivModel.Policy) error { // Dont install policies in ACI mode if !isPolicyEnabled() { return nil } epgpKey := epg.Key + ":" + policy.Key // find the policy gp := mastercfg.FindEpgPolicy(epgpKey) if gp == nil { log.Errorf("Epg policy %s does not e...
go
func PolicyDetach(epg *contivModel.EndpointGroup, policy *contivModel.Policy) error { // Dont install policies in ACI mode if !isPolicyEnabled() { return nil } epgpKey := epg.Key + ":" + policy.Key // find the policy gp := mastercfg.FindEpgPolicy(epgpKey) if gp == nil { log.Errorf("Epg policy %s does not e...
[ "func", "PolicyDetach", "(", "epg", "*", "contivModel", ".", "EndpointGroup", ",", "policy", "*", "contivModel", ".", "Policy", ")", "error", "{", "// Dont install policies in ACI mode", "if", "!", "isPolicyEnabled", "(", ")", "{", "return", "nil", "\n", "}", ...
// PolicyDetach detaches policy from an endpoint and removes associated rules from policyDB
[ "PolicyDetach", "detaches", "policy", "from", "an", "endpoint", "and", "removes", "associated", "rules", "from", "policyDB" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/policy.go#L80-L115
8,061
contiv/netplugin
netmaster/master/policy.go
PolicyAddRule
func PolicyAddRule(policy *contivModel.Policy, rule *contivModel.Rule) error { // Dont install policies in ACI mode if !isPolicyEnabled() { return nil } // Walk all associated endpoint groups for epgKey := range policy.LinkSets.EndpointGroups { gpKey := epgKey + ":" + policy.Key // Find the epg policy gp...
go
func PolicyAddRule(policy *contivModel.Policy, rule *contivModel.Rule) error { // Dont install policies in ACI mode if !isPolicyEnabled() { return nil } // Walk all associated endpoint groups for epgKey := range policy.LinkSets.EndpointGroups { gpKey := epgKey + ":" + policy.Key // Find the epg policy gp...
[ "func", "PolicyAddRule", "(", "policy", "*", "contivModel", ".", "Policy", ",", "rule", "*", "contivModel", ".", "Rule", ")", "error", "{", "// Dont install policies in ACI mode", "if", "!", "isPolicyEnabled", "(", ")", "{", "return", "nil", "\n", "}", "\n\n",...
// PolicyAddRule adds a rule to existing policy
[ "PolicyAddRule", "adds", "a", "rule", "to", "existing", "policy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/policy.go#L118-L150
8,062
contiv/netplugin
state/cfgtool/cfgtool.go
initStateDriver
func initStateDriver(clusterStore string) (core.StateDriver, error) { // parse the state store URL parts := strings.Split(clusterStore, "://") if len(parts) < 2 { return nil, core.Errorf("Invalid state-store URL %q", clusterStore) } stateStore := parts[0] // Make sure we support the statestore type switch sta...
go
func initStateDriver(clusterStore string) (core.StateDriver, error) { // parse the state store URL parts := strings.Split(clusterStore, "://") if len(parts) < 2 { return nil, core.Errorf("Invalid state-store URL %q", clusterStore) } stateStore := parts[0] // Make sure we support the statestore type switch sta...
[ "func", "initStateDriver", "(", "clusterStore", "string", ")", "(", "core", ".", "StateDriver", ",", "error", ")", "{", "// parse the state store URL", "parts", ":=", "strings", ".", "Split", "(", "clusterStore", ",", "\"", "\"", ")", "\n", "if", "len", "(",...
// initStateDriver creates a state driver based on the cluster store URL
[ "initStateDriver", "creates", "a", "state", "driver", "based", "on", "the", "cluster", "store", "URL" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/state/cfgtool/cfgtool.go#L38-L60
8,063
contiv/netplugin
state/cfgtool/cfgtool.go
parseRange
func parseRange(rangeStr string) ([]uint, error) { var values []uint if rangeStr == "" { return []uint{}, nil } // split ranges based on "," char rangeList := strings.Split(rangeStr, ",") for _, subrange := range rangeList { minMax := strings.Split(strings.TrimSpace(subrange), "-") if len(minMax) == 2 { ...
go
func parseRange(rangeStr string) ([]uint, error) { var values []uint if rangeStr == "" { return []uint{}, nil } // split ranges based on "," char rangeList := strings.Split(rangeStr, ",") for _, subrange := range rangeList { minMax := strings.Split(strings.TrimSpace(subrange), "-") if len(minMax) == 2 { ...
[ "func", "parseRange", "(", "rangeStr", "string", ")", "(", "[", "]", "uint", ",", "error", ")", "{", "var", "values", "[", "]", "uint", "\n", "if", "rangeStr", "==", "\"", "\"", "{", "return", "[", "]", "uint", "{", "}", ",", "nil", "\n", "}", ...
// parseRange parses a string in "1,2-3,4-10" format and returns an array of values
[ "parseRange", "parses", "a", "string", "in", "1", "2", "-", "3", "4", "-", "10", "format", "and", "returns", "an", "array", "of", "values" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/state/cfgtool/cfgtool.go#L63-L110
8,064
contiv/netplugin
state/cfgtool/cfgtool.go
processResource
func processResource(stateDriver core.StateDriver, rsrcName, rsrcVal string) error { // Read global config gCfg := gstate.Cfg{} gCfg.StateDriver = stateDriver err := gCfg.Read("") if err != nil { log.Errorf("error reading tenant cfg state. Error: %s", err) return err } // process resource based on name if ...
go
func processResource(stateDriver core.StateDriver, rsrcName, rsrcVal string) error { // Read global config gCfg := gstate.Cfg{} gCfg.StateDriver = stateDriver err := gCfg.Read("") if err != nil { log.Errorf("error reading tenant cfg state. Error: %s", err) return err } // process resource based on name if ...
[ "func", "processResource", "(", "stateDriver", "core", ".", "StateDriver", ",", "rsrcName", ",", "rsrcVal", "string", ")", "error", "{", "// Read global config", "gCfg", ":=", "gstate", ".", "Cfg", "{", "}", "\n", "gCfg", ".", "StateDriver", "=", "stateDriver"...
// processResource handles resource commands
[ "processResource", "handles", "resource", "commands" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/state/cfgtool/cfgtool.go#L113-L176
8,065
contiv/netplugin
mgmtfn/mesosplugin/cnidriver.go
ipnsExecute
func (cniReq *cniServer) ipnsExecute(namespace string, args []string) ([]byte, error) { ipCmd := "ip" ipArgs := []string{"netns", "exec", namespace} ipArgs = append(ipArgs, args...) cniLog.Infof("processing cmd: %v", ipArgs) return exec.Command(ipCmd, ipArgs...).CombinedOutput() }
go
func (cniReq *cniServer) ipnsExecute(namespace string, args []string) ([]byte, error) { ipCmd := "ip" ipArgs := []string{"netns", "exec", namespace} ipArgs = append(ipArgs, args...) cniLog.Infof("processing cmd: %v", ipArgs) return exec.Command(ipCmd, ipArgs...).CombinedOutput() }
[ "func", "(", "cniReq", "*", "cniServer", ")", "ipnsExecute", "(", "namespace", "string", ",", "args", "[", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ipCmd", ":=", "\"", "\"", "\n", "ipArgs", ":=", "[", "]", "string", "{", ...
// execute name space commands
[ "execute", "name", "space", "commands" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/mesosplugin/cnidriver.go#L43-L50
8,066
contiv/netplugin
mgmtfn/mesosplugin/cnidriver.go
ipnsBatchExecute
func (cniReq *cniServer) ipnsBatchExecute(namespace string, args [][]string) ([]byte, error) { for idx, arg1 := range args { if out, err := cniReq.ipnsExecute(namespace, arg1); err != nil { cniLog.Errorf("failed to execute [%d] %v %s, %s", idx, err, arg1, string(out)) return out, err } } return nil, nil ...
go
func (cniReq *cniServer) ipnsBatchExecute(namespace string, args [][]string) ([]byte, error) { for idx, arg1 := range args { if out, err := cniReq.ipnsExecute(namespace, arg1); err != nil { cniLog.Errorf("failed to execute [%d] %v %s, %s", idx, err, arg1, string(out)) return out, err } } return nil, nil ...
[ "func", "(", "cniReq", "*", "cniServer", ")", "ipnsBatchExecute", "(", "namespace", "string", ",", "args", "[", "]", "[", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "for", "idx", ",", "arg1", ":=", "range", "args", "{", "if"...
// execute a batch of namespace commands
[ "execute", "a", "batch", "of", "namespace", "commands" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/mesosplugin/cnidriver.go#L53-L63
8,067
contiv/netplugin
mgmtfn/k8splugin/cniserver.go
setUpAPIClient
func setUpAPIClient() *APIClient { // Read config err := k8sutils.GetK8SConfig(&contivK8Config) if err != nil { log.Errorf("Failed: %v", err) return nil } return NewAPIClient(contivK8Config.K8sAPIServer, contivK8Config.K8sCa, contivK8Config.K8sKey, contivK8Config.K8sCert, contivK8Config.K8sToken) }
go
func setUpAPIClient() *APIClient { // Read config err := k8sutils.GetK8SConfig(&contivK8Config) if err != nil { log.Errorf("Failed: %v", err) return nil } return NewAPIClient(contivK8Config.K8sAPIServer, contivK8Config.K8sCa, contivK8Config.K8sKey, contivK8Config.K8sCert, contivK8Config.K8sToken) }
[ "func", "setUpAPIClient", "(", ")", "*", "APIClient", "{", "// Read config", "err", ":=", "k8sutils", ".", "GetK8SConfig", "(", "&", "contivK8Config", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n...
// setUpAPIClient sets up an instance of the k8s api server
[ "setUpAPIClient", "sets", "up", "an", "instance", "of", "the", "k8s", "api", "server" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/cniserver.go#L42-L53
8,068
contiv/netplugin
mgmtfn/k8splugin/cniserver.go
InitKubServiceWatch
func InitKubServiceWatch(np *plugin.NetPlugin) { watchClient := setUpAPIClient() if watchClient == nil { log.Fatalf("Could not init kubernetes API client") } svcCh := make(chan SvcWatchResp, 1) epCh := make(chan EpWatchResp, 1) go func() { for { select { case svcEvent := <-svcCh: switch svcEvent.o...
go
func InitKubServiceWatch(np *plugin.NetPlugin) { watchClient := setUpAPIClient() if watchClient == nil { log.Fatalf("Could not init kubernetes API client") } svcCh := make(chan SvcWatchResp, 1) epCh := make(chan EpWatchResp, 1) go func() { for { select { case svcEvent := <-svcCh: switch svcEvent.o...
[ "func", "InitKubServiceWatch", "(", "np", "*", "plugin", ".", "NetPlugin", ")", "{", "watchClient", ":=", "setUpAPIClient", "(", ")", "\n", "if", "watchClient", "==", "nil", "{", "log", ".", "Fatalf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "svcCh", "...
// InitKubServiceWatch initializes the k8s service watch
[ "InitKubServiceWatch", "initializes", "the", "k8s", "service", "watch" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/cniserver.go#L56-L109
8,069
contiv/netplugin
mgmtfn/k8splugin/cniserver.go
InitCNIServer
func InitCNIServer(netplugin *plugin.NetPlugin) error { netPlugin = netplugin hostname, err := os.Hostname() if err != nil { log.Fatalf("Could not retrieve hostname: %v", err) } pluginHost = hostname // Set up the api client instance kubeAPIClient = setUpAPIClient() if kubeAPIClient == nil { log.Fatalf("...
go
func InitCNIServer(netplugin *plugin.NetPlugin) error { netPlugin = netplugin hostname, err := os.Hostname() if err != nil { log.Fatalf("Could not retrieve hostname: %v", err) } pluginHost = hostname // Set up the api client instance kubeAPIClient = setUpAPIClient() if kubeAPIClient == nil { log.Fatalf("...
[ "func", "InitCNIServer", "(", "netplugin", "*", "plugin", ".", "NetPlugin", ")", "error", "{", "netPlugin", "=", "netplugin", "\n", "hostname", ",", "err", ":=", "os", ".", "Hostname", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Fatalf"...
// InitCNIServer initializes the k8s cni server
[ "InitCNIServer", "initializes", "the", "k8s", "cni", "server" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/cniserver.go#L112-L156
8,070
contiv/netplugin
mgmtfn/k8splugin/driver.go
epCleanUp
func epCleanUp(req *epSpec) error { // first delete from netplugin // ignore any errors as this is best effort netID := req.Network + "." + req.Tenant pluginErr := netPlugin.DeleteEndpoint(netID + "-" + req.EndpointID) // now delete from master delReq := master.DeleteEndpointRequest{ TenantName: req.Tenant, ...
go
func epCleanUp(req *epSpec) error { // first delete from netplugin // ignore any errors as this is best effort netID := req.Network + "." + req.Tenant pluginErr := netPlugin.DeleteEndpoint(netID + "-" + req.EndpointID) // now delete from master delReq := master.DeleteEndpointRequest{ TenantName: req.Tenant, ...
[ "func", "epCleanUp", "(", "req", "*", "epSpec", ")", "error", "{", "// first delete from netplugin", "// ignore any errors as this is best effort", "netID", ":=", "req", ".", "Network", "+", "\"", "\"", "+", "req", ".", "Tenant", "\n", "pluginErr", ":=", "netPlugi...
// epCleanUp deletes the ep from netplugin and netmaster
[ "epCleanUp", "deletes", "the", "ep", "from", "netplugin", "and", "netmaster" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L57-L85
8,071
contiv/netplugin
mgmtfn/k8splugin/driver.go
createEP
func createEP(req *epSpec) (*epAttr, error) { // if the ep already exists, treat as error for now. netID := req.Network + "." + req.Tenant ep, err := utils.GetEndpoint(netID + "-" + req.EndpointID) if err == nil { return nil, fmt.Errorf("the EP %s already exists", req.EndpointID) } // Build endpoint request ...
go
func createEP(req *epSpec) (*epAttr, error) { // if the ep already exists, treat as error for now. netID := req.Network + "." + req.Tenant ep, err := utils.GetEndpoint(netID + "-" + req.EndpointID) if err == nil { return nil, fmt.Errorf("the EP %s already exists", req.EndpointID) } // Build endpoint request ...
[ "func", "createEP", "(", "req", "*", "epSpec", ")", "(", "*", "epAttr", ",", "error", ")", "{", "// if the ep already exists, treat as error for now.", "netID", ":=", "req", ".", "Network", "+", "\"", "\"", "+", "req", ".", "Tenant", "\n", "ep", ",", "err"...
// createEP creates the specified EP in contiv
[ "createEP", "creates", "the", "specified", "EP", "in", "contiv" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L88-L154
8,072
contiv/netplugin
mgmtfn/k8splugin/driver.go
getLink
func getLink(ifname string) (netlink.Link, error) { // find the link link, err := netlink.LinkByName(ifname) if err != nil { if !strings.Contains(err.Error(), "Link not found") { log.Errorf("unable to find link %q. Error: %q", ifname, err) return link, err } // try once more as sometimes (somehow) link c...
go
func getLink(ifname string) (netlink.Link, error) { // find the link link, err := netlink.LinkByName(ifname) if err != nil { if !strings.Contains(err.Error(), "Link not found") { log.Errorf("unable to find link %q. Error: %q", ifname, err) return link, err } // try once more as sometimes (somehow) link c...
[ "func", "getLink", "(", "ifname", "string", ")", "(", "netlink", ".", "Link", ",", "error", ")", "{", "// find the link", "link", ",", "err", ":=", "netlink", ".", "LinkByName", "(", "ifname", ")", "\n", "if", "err", "!=", "nil", "{", "if", "!", "str...
// getLink is a wrapper that fetches the netlink corresponding to the ifname
[ "getLink", "is", "a", "wrapper", "that", "fetches", "the", "netlink", "corresponding", "to", "the", "ifname" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L157-L175
8,073
contiv/netplugin
mgmtfn/k8splugin/driver.go
nsToPID
func nsToPID(ns string) (int, error) { // Make sure ns is well formed ok := strings.HasPrefix(ns, "/proc/") if !ok { return -1, fmt.Errorf("invalid nw name space: %v", ns) } elements := strings.Split(ns, "/") return strconv.Atoi(elements[2]) }
go
func nsToPID(ns string) (int, error) { // Make sure ns is well formed ok := strings.HasPrefix(ns, "/proc/") if !ok { return -1, fmt.Errorf("invalid nw name space: %v", ns) } elements := strings.Split(ns, "/") return strconv.Atoi(elements[2]) }
[ "func", "nsToPID", "(", "ns", "string", ")", "(", "int", ",", "error", ")", "{", "// Make sure ns is well formed", "ok", ":=", "strings", ".", "HasPrefix", "(", "ns", ",", "\"", "\"", ")", "\n", "if", "!", "ok", "{", "return", "-", "1", ",", "fmt", ...
// nsToPID is a utility that extracts the PID from the netns
[ "nsToPID", "is", "a", "utility", "that", "extracts", "the", "PID", "from", "the", "netns" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L178-L187
8,074
contiv/netplugin
mgmtfn/k8splugin/driver.go
setIfAttrs
func setIfAttrs(pid int, ifname, cidr, cidr6, newname string) error { nsenterPath, err := osexec.LookPath("nsenter") if err != nil { return err } ipPath, err := osexec.LookPath("ip") if err != nil { return err } // find the link link, err := getLink(ifname) if err != nil { log.Errorf("unable to find lin...
go
func setIfAttrs(pid int, ifname, cidr, cidr6, newname string) error { nsenterPath, err := osexec.LookPath("nsenter") if err != nil { return err } ipPath, err := osexec.LookPath("ip") if err != nil { return err } // find the link link, err := getLink(ifname) if err != nil { log.Errorf("unable to find lin...
[ "func", "setIfAttrs", "(", "pid", "int", ",", "ifname", ",", "cidr", ",", "cidr6", ",", "newname", "string", ")", "error", "{", "nsenterPath", ",", "err", ":=", "osexec", ".", "LookPath", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "...
// setIfAttrs sets the required attributes for the container interface
[ "setIfAttrs", "sets", "the", "required", "attributes", "for", "the", "container", "interface" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L209-L279
8,075
contiv/netplugin
mgmtfn/k8splugin/driver.go
setDefGw
func setDefGw(pid int, gw, gw6, intfName string) error { nsenterPath, err := osexec.LookPath("nsenter") if err != nil { return err } routePath, err := osexec.LookPath("route") if err != nil { return err } // set default gw nsPid := fmt.Sprintf("%d", pid) out, err := osexec.Command(nsenterPath, "-t", nsPid,...
go
func setDefGw(pid int, gw, gw6, intfName string) error { nsenterPath, err := osexec.LookPath("nsenter") if err != nil { return err } routePath, err := osexec.LookPath("route") if err != nil { return err } // set default gw nsPid := fmt.Sprintf("%d", pid) out, err := osexec.Command(nsenterPath, "-t", nsPid,...
[ "func", "setDefGw", "(", "pid", "int", ",", "gw", ",", "gw6", ",", "intfName", "string", ")", "error", "{", "nsenterPath", ",", "err", ":=", "osexec", ".", "LookPath", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n"...
// setDefGw sets the default gateway for the container namespace
[ "setDefGw", "sets", "the", "default", "gateway", "for", "the", "container", "namespace" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L306-L334
8,076
contiv/netplugin
mgmtfn/k8splugin/driver.go
getEPSpec
func getEPSpec(pInfo *cniapi.CNIPodAttr) (*epSpec, error) { resp := epSpec{} // Get labels from the kube api server epg, err := kubeAPIClient.GetPodLabel(pInfo.K8sNameSpace, pInfo.Name, "io.contiv.net-group") if err != nil { log.Errorf("Error getting epg. Err: %v", err) return &resp, err } // Safe to igno...
go
func getEPSpec(pInfo *cniapi.CNIPodAttr) (*epSpec, error) { resp := epSpec{} // Get labels from the kube api server epg, err := kubeAPIClient.GetPodLabel(pInfo.K8sNameSpace, pInfo.Name, "io.contiv.net-group") if err != nil { log.Errorf("Error getting epg. Err: %v", err) return &resp, err } // Safe to igno...
[ "func", "getEPSpec", "(", "pInfo", "*", "cniapi", ".", "CNIPodAttr", ")", "(", "*", "epSpec", ",", "error", ")", "{", "resp", ":=", "epSpec", "{", "}", "\n\n", "// Get labels from the kube api server", "epg", ",", "err", ":=", "kubeAPIClient", ".", "GetPodLa...
// getEPSpec gets the EP spec using the pod attributes
[ "getEPSpec", "gets", "the", "EP", "spec", "using", "the", "pod", "attributes" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L337-L361
8,077
contiv/netplugin
mgmtfn/k8splugin/driver.go
deletePod
func deletePod(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) { resp := cniapi.RspAddPod{} logEvent("del pod") content, err := ioutil.ReadAll(r.Body) if err != nil { log.Errorf("Failed to read request: %v", err) return resp, err } pInfo := cniapi.CNIPodAttr{} if err ...
go
func deletePod(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) { resp := cniapi.RspAddPod{} logEvent("del pod") content, err := ioutil.ReadAll(r.Body) if err != nil { log.Errorf("Failed to read request: %v", err) return resp, err } pInfo := cniapi.CNIPodAttr{} if err ...
[ "func", "deletePod", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "vars", "map", "[", "string", "]", "string", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "resp", ":=", "cniapi", ".", "RspAddPod", ...
// deletePod is the handler for pod deletes
[ "deletePod", "is", "the", "handler", "for", "pod", "deletes" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/mgmtfn/k8splugin/driver.go#L477-L509
8,078
contiv/netplugin
netmaster/master/endpoint.go
freeAddrOnErr
func freeAddrOnErr(nwCfg *mastercfg.CfgNetworkState, epgCfg *mastercfg.EndpointGroupState, ipAddress string, pErr *error) { if *pErr != nil { log.Infof("Freeing %s on error", ipAddress) networkReleaseAddress(nwCfg, epgCfg, ipAddress) } }
go
func freeAddrOnErr(nwCfg *mastercfg.CfgNetworkState, epgCfg *mastercfg.EndpointGroupState, ipAddress string, pErr *error) { if *pErr != nil { log.Infof("Freeing %s on error", ipAddress) networkReleaseAddress(nwCfg, epgCfg, ipAddress) } }
[ "func", "freeAddrOnErr", "(", "nwCfg", "*", "mastercfg", ".", "CfgNetworkState", ",", "epgCfg", "*", "mastercfg", ".", "EndpointGroupState", ",", "ipAddress", "string", ",", "pErr", "*", "error", ")", "{", "if", "*", "pErr", "!=", "nil", "{", "log", ".", ...
// freeAddrOnErr deferred function that cleans up on error
[ "freeAddrOnErr", "deferred", "function", "that", "cleans", "up", "on", "error" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/endpoint.go#L93-L99
8,079
contiv/netplugin
netmaster/master/endpoint.go
CreateEndpoints
func CreateEndpoints(stateDriver core.StateDriver, tenant *intent.ConfigTenant) error { err := validateEndpointConfig(stateDriver, tenant) if err != nil { log.Errorf("error validating endpoint config. Error: %s", err) return err } for _, network := range tenant.Networks { nwCfg := &mastercfg.CfgNetworkState{...
go
func CreateEndpoints(stateDriver core.StateDriver, tenant *intent.ConfigTenant) error { err := validateEndpointConfig(stateDriver, tenant) if err != nil { log.Errorf("error validating endpoint config. Error: %s", err) return err } for _, network := range tenant.Networks { nwCfg := &mastercfg.CfgNetworkState{...
[ "func", "CreateEndpoints", "(", "stateDriver", "core", ".", "StateDriver", ",", "tenant", "*", "intent", ".", "ConfigTenant", ")", "error", "{", "err", ":=", "validateEndpointConfig", "(", "stateDriver", ",", "tenant", ")", "\n", "if", "err", "!=", "nil", "{...
// CreateEndpoints creates the endpoints for a given tenant.
[ "CreateEndpoints", "creates", "the", "endpoints", "for", "a", "given", "tenant", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/endpoint.go#L195-L230
8,080
contiv/netplugin
netmaster/master/endpoint.go
DeleteEndpoints
func DeleteEndpoints(hostAddr string) error { // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } readEp := &mastercfg.CfgEndpointState{} readEp.StateDriver = stateDriver epCfgs, err := readEp.ReadAll() if err != nil { return err } for _, epCfg := range epCfgs...
go
func DeleteEndpoints(hostAddr string) error { // Get the state driver stateDriver, err := utils.GetStateDriver() if err != nil { return err } readEp := &mastercfg.CfgEndpointState{} readEp.StateDriver = stateDriver epCfgs, err := readEp.ReadAll() if err != nil { return err } for _, epCfg := range epCfgs...
[ "func", "DeleteEndpoints", "(", "hostAddr", "string", ")", "error", "{", "// Get the state driver", "stateDriver", ",", "err", ":=", "utils", ".", "GetStateDriver", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "readEp", ...
// DeleteEndpoints deletes the endpoints on a give host
[ "DeleteEndpoints", "deletes", "the", "endpoints", "on", "a", "give", "host" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/endpoint.go#L233-L284
8,081
contiv/netplugin
netmaster/master/endpoint.go
DeleteEndpointID
func DeleteEndpointID(stateDriver core.StateDriver, epID string) (*mastercfg.CfgEndpointState, error) { epCfg := &mastercfg.CfgEndpointState{} var epgCfg *mastercfg.EndpointGroupState epCfg.StateDriver = stateDriver err := epCfg.Read(epID) if err != nil { return nil, err } nwCfg := &mastercfg.CfgNetworkState...
go
func DeleteEndpointID(stateDriver core.StateDriver, epID string) (*mastercfg.CfgEndpointState, error) { epCfg := &mastercfg.CfgEndpointState{} var epgCfg *mastercfg.EndpointGroupState epCfg.StateDriver = stateDriver err := epCfg.Read(epID) if err != nil { return nil, err } nwCfg := &mastercfg.CfgNetworkState...
[ "func", "DeleteEndpointID", "(", "stateDriver", "core", ".", "StateDriver", ",", "epID", "string", ")", "(", "*", "mastercfg", ".", "CfgEndpointState", ",", "error", ")", "{", "epCfg", ":=", "&", "mastercfg", ".", "CfgEndpointState", "{", "}", "\n", "var", ...
// DeleteEndpointID deletes an endpoint by ID.
[ "DeleteEndpointID", "deletes", "an", "endpoint", "by", "ID", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/endpoint.go#L287-L354
8,082
contiv/netplugin
netmaster/master/endpoint.go
CreateEpBindings
func CreateEpBindings(epBindings *[]intent.ConfigEP) error { stateDriver, err := utils.GetStateDriver() if err != nil { return err } err = validateEpBindings(epBindings) if err != nil { log.Errorf("error validating the ep bindings. Error: %s", err) return err } readEp := &mastercfg.CfgEndpointState{} re...
go
func CreateEpBindings(epBindings *[]intent.ConfigEP) error { stateDriver, err := utils.GetStateDriver() if err != nil { return err } err = validateEpBindings(epBindings) if err != nil { log.Errorf("error validating the ep bindings. Error: %s", err) return err } readEp := &mastercfg.CfgEndpointState{} re...
[ "func", "CreateEpBindings", "(", "epBindings", "*", "[", "]", "intent", ".", "ConfigEP", ")", "error", "{", "stateDriver", ",", "err", ":=", "utils", ".", "GetStateDriver", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\...
// CreateEpBindings binds an endpoint to a host by updating host-label info // in driver's endpoint configuration.
[ "CreateEpBindings", "binds", "an", "endpoint", "to", "a", "host", "by", "updating", "host", "-", "label", "info", "in", "driver", "s", "endpoint", "configuration", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/master/endpoint.go#L371-L409
8,083
contiv/netplugin
netmaster/objApi/extContracts.go
cleanupExternalContracts
func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error { tenant := endpointGroup.TenantName for _, contractsGrp := range endpointGroup.ExtContractsGrps { contractsGrpKey := tenant + ":" + contractsGrp contractsGrpObj := contivModel.FindExtContractsGroup(contractsGrpKey) if contractsGrpOb...
go
func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error { tenant := endpointGroup.TenantName for _, contractsGrp := range endpointGroup.ExtContractsGrps { contractsGrpKey := tenant + ":" + contractsGrp contractsGrpObj := contivModel.FindExtContractsGroup(contractsGrpKey) if contractsGrpOb...
[ "func", "cleanupExternalContracts", "(", "endpointGroup", "*", "contivModel", ".", "EndpointGroup", ")", "error", "{", "tenant", ":=", "endpointGroup", ".", "TenantName", "\n", "for", "_", ",", "contractsGrp", ":=", "range", "endpointGroup", ".", "ExtContractsGrps",...
// Some utility functions to work with the external contracts // Cleanup external contracts from an epg.
[ "Some", "utility", "functions", "to", "work", "with", "the", "external", "contracts", "Cleanup", "external", "contracts", "from", "an", "epg", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/extContracts.go#L29-L52
8,084
contiv/netplugin
netmaster/objApi/extContracts.go
setupExternalContracts
func setupExternalContracts(endpointGroup *contivModel.EndpointGroup, extContractsGrps []string) error { // Validate presence and register consumed external contracts tenant := endpointGroup.TenantName for _, contractsGrp := range extContractsGrps { contractsGrpKey := tenant + ":" + contractsGrp contractsGrpObj ...
go
func setupExternalContracts(endpointGroup *contivModel.EndpointGroup, extContractsGrps []string) error { // Validate presence and register consumed external contracts tenant := endpointGroup.TenantName for _, contractsGrp := range extContractsGrps { contractsGrpKey := tenant + ":" + contractsGrp contractsGrpObj ...
[ "func", "setupExternalContracts", "(", "endpointGroup", "*", "contivModel", ".", "EndpointGroup", ",", "extContractsGrps", "[", "]", "string", ")", "error", "{", "// Validate presence and register consumed external contracts", "tenant", ":=", "endpointGroup", ".", "TenantNa...
// Setup external contracts for an epg.
[ "Setup", "external", "contracts", "for", "an", "epg", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/extContracts.go#L55-L80
8,085
contiv/netplugin
netmaster/objApi/extContracts.go
ExtContractsGroupCreate
func (ac *APIController) ExtContractsGroupCreate(contractsGroup *contivModel.ExtContractsGroup) error { log.Infof("Received ExtContractsGroupCreate: %+v", contractsGroup) // Validate contracts type if contractsGroup.ContractsType != "provided" && contractsGroup.ContractsType != "consumed" { return core.Errorf("Co...
go
func (ac *APIController) ExtContractsGroupCreate(contractsGroup *contivModel.ExtContractsGroup) error { log.Infof("Received ExtContractsGroupCreate: %+v", contractsGroup) // Validate contracts type if contractsGroup.ContractsType != "provided" && contractsGroup.ContractsType != "consumed" { return core.Errorf("Co...
[ "func", "(", "ac", "*", "APIController", ")", "ExtContractsGroupCreate", "(", "contractsGroup", "*", "contivModel", ".", "ExtContractsGroup", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "contractsGroup", ")", "\n\n", "// Validate contracts type",...
// ExtContractsGroupCreate creates a new group of external contracts
[ "ExtContractsGroupCreate", "creates", "a", "new", "group", "of", "external", "contracts" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/extContracts.go#L88-L105
8,086
contiv/netplugin
netmaster/objApi/extContracts.go
ExtContractsGroupUpdate
func (ac *APIController) ExtContractsGroupUpdate(contractsGroup, params *contivModel.ExtContractsGroup) error { log.Infof("Received ExtContractsGroupUpdate: %+v, params: %+v", contractsGroup, params) log.Errorf("Error: external contracts update not supported: %s", contractsGroup.ContractsGroupName) return core.Erro...
go
func (ac *APIController) ExtContractsGroupUpdate(contractsGroup, params *contivModel.ExtContractsGroup) error { log.Infof("Received ExtContractsGroupUpdate: %+v, params: %+v", contractsGroup, params) log.Errorf("Error: external contracts update not supported: %s", contractsGroup.ContractsGroupName) return core.Erro...
[ "func", "(", "ac", "*", "APIController", ")", "ExtContractsGroupUpdate", "(", "contractsGroup", ",", "params", "*", "contivModel", ".", "ExtContractsGroup", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "contractsGroup", ",", "params", ")", "...
// ExtContractsGroupUpdate updates an existing group of contract sets
[ "ExtContractsGroupUpdate", "updates", "an", "existing", "group", "of", "contract", "sets" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/extContracts.go#L108-L113
8,087
contiv/netplugin
netmaster/objApi/extContracts.go
ExtContractsGroupDelete
func (ac *APIController) ExtContractsGroupDelete(contractsGroup *contivModel.ExtContractsGroup) error { log.Infof("Received ExtContractsGroupDelete: %+v", contractsGroup) // At this moment, we let the external contracts to be deleted only // if there are no consumers of this external contracts group if isExtContra...
go
func (ac *APIController) ExtContractsGroupDelete(contractsGroup *contivModel.ExtContractsGroup) error { log.Infof("Received ExtContractsGroupDelete: %+v", contractsGroup) // At this moment, we let the external contracts to be deleted only // if there are no consumers of this external contracts group if isExtContra...
[ "func", "(", "ac", "*", "APIController", ")", "ExtContractsGroupDelete", "(", "contractsGroup", "*", "contivModel", ".", "ExtContractsGroup", ")", "error", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "contractsGroup", ")", "\n\n", "// At this moment, we let th...
// ExtContractsGroupDelete deletes an existing external contracts group
[ "ExtContractsGroupDelete", "deletes", "an", "existing", "external", "contracts", "group" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/netmaster/objApi/extContracts.go#L116-L127
8,088
contiv/netplugin
utils/httputils.go
MakeHTTPHandler
func MakeHTTPHandler(handlerFunc httpAPIFunc) http.HandlerFunc { // Create a closure and return an anonymous function return func(w http.ResponseWriter, r *http.Request) { // Call the handler resp, err := handlerFunc(w, r, mux.Vars(r)) if err != nil { // Log error log.Errorf("Handler for %s %s returned er...
go
func MakeHTTPHandler(handlerFunc httpAPIFunc) http.HandlerFunc { // Create a closure and return an anonymous function return func(w http.ResponseWriter, r *http.Request) { // Call the handler resp, err := handlerFunc(w, r, mux.Vars(r)) if err != nil { // Log error log.Errorf("Handler for %s %s returned er...
[ "func", "MakeHTTPHandler", "(", "handlerFunc", "httpAPIFunc", ")", "http", ".", "HandlerFunc", "{", "// Create a closure and return an anonymous function", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", ...
// MakeHTTPHandler is a simple Wrapper for http handlers
[ "MakeHTTPHandler", "is", "a", "simple", "Wrapper", "for", "http", "handlers" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/utils/httputils.go#L33-L65
8,089
contiv/netplugin
utils/httputils.go
UnknownAction
func UnknownAction(w http.ResponseWriter, r *http.Request) { log.Infof("Unknown action at %q", r.URL.Path) content, _ := ioutil.ReadAll(r.Body) log.Infof("Body content: %s", string(content)) http.NotFound(w, r) }
go
func UnknownAction(w http.ResponseWriter, r *http.Request) { log.Infof("Unknown action at %q", r.URL.Path) content, _ := ioutil.ReadAll(r.Body) log.Infof("Body content: %s", string(content)) http.NotFound(w, r) }
[ "func", "UnknownAction", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "log", ".", "Infof", "(", "\"", "\"", ",", "r", ".", "URL", ".", "Path", ")", "\n", "content", ",", "_", ":=", "ioutil", ".", "Read...
// UnknownAction is a catchall handler for additional driver functions
[ "UnknownAction", "is", "a", "catchall", "handler", "for", "additional", "driver", "functions" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/utils/httputils.go#L81-L86
8,090
contiv/netplugin
utils/httputils.go
HTTPPost
func HTTPPost(url string, req interface{}, resp interface{}) error { // Convert the req to json jsonStr, err := json.Marshal(req) if err != nil { log.Errorf("Error converting request data(%#v) to Json. Err: %v", req, err) return err } // Perform HTTP POST operation res, err := http.Post(url, "application/jso...
go
func HTTPPost(url string, req interface{}, resp interface{}) error { // Convert the req to json jsonStr, err := json.Marshal(req) if err != nil { log.Errorf("Error converting request data(%#v) to Json. Err: %v", req, err) return err } // Perform HTTP POST operation res, err := http.Post(url, "application/jso...
[ "func", "HTTPPost", "(", "url", "string", ",", "req", "interface", "{", "}", ",", "resp", "interface", "{", "}", ")", "error", "{", "// Convert the req to json", "jsonStr", ",", "err", ":=", "json", ".", "Marshal", "(", "req", ")", "\n", "if", "err", "...
// HTTPPost performs http POST operation
[ "HTTPPost", "performs", "http", "POST", "operation" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/utils/httputils.go#L89-L137
8,091
contiv/netplugin
utils/httputils.go
HTTPDel
func HTTPDel(url string) error { req, err := http.NewRequest("DELETE", url, nil) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() // Check the response code if res.StatusCode == http.StatusInternalServerError { eBody, err := ioutil.ReadAll(res.Body) if err != nil...
go
func HTTPDel(url string) error { req, err := http.NewRequest("DELETE", url, nil) res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() // Check the response code if res.StatusCode == http.StatusInternalServerError { eBody, err := ioutil.ReadAll(res.Body) if err != nil...
[ "func", "HTTPDel", "(", "url", "string", ")", "error", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "url", ",", "nil", ")", "\n\n", "res", ",", "err", ":=", "http", ".", "DefaultClient", ".", "Do", "(", "req", ")...
// HTTPDel performs http DELETE operation
[ "HTTPDel", "performs", "http", "DELETE", "operation" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/utils/httputils.go#L140-L165
8,092
contiv/netplugin
contivmodel/client/contivModelClient.go
NewContivClient
func NewContivClient(baseURL string) (*ContivClient, error) { ok, err := regexp.Match(`^https?://`, []byte(baseURL)) if !ok { return nil, errors.New("invalid URL: must begin with http:// or https://") } else if err != nil { return nil, err } client := ContivClient{ baseURL: baseURL, customReq...
go
func NewContivClient(baseURL string) (*ContivClient, error) { ok, err := regexp.Match(`^https?://`, []byte(baseURL)) if !ok { return nil, errors.New("invalid URL: must begin with http:// or https://") } else if err != nil { return nil, err } client := ContivClient{ baseURL: baseURL, customReq...
[ "func", "NewContivClient", "(", "baseURL", "string", ")", "(", "*", "ContivClient", ",", "error", ")", "{", "ok", ",", "err", ":=", "regexp", ".", "Match", "(", "`^https?://`", ",", "[", "]", "byte", "(", "baseURL", ")", ")", "\n", "if", "!", "ok", ...
// NewContivClient creates a new client instance
[ "NewContivClient", "creates", "a", "new", "client", "instance" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L233-L248
8,093
contiv/netplugin
contivmodel/client/contivModelClient.go
SetAuthToken
func (c *ContivClient) SetAuthToken(token string) error { // setting an auth token is only allowed on secure requests. // if we didn't enforce this, the client could potentially send auth // tokens in plain text across the network. if !c.isHTTPS() { return errors.New("setting auth token requires a https auth_pro...
go
func (c *ContivClient) SetAuthToken(token string) error { // setting an auth token is only allowed on secure requests. // if we didn't enforce this, the client could potentially send auth // tokens in plain text across the network. if !c.isHTTPS() { return errors.New("setting auth token requires a https auth_pro...
[ "func", "(", "c", "*", "ContivClient", ")", "SetAuthToken", "(", "token", "string", ")", "error", "{", "// setting an auth token is only allowed on secure requests.", "// if we didn't enforce this, the client could potentially send auth", "// tokens in plain text across the network.", ...
// SetAuthToken sets the token used to authenticate with auth_proxy
[ "SetAuthToken", "sets", "the", "token", "used", "to", "authenticate", "with", "auth_proxy" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L265-L286
8,094
contiv/netplugin
contivmodel/client/contivModelClient.go
Login
func (c *ContivClient) Login(username, password string) (*http.Response, []byte, error) { // login is only allowed over a secure channel if !c.isHTTPS() { return nil, nil, errors.New("login requires a https auth_proxy URL") } url := c.baseURL + LoginPath // create the POST payload for login lp := loginPayloa...
go
func (c *ContivClient) Login(username, password string) (*http.Response, []byte, error) { // login is only allowed over a secure channel if !c.isHTTPS() { return nil, nil, errors.New("login requires a https auth_proxy URL") } url := c.baseURL + LoginPath // create the POST payload for login lp := loginPayloa...
[ "func", "(", "c", "*", "ContivClient", ")", "Login", "(", "username", ",", "password", "string", ")", "(", "*", "http", ".", "Response", ",", "[", "]", "byte", ",", "error", ")", "{", "// login is only allowed over a secure channel", "if", "!", "c", ".", ...
// Login performs a login to auth_proxy and returns the response and body
[ "Login", "performs", "a", "login", "to", "auth_proxy", "and", "returns", "the", "response", "and", "body" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L301-L334
8,095
contiv/netplugin
contivmodel/client/contivModelClient.go
addCustomRequestHeader
func (c *ContivClient) addCustomRequestHeader(name, value string) { // lowercase the header name so we can easily check for duplicates in other places. // there can legitimately be many headers with the same name, but in some cases // (e.g., auth token) we want to enforce that there is only one. // Go internally c...
go
func (c *ContivClient) addCustomRequestHeader(name, value string) { // lowercase the header name so we can easily check for duplicates in other places. // there can legitimately be many headers with the same name, but in some cases // (e.g., auth token) we want to enforce that there is only one. // Go internally c...
[ "func", "(", "c", "*", "ContivClient", ")", "addCustomRequestHeader", "(", "name", ",", "value", "string", ")", "{", "// lowercase the header name so we can easily check for duplicates in other places.", "// there can legitimately be many headers with the same name, but in some cases",...
// addCustomRequestHeader records a custom request header to be added to all outgoing requests
[ "addCustomRequestHeader", "records", "a", "custom", "request", "header", "to", "be", "added", "to", "all", "outgoing", "requests" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L337-L346
8,096
contiv/netplugin
contivmodel/client/contivModelClient.go
processCustomHeaders
func (c *ContivClient) processCustomHeaders(req *http.Request) { for _, pair := range c.customRequestHeaders { req.Header.Add(pair[0], pair[1]) } }
go
func (c *ContivClient) processCustomHeaders(req *http.Request) { for _, pair := range c.customRequestHeaders { req.Header.Add(pair[0], pair[1]) } }
[ "func", "(", "c", "*", "ContivClient", ")", "processCustomHeaders", "(", "req", "*", "http", ".", "Request", ")", "{", "for", "_", ",", "pair", ":=", "range", "c", ".", "customRequestHeaders", "{", "req", ".", "Header", ".", "Add", "(", "pair", "[", ...
// processCustomHeaders adds all custom request headers to the target request. // this function is called before a GET, POST, or DELETE is sent by the client.
[ "processCustomHeaders", "adds", "all", "custom", "request", "headers", "to", "the", "target", "request", ".", "this", "function", "is", "called", "before", "a", "GET", "POST", "or", "DELETE", "is", "sent", "by", "the", "client", "." ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L350-L354
8,097
contiv/netplugin
contivmodel/client/contivModelClient.go
AciGwPost
func (c *ContivClient) AciGwPost(obj *AciGw) error { // build key and URL keyStr := obj.Name url := c.baseURL + "/api/v1/aciGws/" + keyStr + "/" // http post the object err := c.httpPost(url, obj) if err != nil { log.Debugf("Error creating aciGw %+v. Err: %v", obj, err) return err } return nil }
go
func (c *ContivClient) AciGwPost(obj *AciGw) error { // build key and URL keyStr := obj.Name url := c.baseURL + "/api/v1/aciGws/" + keyStr + "/" // http post the object err := c.httpPost(url, obj) if err != nil { log.Debugf("Error creating aciGw %+v. Err: %v", obj, err) return err } return nil }
[ "func", "(", "c", "*", "ContivClient", ")", "AciGwPost", "(", "obj", "*", "AciGw", ")", "error", "{", "// build key and URL", "keyStr", ":=", "obj", ".", "Name", "\n", "url", ":=", "c", ".", "baseURL", "+", "\"", "\"", "+", "keyStr", "+", "\"", "\"",...
// AciGwPost posts the aciGw object
[ "AciGwPost", "posts", "the", "aciGw", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L887-L900
8,098
contiv/netplugin
contivmodel/client/contivModelClient.go
AciGwList
func (c *ContivClient) AciGwList() (*[]*AciGw, error) { // build key and URL url := c.baseURL + "/api/v1/aciGws/" // http get the object var objList []*AciGw err := c.httpGet(url, &objList) if err != nil { log.Debugf("Error getting aciGws. Err: %v", err) return nil, err } return &objList, nil }
go
func (c *ContivClient) AciGwList() (*[]*AciGw, error) { // build key and URL url := c.baseURL + "/api/v1/aciGws/" // http get the object var objList []*AciGw err := c.httpGet(url, &objList) if err != nil { log.Debugf("Error getting aciGws. Err: %v", err) return nil, err } return &objList, nil }
[ "func", "(", "c", "*", "ContivClient", ")", "AciGwList", "(", ")", "(", "*", "[", "]", "*", "AciGw", ",", "error", ")", "{", "// build key and URL", "url", ":=", "c", ".", "baseURL", "+", "\"", "\"", "\n\n", "// http get the object", "var", "objList", ...
// AciGwList lists all aciGw objects
[ "AciGwList", "lists", "all", "aciGw", "objects" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L903-L916
8,099
contiv/netplugin
contivmodel/client/contivModelClient.go
AciGwDelete
func (c *ContivClient) AciGwDelete(name string) error { // build key and URL keyStr := name url := c.baseURL + "/api/v1/aciGws/" + keyStr + "/" // http get the object err := c.httpDelete(url) if err != nil { log.Debugf("Error deleting aciGw %s. Err: %v", keyStr, err) return err } return nil }
go
func (c *ContivClient) AciGwDelete(name string) error { // build key and URL keyStr := name url := c.baseURL + "/api/v1/aciGws/" + keyStr + "/" // http get the object err := c.httpDelete(url) if err != nil { log.Debugf("Error deleting aciGw %s. Err: %v", keyStr, err) return err } return nil }
[ "func", "(", "c", "*", "ContivClient", ")", "AciGwDelete", "(", "name", "string", ")", "error", "{", "// build key and URL", "keyStr", ":=", "name", "\n", "url", ":=", "c", ".", "baseURL", "+", "\"", "\"", "+", "keyStr", "+", "\"", "\"", "\n\n", "// ht...
// AciGwDelete deletes the aciGw object
[ "AciGwDelete", "deletes", "the", "aciGw", "object" ]
965773066d2b8ebed3514979949061a03d46fd20
https://github.com/contiv/netplugin/blob/965773066d2b8ebed3514979949061a03d46fd20/contivmodel/client/contivModelClient.go#L936-L949