anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func (d *OvsDriver) InspectNameserver() ([]byte, error) {\n\tif d.nameServer == nil {\n\t\treturn []byte{}, nil\n\t}\n\n\tns, err := d.nameServer.InspectState()\n\tjsonState, err := json.Marshal(ns)\n\tif err !=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\tlog.Errorf(\"Error encoding nameserver state. Err: %v\", err)\n\t\treturn []byte{}, err\n\t}\n\n\treturn jsonState, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " subvolDelete(d.subvolumesDir(), id, d.quotaEnabled); err != nil {\n\t\treturn err\n\t}\n\tif err := system.EnsureRemoveAll(dir); err != nil {\n\t\treturn err\n\t}\n\tif err := d.subvolRescanQuota(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (cp *consulPlugin) NewClient(endpoints []string) (API, error) {\n\tcc := new(ConsulClient)\n\n\tif len(endpoints) == 0 {\n\t\tendpoints = []string{\"127.0.0.1:8500\"}\n\t}\n\n\t// default consul config\n\tcc.consulConfig = api.Config{Address: strings.TrimPrefix(endpoints[... | {
"audio": "",
"image": "",
"text": " consul client\")\n\t\treturn nil, err\n\t}\n\n\tcc.client = client\n\n\t// verify we can reach the consul\n\t_, _, err = client.KV().List(\"/\", nil)\n\tif err != nil {\n\t\tif api.IsServerError(err) || strings.Contains(err.Error(), \"EOF\") ||\n\t\t\tstrings.Contains(err.Err... | {
"audio": "",
"image": "",
"text": "\n\t\t\tProviderSpecific: providerSpecific,\n\t\t}\n\t\tendpoints = append(endpoints, epA)\n\t}\n\n\tif len(cnameTargets) > 0 {\n\t\tepCNAME := &endpoint.Endpoint{\n\t\t\tDNSName: strings.TrimSuffix(hostname, \".\"),\n\t\t\tTargets: cnameTargets,\n\t\t\tRecor... |
{
"audio": "",
"image": "",
"text": "func (cp *ConsulClient) GetObj(key string, retVal interface{}) error {\n\tkey = processKey(\"/contiv.io/obj/\" + processKey(key))\n\n\tresp, _, err := cp.client.KV().Get(key, &api.QueryOptions{RequireConsistent: true})\n\tif err != nil {\n\t\tif api.IsServerError(err) || strin... | {
"audio": "",
"image": "",
"text": "\t}\n\t}\n\t// Consul returns success and a nil kv when a key is not found,\n\t// translate it to 'Key not found' error\n\tif resp == nil {\n\t\treturn errors.New(\"Key not found\")\n\t}\n\n\t// Parse JSON response\n\tif err := json.Unmarshal(resp.Value, retVal); err != nil {\... | {
"audio": "",
"image": "",
"text": " i := 0; i < 3; i++ {\n\t\tresp, err = s.cs.newRequest(\"queryAsyncJobResult\", p.toURLValues())\n\t\tif err == nil {\n\t\t\tbreak\n\t\t}\n\t\ttime.Sleep(500 * time.Millisecond)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar r QueryAsyncJobResultResponse\n\tif err ... |
{
"audio": "",
"image": "",
"text": "func (cp *ConsulClient) ListDir(key string) ([]string, error) {\n\tkey = processKey(\"/contiv.io/obj/\" + processKey(key))\n\n\tkvs, _, err := cp.client.KV().List(key, nil)\n\tif err != nil {\n\t\tif api.IsServerError(err) || strings.Contains(err.Error(), \"EOF\") ||\n\t\t\tst... | {
"audio": "",
"image": "",
"text": "\t\t\treturn nil, err\n\t\t}\n\t}\n\t// Consul returns success and a nil kv when a key is not found,\n\t// translate it to 'Key not found' error\n\tif kvs == nil {\n\t\treturn []string{}, nil\n\t}\n\n\tvar keys []string\n\tfor _, kv := range kvs {\n\t\tkeys = append(keys, stri... | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\t\treturn esResp, err\n\t\t}\n\t}\n\n\tif req.api == \"_bulk\" && esResp.Errors {\n\t\tfor _, item := range esResp.Items {\n\t\t\tfor _, i := range item {\n\t\t\t\tif i.Error != \"\" {\n\t\t\t\t\treturn esResp, &SearchError{i.Error, i.Status}\n\t\t\t\t}\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (cp *ConsulClient) SetObj(key string, value interface{}) error {\n\tkey = processKey(\"/contiv.io/obj/\" + processKey(key))\n\n\t// JSON format the object\n\tjsonVal, err := json.Marshal(value)\n\tif err != nil {\n\t\tlog.Errorf(\"Json conversion error. Err %v\", err)\n\t... | {
"audio": "",
"image": "",
"text": " jsonVal}, nil)\n\tif err != nil {\n\t\tif api.IsServerError(err) || strings.Contains(err.Error(), \"EOF\") ||\n\t\t\tstrings.Contains(err.Error(), \"connection refused\") {\n\t\t\tfor i := 0; i < maxConsulRetries; i++ {\n\t\t\t\t_, err = cp.client.KV().Put(&api.KVPair{Key: ke... | {
"audio": "",
"image": "",
"text": "\n\t\tkey, err := item.Key.Link(scope, m.KeySpec)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvalue, err := item.Value.Link(scope, m.ValueSpec)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// TODO(abg): Duplicate key check\n\t\titems[i] = ConstantVal... |
{
"audio": "",
"image": "",
"text": "func (cp *ConsulClient) DelObj(key string) error {\n\tkey = processKey(\"/contiv.io/obj/\" + processKey(key))\n\t_, err := cp.client.KV().Delete(key, nil)\n\tif err != nil {\n\t\tif api.IsServerError(err) || strings.Contains(err.Error(), \"EOF\") ||\n\t\t\tstrings.Contains(err... | {
"audio": "",
"image": "",
"text": " maxConsulRetries; i++ {\n\t\t\t\t_, err = cp.client.KV().Delete(key, nil)\n\t\t\t\tif err == nil {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\n\t\t\t\t// Retry after a delay\n\t\t\t\ttime.Sleep(time.Second)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\t\treturn esResp, err\n\t\t}\n\t}\n\n\tif req.api == \"_bulk\" && esResp.Errors {\n\t\tfor _, item := range esResp.Items {\n\t\t\tfor _, i := range item {\n\t\t\t\tif i.Error != \"\" {\n\t\t\t\t\treturn esResp, &SearchError{i.Error, i.Status}\n\t\t\t\t}\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (d *ConsulStateDriver) ClearState(key string) error {\n\tkey = processKey(key)\n\t_, err :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " d.Client.KV().Delete(key, nil)\n\treturn err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string\n\t\tif items != nil {\n\t\t\tkey = items.Key\n\t\t}\n\t\tkeys[i] = key\n\t}\n\treturn keys\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *ConsulStateDriver) ReadState(key string, value core.State,\n\tunmarshal func([]byte, interface{}) error) error {\n\tkey = processKey(key)\n\tencodedState,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := d.Read(key)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn unmarshal(encodedState, value)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(registry *registry) error {\n\t\tregistry.schema1SigningKey = key\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *ConsulStateDriver) ReadAllState(baseKey string, sType core.State,\n\tunmarshal func([]byte,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " interface{}) error) ([]core.State, error) {\n\tbaseKey = processKey(baseKey)\n\treturn readAllStateCommon(d, baseKey, sType, unmarshal)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string) (string, []byte, bool) {\n\treturn \"\", nil, false\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func AddLink(link *Link, obj ModelObj) {\n\tlink.ObjType = obj.GetType()",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tlink.ObjKey = obj.GetKey()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " html.Link.ClrB = 0, 0, 128\n\thtml.Link.Bold, html.Link.Italic, html.Link.Underscore = false, false, true\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func AddLinkSet(linkSet *(map[string]Link), obj ModelObj) error {\n\t// Allocate the linkset if its nil\n\tif *linkSet == nil {\n\t\t*linkSet = make(map[string]Link)\n\t}\n\n\t// add the link to map\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t(*linkSet)[obj.GetKey()] = Link{\n\t\tObjType: obj.GetType(),\n\t\tObjKey: obj.GetKey(),\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ok := s.interfaceIndex[peerPub]; !ok {\n\t\ts.interfaceIndex[peerPub] = make(map[lnwire.ChannelID]ChannelLink)\n\t}\n\ts.interfaceIndex[peerPub][link.ChanID()] = link\n\n\t// Inform the channel notifier if the link has become active.\n\tif link.EligibleToForward() {\n\t\ts.cf... |
{
"audio": "",
"image": "",
"text": "func RemoveLinkSet(linkSet *(map[string]Link), obj ModelObj) error {\n\t// check is linkset is nil\n\tif *linkSet == nil {\n\t\treturn nil\n\t}\n\n\t// remove",
"video": ""
} | {
"audio": "",
"image": "",
"text": " the link from map\n\tdelete(*linkSet, obj.GetKey())\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " is not allowed\", key)\n\t\t}\n\n\t\t// Check that value is allowed\n\t\tif len(permVals) > 0 {\n\t\t\t_, ok = permVals[val]\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"key %v does not allow value %v\", key, val)\n\t\t\t}\n\t\t}\n\t}\n\n\tpl.Pairs[key] = val\n\treturn nil\n}... |
{
"audio": "",
"image": "",
"text": "func WriteObj(objType, objKey string, value interface{}) error {\n\tkey := \"/modeldb/\" + objType + \"/\" +",
"video": ""
} | {
"audio": "",
"image": "",
"text": " objKey\n\terr := cdb.SetObj(key, value)\n\tif err != nil {\n\t\tlog.Errorf(\"Error storing object %s. Err: %v\", key, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\t\taclPolicyRefs[key] = \"/\" + ChannelGroupKey + \"/\" + ApplicationGroupKey + \"/\" + acl.PolicyRef\n\t\t} else {\n\t\t\taclPolicyRefs[key] = acl.PolicyRef\n\t\t}\n\t}\n\n\treturn &aclsProvider{\n\t\taclPolicyRefs: aclPolicyRefs,\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ReadObj(objType, objKey string, retVal interface{}) error {\n\tkey := \"/modeldb/\" + objType + \"/\" +",
"video": ""
} | {
"audio": "",
"image": "",
"text": " objKey\n\terr := cdb.GetObj(key, retVal)\n\tif err != nil {\n\t\tlog.Errorf(\"Error reading object: %s. Err: %v\", key, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\t\taclPolicyRefs[key] = \"/\" + ChannelGroupKey + \"/\" + ApplicationGroupKey + \"/\" + acl.PolicyRef\n\t\t} else {\n\t\t\taclPolicyRefs[key] = acl.PolicyRef\n\t\t}\n\t}\n\n\treturn &aclsProvider{\n\t\taclPolicyRefs: aclPolicyRefs,\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func DeleteObj(objType, objKey string) error {\n\tkey := \"/modeldb/\" + objType + \"/\" + objKey\n\terr := cdb.DelObj(key)\n\tif err !=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\tlog.Errorf(\"Error deleting object: %s. Err: %v\", key, err)\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tkey := name\n\tfor _, k := range keys {\n\t\tkey = key + tagsSep + k + tagKVSep + tags[k]\n\t}\n\treturn key\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func ReadAllObj(objType string) ([]string, error) {\n\tkey :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"/modeldb/\" + objType + \"/\"\n\treturn cdb.ListDir(key)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(registry *registry) error {\n\t\tregistry.schema1SigningKey = key\n\t\treturn nil\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func GetEndpointGroupID(stateDriver core.StateDriver, groupName, tenantName string) (int, error) {\n\t// If service name is not specified, we are done\n\tif groupName == \"\" {\n\t\treturn 0, nil\n\t}\n\n\tepgKey := GetEndpointGroupKey(groupName, tenantName)\n\tcfgEpGroup := &... | {
"audio": "",
"image": "",
"text": " {\n\t\tlog.Errorf(\"Error finding epg: %s. Err: %v\", epgKey, err)\n\t\treturn 0, core.Errorf(\"EPG not found\")\n\t}\n\n\t// return endpoint group id\n\treturn cfgEpGroup.EndpointGroupID, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func getGwCIDR(epgObj *contivModel.EndpointGroup, stateDriver core.StateDriver) (string, error) {\n\t// get the subnet info and add it to ans\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\tnetworkID := epgObj.NetworkName + \".\" + epgObj.TenantN... | {
"audio": "",
"image": "",
"text": "\tlog.Errorf(\"Failed to network info %v %v \", networkID, nErr)\n\t\treturn \"\", nErr\n\t}\n\tgw := nwCfg.Gateway + \"/\" + strconv.Itoa(int(nwCfg.SubnetLen))\n\tlog.Debugf(\"GW is %s for epg %s\", gw, epgObj.GroupName)\n\treturn gw, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func addPolicyContracts(csMap map[string]*contrSpec, epg *epgSpec, policy *contivModel.Policy) error {\n\n\tfor ruleName := range policy.LinkSets.Rules {\n\t\trule := contivModel.FindRule(ruleName)\n\t\tif rule == nil {\n\t\t\terrStr := fmt.Sprintf(\"rule %v not found\", ruleN... | {
"audio": "",
"image": "",
"text": " ACI mode\", ruleName)\n\t\t\treturn errors.New(errStr)\n\t\t}\n\n\t\tif rule.Action == \"deny\" {\n\t\t\tlog.Debugf(\"==Ignoring deny rule %v\", ruleName)\n\t\t\tcontinue\n\t\t}\n\n\t\tfilter := filterInfo{Protocol: rule.Protocol, ServPort: strconv.Itoa(rule.Port)}\n\t\tcn :=... | {
"audio": "",
"image": "",
"text": " \"\" {\n\t\tepg = contivModel.FindEndpointGroup(epgKey)\n\t\tif epg != nil {\n\t\t\tmodeldb.RemoveLinkSet(&epg.LinkSets.MatchRules, rule)\n\t\t}\n\t}\n\n\t// Trigger policyDB Update\n\terr = master.PolicyDelRule(policy, rule)\n\tif err != nil {\n\t\tlog.Errorf(\"Error deletin... |
{
"audio": "",
"image": "",
"text": "func CreateAppNw(app *contivModel.AppProfile) error {\n\taciPresent, aErr := master.IsAciConfigured()\n\tif aErr != nil {\n\t\tlog.Errorf(\"Couldn't read global config %v\", aErr)\n\t\treturn aErr\n\t}\n\n\tif !aciPresent {\n\t\tlog.Debugf(\"ACI not configured\")\n\t\treturn n... | {
"audio": "",
"image": "",
"text": "\t\treturn errors.New(err)\n\t\t}\n\n\t\tif err := appendEpgInfo(eMap, epgObj, stateDriver); err != nil {\n\t\t\tlog.Errorf(\"Error getting epg info %v\", err)\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// walk the map and add to ANS\n\tfor _, epg := range eMap.Specs {\n\t\tans.Epgs =... | {
"audio": "",
"image": "",
"text": " \"\" {\n\t\tepg = contivModel.FindEndpointGroup(epgKey)\n\t\tif epg != nil {\n\t\t\tmodeldb.RemoveLinkSet(&epg.LinkSets.MatchRules, rule)\n\t\t}\n\t}\n\n\t// Trigger policyDB Update\n\terr = master.PolicyDelRule(policy, rule)\n\tif err != nil {\n\t\tlog.Errorf(\"Error deletin... |
{
"audio": "",
"image": "",
"text": "func DeleteAppNw(app *contivModel.AppProfile) error {\n\taciPresent, aErr := master.IsAciConfigured()\n\tif aErr != nil {\n\t\tlog.Errorf(\"Couldn't read global config %v\", aErr)\n\t\treturn aErr\n\t}\n\n\tif !aciPresent {\n\t\tlog.Debugf(\"ACI not configured\")\n\t\treturn n... | {
"audio": "",
"image": "",
"text": "\tlog.Errorf(\"Delete failed. Error: %v\", err)\n\t\treturn err\n\t}\n\n\tif resp.Result != \"success\" {\n\t\tlog.Errorf(\"Delete failed %v - %v\", resp.Result, resp.Info)\n\t}\n\n\ttime.Sleep(time.Second)\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tans := <-wschannel\n\treturn ans.Table\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (cp *ConsulClient) NewLock(name string, myID string, ttl uint64) (LockInterface, error) {\n\t// Create a lock\n\treturn &consulLock{\n\t\tname: name,\n\t\tkeyName: \"contiv.io/lock/\" + name,\n\t\tmyID: myID,\n\t\tttl:",
"video": ""
} | {
"audio": "",
"image": "",
"text": " fmt.Sprintf(\"%ds\", ttl),\n\t\teventChan: make(chan LockEvent, 1),\n\t\tstopChan: make(chan struct{}, 1),\n\t\tmutex: new(sync.Mutex),\n\t\tclient: cp.client,\n\t}, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (lk *consulLock) IsReleased() bool {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tlk.mutex.Lock()\n\tdefer lk.mutex.Unlock()\n\treturn lk.isReleased\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool {\n\treturn func(err error) bool {\n\t\treturn Cause(err) == cause\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (lk *consulLock) createSession() error {\n\t// session configuration\n\tsessCfg := api.SessionEntry{\n\t\tName: lk.keyName,\n\t\tBehavior: \"delete\",\n\t\tLockDelay: 10 * time.Millisecond,\n\t\tTTL: lk.ttl,\n\t}\n\n\t// Create consul session\n\tsessionID, _, ... | {
"audio": "",
"image": "",
"text": " := lk.client.Session().CreateNoChecks(&sessCfg, nil)\n\tif err != nil {\n\t\tlog.Errorf(\"Error Creating session for lock %s. Err: %v\", lk.keyName, err)\n\t\treturn err\n\t}\n\n\tlog.Infof(\"Created session: %s for lock %s/%s\", sessionID, lk.name, lk.myID)\n\n\t// save the ... | {
"audio": "",
"image": "",
"text": "\tlk.Lock()\n\tfn()\n\tlk.Unlock()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (lk *consulLock) renewSession() {\n\tfor {\n\t\terr := lk.client.Session().RenewPeriodic(lk.ttl, lk.sessionID, nil, lk.stopChan)\n\t\tif err == nil || lk.IsReleased() {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\t// If lock was released, exit this go routine\n\t\t\treturn\n\t\t}\n\n\t\t// Create new consul session\n\t\terr = lk.createSession()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error Creating session for lock %s. Err: %v\", lk.keyName, err)\n\t\t}\n\t}\n\n}",
"video": ""
... | {
"audio": "",
"image": "",
"text": "\tlk.Lock()\n\tfn()\n\tlk.Unlock()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func GetEndpoint(epID string) (*drivers.OperEndpointState, error) {\n\t// Get hold of the state driver\n\tstateDriver, err := GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\toperEp := &drivers.OperEndpointState{}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\toperEp.StateDriver = stateDriver\n\terr = operEp.Read(epID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn operEp, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func NewOvsdbDriver(bridgeName string, failMode string, vxlanUDPPort int) (*OvsdbDriver, error) {\n\t// Create a new driver instance\n\td := new(OvsdbDriver)\n\td.bridgeName = bridgeName\n\td.vxlanUDPPort = fmt.Sprintf(\"%d\", vxlanUDPPort)\n\n\t// Connect to OVS\n\tovs, err :... | {
"audio": "",
"image": "",
"text": " driver, only create the bridge\n\t// if it's not already created\n\t// XXX: revisit if the bridge-name needs to be configurable\n\tbrCreated := false\n\tfor _, row := range d.cache[bridgeTable] {\n\t\tif row.Fields[\"name\"] == bridgeName {\n\t\t\tbrCreated = true\n\t\t\tbrea... | {
"audio": "",
"image": "",
"text": " == next {\n\t\t\t\t// This fragment completes the next\n\t\t\t\t// contiguous swathe of bytes to be\n\t\t\t\t// written out.\n\t\t\t\tn, err := d.writeConsecutive(dst, frag)\n\t\t\t\td.written += n\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn d.written, err\n\t\t\t\t}\n\t\t\t} ... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) Update(context interface{}, tableUpdates libovsdb.TableUpdates) {\n\td.populateCache(tableUpdates)\n\tintfUpds, ok := tableUpdates.Updates[\"Interface\"]\n\tif !ok {\n\t\treturn\n\t}\n\n\tfor _, intfUpd := range intfUpds.Rows {\n\t\tintf := intfUpd.New.Fi... | {
"audio": "",
"image": "",
"text": " || d.ovsSwitch == nil {\n\t\t\treturn\n\t\t}\n\n\t\tlinkUpd := ofnet.LinkUpdateInfo{\n\t\t\tLinkName: intf.(string),\n\t\t\tLacpStatus: newLacpStatus.(bool),\n\t\t}\n\t\tlog.Debugf(\"LACP_UPD: Interface: %+v. LACP Status - (Old: %+v, New: %+v)\\n\", intf, oldLacpStatus, new... | {
"audio": "",
"image": "",
"text": "\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, row := range op.Rows {\n\t\t\t\tfor column := range row {\n\t\t\t\t\tif _, ok := table.Columns[column]; !ok {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, column := range op.Columns {\n\t\t\t\ti... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) createDeleteBridge(bridgeName, failMode string, op oper) error {\n\tnamedUUIDStr := \"netplugin\"\n\tbrUUID := []libovsdb.UUID{{GoUuid: namedUUIDStr}}\n\tprotocols := []string{\"OpenFlow10\", \"OpenFlow11\", \"OpenFlow12\", \"OpenFlow13\"}\n\topStr := \"i... | {
"audio": "",
"image": "",
"text": "\t\tfor uuid, row := range d.cache[bridgeTable] {\n\t\t\tname := row.Fields[\"name\"].(string)\n\t\t\tif name == bridgeName {\n\t\t\t\tbrUUID = []libovsdb.UUID{uuid}\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\t// Inserting/Deleting a Bridge row in Bridge table requires mutating\n... | {
"audio": "",
"image": "",
"text": " range c.Operation {\n\t\t\tif op.State != OpReady {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif len(op.Pkg.Local) > longestLen {\n\t\t\t\tlongestLen = len(op.Pkg.Local)\n\t\t\t\tlongestIndex = i\n\t\t\t}\n\t\t}\n\t\tc.OpIndex = longestIndex\n\t\tc.Resolved = true\n\t}\n\treturn cc... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) GetPortOrIntfNameFromID(id string, isPort bool) (string, error) {\n\ttable := portTable\n\tif !isPort {\n\t\ttable = interfaceTable\n\t}\n\n\td.cacheLock.RLock()\n\tdefer d.cacheLock.RUnlock()\n\n\t// walk thru all ports\n\tfor _, row := range d.cache[tab... | {
"audio": "",
"image": "",
"text": "\t\t\textIDMap := extIDs.(libovsdb.OvsMap).GoMap\n\t\t\tif portID, ok := extIDMap[\"endpoint-id\"]; ok && portID == id {\n\t\t\t\treturn row.Fields[\"name\"].(string), nil\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\", core.Errorf(\"Ovs port/intf not found for id: %s\", id)\n}",
"vide... | {
"audio": "",
"image": "",
"text": "\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, row := range op.Rows {\n\t\t\t\tfor column := range row {\n\t\t\t\t\tif _, ok := table.Columns[column]; !ok {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, column := range op.Columns {\n\t\t\t\ti... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) CreatePort(intfName, intfType, id string, tag, burst int, bandwidth int64) error {\n\t// intfName is assumed to be unique enough to become uuid\n\tportUUIDStr := intfName\n\tintfUUIDStr := fmt.Sprintf(\"Intf%s\", intfName)\n\tportUUID := []libovsdb.UUID{{... | {
"audio": "",
"image": "",
"text": "\n\t// interface table ops\n\tintfOp = libovsdb.Operation{\n\t\tOp: opStr,\n\t\tTable: interfaceTable,\n\t\tRow: intf,\n\t\tUUIDName: intfUUIDStr,\n\t}\n\n\t// insert/delete a row in Port table\n\tportOp := libovsdb.Operation{}\n\tport := make(map[string]interfac... | {
"audio": "",
"image": "",
"text": " after\n\terr = before.IterateValidators(func(id crypto.Addressable, powerBefore *big.Int) error {\n\t\tpowerAfter, err := after.Power(id.GetAddress())\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// If there is a difference value then add to diff\n\t\tif powerAfter.Cmp(... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) GetInterfacesInPort(portName string) []string {\n\tvar intfList []string\n\td.cacheLock.RLock()\n\tdefer d.cacheLock.RUnlock()\n\n\tfor _, row := range d.cache[\"Port\"] {\n\t\tname := row.Fields[\"name\"].(string)\n\t\tif name == portName {\n\t\t\t// Por... | {
"audio": "",
"image": "",
"text": "\t\t\t}\n\t\t\t\tintfList = append(intfList, intfInfo.Fields[\"name\"].(string))\n\t\t\tcase libovsdb.OvsSet: // Port bond case\n\t\t\t\tintfUUIDList := row.Fields[\"interfaces\"].(libovsdb.OvsSet)\n\t\t\t\tfor _, intfUUID := range intfUUIDList.GoSet {\n\t\t\t\t\tintfInfo := d... | {
"audio": "",
"image": "",
"text": " %s\", columns, d.quoted(table), d.quoted(pkName), d.Placeholder)\n\n\trows, err := db.Query(q, pk)\n\tif err != nil {\n\t\treturn &dbErr{msg: \"meddler.Load: DB error in Query\", err: err}\n\t}\n\n\t// scan the row\n\treturn d.ScanRow(rows, dst)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) GetIntfInfo(uuid libovsdb.UUID) libovsdb.Row {\n\td.cacheLock.RLock()\n\tdefer d.cacheLock.RUnlock()\n\n\tfor intfUUID, row := range d.cache[\"Interface\"]",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\tif intfUUID == uuid {\n\t\t\treturn row\n\t\t}\n\t}\n\n\treturn libovsdb.Row{}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tfor s := range d.myAdvertisedServices {\n\t\tservices = append(services, s)\n\t}\n\td.watchedMutex.RUnlock()\n\tfor _, serviceName := range services {\n\t\td.DeleteAdvertisedService(serviceName)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) CreatePortBond(intfList []string, bondName string) error {\n\n\tvar err error\n\tvar ops []libovsdb.Operation\n\tvar intfUUIDList []libovsdb.UUID\n\topStr := \"insert\"\n\n\t// Add all the interfaces to the interface table\n\tfor _, intf := range intfList... | {
"audio": "",
"image": "",
"text": "\tport[\"bond_mode\"] = \"balance-tcp\"\n\n\tport[\"lacp\"] = \"active\"\n\tlacpMap := make(map[string]string)\n\tlacpMap[\"lacp-fallback-ab\"] = \"true\"\n\tport[\"other_config\"], err = libovsdb.NewOvsMap(lacpMap)\n\n\tportUUIDStr := bondName\n\tportUUID := []libovsdb.UUID{{... | {
"audio": "",
"image": "",
"text": " the ports and generate a named listener for\n\t\t// each port.\n\t\tfor _, port := range svc.Ports {\n\t\t\t// Only listen on ServicePorts\n\t\t\tif port.ServicePort < 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tlisteners = append(listeners, s.EnvoyListenerFromService(svc, port.S... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) DeletePortBond(bondName string, intfList []string) error {\n\n\tvar ops []libovsdb.Operation\n\tvar condition []interface{}\n\tportUUIDStr := bondName\n\tportUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}}\n\topStr := \"delete\"\n\n\tfor _, intfName := ran... | {
"audio": "",
"image": "",
"text": "\t}\n\td.cacheLock.RUnlock()\n\n\t// mutate the Ports column of the row in the Bridge table\n\tmutateSet, _ := libovsdb.NewOvsSet(portUUID)\n\tmutation := libovsdb.NewMutation(\"ports\", opStr, mutateSet)\n\tcondition = libovsdb.NewCondition(\"name\", \"==\", d.bridgeName)\n\t... | {
"audio": "",
"image": "",
"text": "\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, row := range op.Rows {\n\t\t\t\tfor column := range row {\n\t\t\t\t\tif _, ok := table.Columns[column]; !ok {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, column := range op.Columns {\n\t\t\t\ti... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) UpdatePolicingRate(intfName string, burst int, bandwidth int64) error {\n\tbw := int(bandwidth)\n\tintf := make(map[string]interface{})\n\tintf[\"ingress_policing_rate\"] = bw\n\tintf[\"ingress_policing_burst\"] = burst\n\n\tcondition := libovsdb.NewCondi... | {
"audio": "",
"image": "",
"text": "\n\t}\n\tmutateOp := libovsdb.Operation{\n\t\tOp: \"update\",\n\t\tTable: interfaceTable,\n\t\tRow: intf,\n\t\tWhere: []interface{}{condition},\n\t}\n\n\toperations := []libovsdb.Operation{mutateOp}\n\treturn d.performOvsdbOps(operations)\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t} else if c.Type == ConditionAnd {\n\t\tc.Inner = append(c.Inner, condition...)\n\t\treturn c\n\t}\n\n\tinner := append([]Condition{c}, condition...)\n\treturn And(inner...)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) CreateVtep(intfName string, vtepRemoteIP string) error {\n\tportUUIDStr := intfName\n\tintfUUIDStr := fmt.Sprintf(\"Intf%s\", intfName)\n\tportUUID := []libovsdb.UUID{{GoUuid: portUUIDStr}}\n\tintfUUID := []libovsdb.UUID{{GoUuid: intfUUIDStr}}\n\topStr :=... | {
"audio": "",
"image": "",
"text": " {\n\t\tlog.Errorf(\"error '%s' creating options from %v \\n\", err, intfOptions)\n\t\treturn err\n\t}\n\n\t// Add an entry in Interface table\n\tintfOp := libovsdb.Operation{\n\t\tOp: opStr,\n\t\tTable: interfaceTable,\n\t\tRow: intf,\n\t\tUUIDName: intfUUIDStr,... | {
"audio": "",
"image": "",
"text": " the ports and generate a named listener for\n\t\t// each port.\n\t\tfor _, port := range svc.Ports {\n\t\t\t// Only listen on ServicePorts\n\t\t\tif port.ServicePort < 1 {\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tlisteners = append(listeners, s.EnvoyListenerFromService(svc, port.S... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) GetOfpPortNo(intfName string) (uint32, error) {\n\tretryNo := 0\n\tcondition := libovsdb.NewCondition(\"name\", \"==\", intfName)\n\tselectOp := libovsdb.Operation{\n\t\tOp: \"select\",\n\t\tTable: \"Interface\",\n\t\tWhere: []interface{}{condition},\n... | {
"audio": "",
"image": "",
"text": " and populating ovsdb entry for the interface\n\t\t\t\t//may not be populated instantly.\n\t\t\t\tif ofpPort := reflect.ValueOf(value).Float(); ofpPort != -1 {\n\t\t\t\t\treturn uint32(ofpPort), nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ttime.Sleep(300 * time.Millisecond)\n\n\t\tif r... | {
"audio": "",
"image": "",
"text": " += s\n\t\t\t}\n\t\t\treturn sum\n\t\t}\n\n\tcase reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,\n\t\treflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,\n\t\treflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:\n\t\treturn int(t.Size... |
{
"audio": "",
"image": "",
"text": "func (d *OvsdbDriver) IsVtepPresent(remoteIP string) (bool, string) {\n\td.cacheLock.RLock()\n\tdefer d.cacheLock.RUnlock()\n\n\t// walk the local cache\n\tfor tName, table := range d.cache {\n\t\tif tName == \"Interface\" {\n\t\t\tfor _, row := range table {\n\t\t\t\toptions ... | {
"audio": "",
"image": "",
"text": "\t\t\t\t\tswitch t := value.(type) {\n\t\t\t\t\t\tcase string:\n\t\t\t\t\t\t\treturn true, t\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t// return false, \"\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\t// return false, \"\"\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// We cou... | {
"audio": "",
"image": "",
"text": "\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, row := range op.Rows {\n\t\t\t\tfor column := range row {\n\t\t\t\t\tif _, ok := table.Columns[column]; !ok {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, column := range op.Columns {\n\t\t\t\ti... |
{
"audio": "",
"image": "",
"text": "func SetClusterMode(cm string) error {\n\tswitch cm {\n\tcase core.Docker, core.Kubernetes, core.SwarmMode:\n\tcase core.Test: // internal mode used for integration testing\n\t\tbreak\n\tdefault:\n\t\treturn core.Errorf(\"%s not a valid cluster mode {%s",
"video": ""
} | {
"audio": "",
"image": "",
"text": " | %s | %s}\",\n\t\t\tcm, core.Docker, core.Kubernetes, core.SwarmMode)\n\t}\n\n\tmasterRTCfg.clusterMode = cm\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " reg core.Registration) (regR core.Registration, err error) {\n\treturn\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func CreateGlobal(stateDriver core.StateDriver, gc *intent.ConfigGlobal) error {\n\tlog.Infof(\"Received global create with intent {%v}\", gc)\n\tvar err error\n\tgcfgUpdateList := []string{}\n\n\tmasterGc := &mastercfg.GlobConfig{}\n\tmasterGc.StateDriver = stateDriver\n\tmas... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t\tgCfg.Auto.VLANs = gc.VLANs\n\t\tgcfgUpdateList = append(gcfgUpdateList, \"vlan\")\n\t}\n\n\tif gc.VXLANs != \"\" {\n\t\t_, err = netutils.ParseTagRanges(gc.VXLANs, \"vxlan\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tgCfg.Auto.VXLANs = gc.VXLANs\n\t\tgcfg... | {
"audio": "",
"image": "",
"text": " *resources.AutoVXLANCfgResource\n\t\tvxlanRsrcCfg, err = gc.initVXLANBitset(gc.Auto.VXLANs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = ra.RedefineResource(\"global\", resources.AutoVXLANResource, vxlanRsrcCfg)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error delet... |
{
"audio": "",
"image": "",
"text": "func DeleteGlobal(stateDriver core.StateDriver) error {\n\tmasterGc := &mastercfg.GlobConfig{}\n\tmasterGc.StateDriver = stateDriver\n\terr := masterGc.Read(\"\")\n\tif err == nil {\n\t\terr = masterGc.Clear()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Setup gl... | {
"audio": "",
"image": "",
"text": "\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = gCfg.Clear()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Delete old state\n\tgOper := &gstate.Oper{}\n\tgOper.StateDriver = stateDriver\n\terr = gOper.Read(\"\")\n\tif err == nil {\n\t\terr = gOper.Clea... | {
"audio": "",
"image": "",
"text": " *resources.AutoVXLANCfgResource\n\t\tvxlanRsrcCfg, err = gc.initVXLANBitset(gc.Auto.VXLANs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = ra.RedefineResource(\"global\", resources.AutoVXLANResource, vxlanRsrcCfg)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error delet... |
{
"audio": "",
"image": "",
"text": "func DeleteTenant(stateDriver core.StateDriver, tenant *intent.ConfigTenant) error {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn validateTenantConfig(tenant)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn s.StateDriver.ReadAllState(endpointConfigPathPrefix, s, json.Unmarshal)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func IsAciConfigured() (res bool, err error) {\n\t// Get the state driver\n\tstateDriver, uErr := utils.GetStateDriver()\n\tif uErr != nil {\n\t\tlog.Warnf(\"Couldn't read global config %v\", uErr)\n\t\treturn false, uErr\n\t}\n\n\t// read global config\n\tmasterGc := &masterc... | {
"audio": "",
"image": "",
"text": "\tlog.Warnf(\"Couldn't read global config %v\", uErr)\n\t\treturn false, nil\n\t}\n\n\tif masterGc.NwInfraType != \"aci\" {\n\t\tlog.Debugf(\"NwInfra type is %v, no ACI\", masterGc.NwInfraType)\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func getVersion(w http.ResponseWriter, r *http.Request) {\n\tver := version.Get()\n\n\tresp, err := json.Marshal(ver)\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\thttp.Error(w,\n\t\t\tcore.Errorf(\"marshaling json failed. Error: %s\", err).Error(),\n\t\t\thttp.StatusInternalServerError)\n\t\treturn\n\t}\n\tw.Write(resp)\n\treturn\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(responseWriter http.ResponseWriter, request *http.Request) {\n\t\thttp.ServeFile(responseWriter, request, filePath)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func slaveProxyHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Infof(\"proxy handler for %q \", r.URL.Path)\n\n\tlocalIP, err := netutils.GetDefaultAddr()\n\tif err != nil {\n\t\tlog.Fatalf(\"Error getting local IP address. Err: %v\", err)\n\t}\n\n\t// get current hol... | {
"audio": "",
"image": "",
"text": "\t\treturn\n\t}\n\n\t// build the proxy url\n\turl, _ := url.Parse(fmt.Sprintf(\"http://%s\", masterNode))\n\n\t// Create a proxy for the URL\n\tproxy := httputil.NewSingleHostReverseProxy(url)\n\n\t// modify the request url\n\tnewReq := *r\n\t// newReq.URL = url\n\n\t// Serve... | {
"audio": "",
"image": "",
"text": "\tif r.Method == \"GET\" {\n\t\t\terr = r.ParseForm()\n\t\t\tif err != nil {\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor str, _ := range r.Form {\n\t\t\t\tdat = []byte(str)\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// par... |
{
"audio": "",
"image": "",
"text": "func (s *CfgEndpointState) ReadAll() ([]core.State, error)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn s.StateDriver.ReadAllState(endpointConfigPathPrefix, s, json.Unmarshal)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tuser.Banned = false\n\treturn s.ExecuteInTransaction(func() error {\n\t\treturn s.Repositories().Users().Save(ctx, &user)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *CfgEndpointState) WatchAll(rsps chan core.WatchState) error",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn s.StateDriver.WatchAllState(endpointConfigPathPrefix, s, json.Unmarshal,\n\t\trsps)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *v1.VolumeProjection, s conversion.Scope) error {\n\treturn autoConvert_core_VolumeProjection_To_v1_VolumeProjection(in, out, s)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) Init() {\n\t// set cluster mode\n\terr := master.SetClusterMode(d.ClusterMode)\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to set cluster-mode %q. Error: %s\", d.ClusterMode, err)\n\t}\n\n\t// initialize state driver\n\td.stateDriver, err = utils.NewStat... | {
"audio": "",
"image": "",
"text": " resource manager. Error: %s\", err)\n\t}\n\n\t// Create an objdb client\n\td.objdbClient, err = objdb.InitClient(d.ClusterStoreDriver, []string{d.ClusterStoreURL})\n\tif err != nil {\n\t\tlog.Fatalf(\"Error connecting to state store: driver %q, URLs %q. Err: %v\", d.ClusterSt... | {
"audio": "",
"image": "",
"text": " what we\n\t\t// shouldn't be\n\t\tfor _, d := range deployments {\n\t\t\tif d.Active() {\n\t\t\t\tif err := w.add(d); err != nil {\n\t\t\t\t\tw.logger.Error(\"failed to track deployment\", \"deployment_id\", d.ID, \"error\", err)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tw.remove(d... |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) agentDiscoveryLoop() {\n\n\t// Create channels for watch thread\n\tagentEventCh := make(chan objdb.WatchServiceEvent, 1)\n\twatchStopCh := make(chan bool, 1)\n\n\t// Start a watch on netplugin service\n\terr := d.objdbClient.WatchService(\"netplugin\", a... | {
"audio": "",
"image": "",
"text": "\t\terr = d.ofnetMaster.AddNode(nodeInfo)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Error adding node %v. Err: %v\", nodeInfo, err)\n\t\t\t}\n\t\t} else if agentEv.EventType == objdb.WatchServiceEventDel {\n\t\t\tvar res bool\n\t\t\tlog.Infof(\"Unregister node %+v\", nodeIn... | {
"audio": "",
"image": "",
"text": " Get the openflow port number for the interface\n\tofpPort, err := sw.ovsdbDriver.GetOfpPortNo(intfName)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not find the OVS port %s. Err: %v\", intfName, err)\n\t\treturn err\n\t}\n\n\t// Add info about VTEP port to ofnet\n\tif sw.ofnet... |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) getPluginAddress(hostName string) (string, error) {\n\tsrvList, err := d.objdbClient.GetService(\"netplugin.vtep\")\n\tif err != nil {\n\t\tlog.Errorf(\"Error getting netplugin nodes. Err: %v\", err)\n\t\treturn \"\", err\n\t}\n\n\tfor _, srv",
"video"... | {
"audio": "",
"image": "",
"text": " := range srvList {\n\t\tif srv.Hostname == hostName {\n\t\t\treturn srv.HostAddr, nil\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"Could not find plugin instance with name: %s\", hostName)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " = getFilenameFromURL(url)\n\t\t}\n\n\t\tf, err := os.Create(filepath.Join(d.saveDir, d.filename))\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\t\tdefer f.Close()\n\n\t\tsize, err := io.Copy(f, r.Body)\n\t\tif err != nil {\n\t\t\treturn 0, \"\", err\n\t\t}\n\n\t\td... |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) ClearEndpoints(stateDriver core.StateDriver, epCfgs *[]core.State, id, matchField string) error {\n\tfor _, epCfg := range *epCfgs {\n\t\tep := epCfg.(*mastercfg.CfgEndpointState)\n\t\tif (matchField == \"net\" && ep.NetID == id) ||\n\t\t\t(matchField ==... | {
"audio": "",
"image": "",
"text": "\t\t\t}\n\n\t\t\tpluginAddress, err := d.getPluginAddress(ep.HomingHost)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tepDelURL := \"http://\" + pluginAddress + \":9090/debug/reclaimEndpoint/\" + ep.ID\n\t\t\terr = utils.HTTPDel(epDelURL)\n\t\t\tif err != nil {\... | {
"audio": "",
"image": "",
"text": " container '%s' and host '%s'\",\n\t\t\tep.Container, ep.Host)\n\n\t\tfor _, epCfg := range epCfgs {\n\t\t\tcfg := epCfg.(*mastercfg.CfgEndpointState)\n\t\t\tif cfg.EndpointID != ep.Container {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcfg.HomingHost = ep.Host\n\t\t\terr = cfg.Write()... |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) runLeader() {\n\trouter := mux.NewRouter()\n\n\t// Create a new api controller\n\tapiConfig := &objApi.APIControllerConfig{\n\t\tNetForwardMode: d.NetForwardMode,\n\t\tNetInfraType: d.NetInfraType,\n\t}\n\td.apiController = objApi.NewAPIController(rout... | {
"audio": "",
"image": "",
"text": "\n\n\t// initialize policy manager\n\tmastercfg.InitPolicyMgr(d.stateDriver, d.ofnetMaster)\n\n\t// setup HTTP routes\n\td.registerRoutes(router)\n\n\td.startListeners(router, d.stopLeaderChan)\n\n\tlog.Infof(\"Exiting Leader mode\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\td.cols--\n\td.headers = append(d.headers[:colIndex], d.headers[colIndex+1:]...)\n\t// remove the column\n\tfor i := range d.data {\n\t\td.data[i] = append(d.data[i][:colIndex], d.data[i][colIndex+1:]...)\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) runFollower() {\n\trouter := mux.NewRouter()\n\trouter.PathPrefix(\"/\").HandlerFunc(slaveProxyHandler)\n\n\t// Register netmaster",
"video": ""
} | {
"audio": "",
"image": "",
"text": " service\n\td.registerService()\n\n\t// just wait on stop channel\n\tlog.Infof(\"Listening in follower mode\")\n\td.startListeners(router, d.stopFollowerChan)\n\n\tlog.Info(\"Exiting follower mode\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tname: name,\n\t}\n\n\tfor _, prefix := range config.Regex {\n\t\tstripPrefix.router.PathPrefix(prefix)\n\t}\n\n\treturn &stripPrefix, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) becomeLeader() {\n\t// ask listener to stop\n\td.stopFollowerChan <- true\n\n\t// set current state\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\td.currState = \"leader\"\n\n\t// Run the HTTP listener\n\tgo d.runLeader()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\td.stopping = true\n\n\tfor _, client := range d.blockProviders {\n\t\tclient.Stop()\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) becomeFollower() {\n\t// ask listener to stop\n\td.stopLeaderChan <- true\n\ttime.Sleep(time.Second)\n\n\t// set current",
"video": ""
} | {
"audio": "",
"image": "",
"text": " state\n\td.currState = \"follower\"\n\n\t// run follower loop\n\tgo d.runFollower()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tcase \"us\":\n\t\td = time.Microsecond\n\tcase \"ms\":\n\t\td = time.Millisecond\n\tcase \"s\":\n\t\td = time.Second\n\t}\n\treturn int64(d)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) InitServices() {\n\tif d.ClusterMode == \"kubernetes\" {\n\t\tisLeader :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func() bool {\n\t\t\treturn d.currState == \"leader\"\n\t\t}\n\t\tnetworkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader)\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\t\t\t\t\t\tsuffix = \": \" + declKey(d) + \" \" + c2go.GoString(d.Type)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f.ptrAdd {\n\t\t\t\t\t\t\tsuffix += \" (ptradd)\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif f.usedAsBool {\n\t\t\t\t\t\t\tsuffix += \" (bool)\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfmt.Pr... |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) RunMasterFsm() {\n\tvar err error\n\n\tmasterURL := strings.Split(d.ControlURL, \":\")\n\tmasterIP, masterPort := masterURL[0], masterURL[1]\n\tif len(masterURL) != 2 {\n\t\tlog.Fatalf(\"Invalid netmaster URL\")\n\t}\n\n\t// create new ofnet master\n\td.... | {
"audio": "",
"image": "",
"text": " = make(chan bool, 1)\n\n\t// set current state\n\td.currState = \"follower\"\n\n\t// Start off being a follower\n\tgo d.runFollower()\n\n\t// Main run loop waiting on leader lock\n\tfor {\n\t\t// Wait for lock events\n\t\tselect {\n\t\tcase event := <-leaderLock.EventChan():\... | {
"audio": "",
"image": "",
"text": " Get the openflow port number for the interface\n\tofpPort, err := sw.ovsdbDriver.GetOfpPortNo(intfName)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not find the OVS port %s. Err: %v\", intfName, err)\n\t\treturn err\n\t}\n\n\t// Add info about VTEP port to ofnet\n\tif sw.ofnet... |
{
"audio": "",
"image": "",
"text": "func (d *MasterDaemon) getMasterInfo() (map[string]interface{}, error) {\n\tinfo := make(map[string]interface{})\n\n\t// get local ip\n\tlocalIP, err := netutils.GetDefaultAddr()\n\tif err != nil {\n\t\treturn nil, errors.New(\"error getting local IP address\")\n\t}\n\n\t// ge... | {
"audio": "",
"image": "",
"text": " getting netplugin nodes. Err: %v\", err)\n\t\treturn nil, err\n\t}\n\n\t// Add each node\n\tpluginNodes := []string{}\n\tfor _, srv := range srvList {\n\t\tpluginNodes = append(pluginNodes, srv.HostAddr)\n\t}\n\n\t// Get all netmaster services\n\tsrvList, err = d.objdbClient.... | {
"audio": "",
"image": "",
"text": " err := cmd.Output()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %v\", strings.Join(args, \" \"), err)\n\t}\n\tvar d describe\n\tif yaml.Unmarshal(data, &d); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshal gcloud: %v\", err)\n\t}\n\n\tif d.Endpoint == \"\" {\n\t\... |
{
"audio": "",
"image": "",
"text": "func PolicyAttach(epg *contivModel.EndpointGroup, policy *contivModel.Policy) error {\n\t// Dont install policies in ACI mode\n\tif !isPolicyEnabled() {\n\t\treturn nil\n\t}\n\n\tepgpKey := epg.Key + \":\" + policy.Key\n\n\t// See if it already exists\n\tgp := mastercfg.FindEp... | {
"audio": "",
"image": "",
"text": " mastercfg.GetEndpointGroupID(stateDriver, epg.GroupName, epg.TenantName)\n\tif err != nil {\n\t\tlog.Errorf(\"Error getting epgID for %s. Err: %v\", epgpKey, err)\n\t\treturn err\n\t}\n\n\t// Create the epg policy\n\tgp, err = mastercfg.NewEpgPolicy(epgpKey, epgID, policy)\n\... | {
"audio": "",
"image": "",
"text": " \"\" {\n\t\tepg = contivModel.FindEndpointGroup(epgKey)\n\t\tif epg != nil {\n\t\t\tmodeldb.RemoveLinkSet(&epg.LinkSets.MatchRules, rule)\n\t\t}\n\t}\n\n\t// Trigger policyDB Update\n\terr = master.PolicyDelRule(policy, rule)\n\tif err != nil {\n\t\tlog.Errorf(\"Error deletin... |
{
"audio": "",
"image": "",
"text": "func PolicyDetach(epg *contivModel.EndpointGroup, policy *contivModel.Policy) error {\n\t// Dont install policies in ACI mode\n\tif !isPolicyEnabled() {\n\t\treturn nil\n\t}\n\n\tepgpKey := epg.Key + \":\" + policy.Key\n\n\t// find the policy\n\tgp := mastercfg.FindEpgPolicy(e... | {
"audio": "",
"image": "",
"text": " rule == nil {\n\t\t\tlog.Errorf(\"Error finding the rule %s\", ruleKey)\n\t\t\tcontinue\n\t\t}\n\n\t\tlog.Infof(\"Deleting Rule %s from epgp policy %s\", ruleKey, epgpKey)\n\n\t\t// Add the rule to epg Policy\n\t\terr := gp.DelRule(rule)\n\t\tif err != nil {\n\t\t\tlog.Errorf... | {
"audio": "",
"image": "",
"text": " \"\" {\n\t\tepg = contivModel.FindEndpointGroup(epgKey)\n\t\tif epg != nil {\n\t\t\tmodeldb.RemoveLinkSet(&epg.LinkSets.MatchRules, rule)\n\t\t}\n\t}\n\n\t// Trigger policyDB Update\n\terr = master.PolicyDelRule(policy, rule)\n\tif err != nil {\n\t\tlog.Errorf(\"Error deletin... |
{
"audio": "",
"image": "",
"text": "func PolicyAddRule(policy *contivModel.Policy, rule *contivModel.Rule) error {\n\t// Dont install policies in ACI mode\n\tif !isPolicyEnabled() {\n\t\treturn nil\n\t}\n\n\t// Walk all associated endpoint groups\n\tfor epgKey := range policy.LinkSets.EndpointGroups {\n\t\tgpKey... | {
"audio": "",
"image": "",
"text": "\t}\n\n\t\t// Add the Rule\n\t\terr := gp.AddRule(rule)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error adding the rule %s to epg policy %s. Err: %v\", rule.Key, gpKey, err)\n\t\t\treturn err\n\t\t}\n\n\t\t// Save the policy state\n\t\terr = gp.Write()\n\t\tif err != nil {\n\t\... | {
"audio": "",
"image": "",
"text": " \"\" {\n\t\tepg = contivModel.FindEndpointGroup(epgKey)\n\t\tif epg != nil {\n\t\t\tmodeldb.RemoveLinkSet(&epg.LinkSets.MatchRules, rule)\n\t\t}\n\t}\n\n\t// Trigger policyDB Update\n\terr = master.PolicyDelRule(policy, rule)\n\tif err != nil {\n\t\tlog.Errorf(\"Error deletin... |
{
"audio": "",
"image": "",
"text": "func initStateDriver(clusterStore string) (core.StateDriver, error) {\n\t// parse the state store URL\n\tparts := strings.Split(clusterStore, \"://\")\n\tif len(parts) < 2 {\n\t\treturn nil, core.Errorf(\"Invalid state-store URL %q\", clusterStore)\n\t}\n\tstateStore := parts[... | {
"audio": "",
"image": "",
"text": " utils.EtcdNameStr:\n\tcase utils.ConsulNameStr:\n\tdefault:\n\t\treturn nil, core.Errorf(\"Unsupported state-store %q\", stateStore)\n\t}\n\n\t// Setup instance info\n\tinstInfo := core.InstanceInfo{\n\t\tDbURL: clusterStore,\n\t}\n\n\treturn utils.NewStateDriver(stateStore, ... | {
"audio": "",
"image": "",
"text": " != nil {\n\t\t\tif err == io.EOF {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn err\n\t\t}\n\t\tparts := strings.Split(line, \":\")\n\t\tif len(parts) != 2 {\n\t\t\tcontinue\n\t\t}\n\t\tkey := strings.TrimSpace(parts[0])\n\t\tvalue, err := strconv.ParseInt(strings.TrimSpace(par... |
{
"audio": "",
"image": "",
"text": "func parseRange(rangeStr string) ([]uint, error) {\n\tvar values []uint\n\tif rangeStr == \"\" {\n\t\treturn []uint{}, nil\n\t}\n\n\t// split ranges based on \",\" char\n\trangeList := strings.Split(rangeStr, \",\")\n\n\tfor _, subrange := range rangeList {\n\t\tminMax := stri... | {
"audio": "",
"image": "",
"text": "\n\n\t\t\tfor i := min; i <= max; i++ {\n\t\t\t\tvalues = append(values, uint(i))\n\t\t\t}\n\t\t} else if len(minMax) == 1 {\n\t\t\tval, err := strconv.Atoi(minMax[0])\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Invalid range: %v\", subrange)\n\t\t\t\treturn nil, err\n\t\t\t}... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t\treturn nil\n\t}\n\tif len(args) < argBounds.Min || len(args) > argBounds.Max {\n\t\tif argBounds.Min == argBounds.Max {\n\t\t\treturn fmt.Errorf(\"Expected %d args, got %d\", argBounds.Min, len(args))\n\t\t}\n\t\treturn fmt.Errorf(\"Expected between %d and %d args... |
{
"audio": "",
"image": "",
"text": "func processResource(stateDriver core.StateDriver, rsrcName, rsrcVal string) error {\n\t// Read global config\n\tgCfg := gstate.Cfg{}\n\tgCfg.StateDriver = stateDriver\n\terr := gCfg.Read(\"\")\n\tif err != nil {\n\t\tlog.Errorf(\"error reading tenant cfg state. Error: %s\", e... | {
"audio": "",
"image": "",
"text": " else if rsrcName == \"vxlan\" {\n\t\tnumVxlans, vxlansInUse := gCfg.GetVxlansInUse()\n\t\tfmt.Printf(\"Num Vxlans: %d\\n Current Vxlans in Use: %s\\n\", numVxlans, vxlansInUse)\n\n\t\t// see if we need to set the resource\n\t\tif rsrcVal != \"\" {\n\t\t\tvalues, err := parseR... | {
"audio": "",
"image": "",
"text": " *resources.AutoVXLANCfgResource\n\t\tvxlanRsrcCfg, err = gc.initVXLANBitset(gc.Auto.VXLANs)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\terr = ra.RedefineResource(\"global\", resources.AutoVXLANResource, vxlanRsrcCfg)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"Error delet... |
{
"audio": "",
"image": "",
"text": "func (cniReq *cniServer) ipnsExecute(namespace string, args []string) ([]byte, error) {\n\tipCmd := \"ip\"\n\tipArgs := []string{\"netns\", \"exec\", namespace}\n\n\tipArgs = append(ipArgs, args...)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tcniLog.Infof(\"processing cmd: %v\", ipArgs)\n\treturn exec.Command(ipCmd, ipArgs...).CombinedOutput()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " CommandTarget), we can emit it on either side.\n\tif !cl.Target.followsFlagSeparator() {\n\t\targs = append(args, targetArgs...)\n\t\targs = append(args, flagSeparator...)\n\t} else {\n\t\targs = append(args, flagSeparator...)\n\t\targs = append(args, targetArgs...)\n\t}\n\n\... |
{
"audio": "",
"image": "",
"text": "func (cniReq *cniServer) ipnsBatchExecute(namespace string, args [][]string) ([]byte, error) {\n\n\tfor idx, arg1 := range args {\n\t\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " out, err := cniReq.ipnsExecute(namespace, arg1); err != nil {\n\t\t\tcniLog.Errorf(\"failed to execute [%d] %v %s, %s\", idx, err, arg1, string(out))\n\t\t\treturn out, err\n\t\t}\n\t}\n\n\treturn nil, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " len(args.Models)),\n\t}\n\tfor i, arg := range args.Models {\n\t\terr := f.setModelEnvironVersion(arg)\n\t\tif err != nil {\n\t\t\tresult.Results[i].Error = common.ServerError(err)\n\t\t}\n\t}\n\treturn result, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func setUpAPIClient() *APIClient {\n\t// Read config\n\terr := k8sutils.GetK8SConfig(&contivK8Config)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed: %v\", err)\n\t\treturn nil\n\t}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn NewAPIClient(contivK8Config.K8sAPIServer, contivK8Config.K8sCa,\n\t\tcontivK8Config.K8sKey, contivK8Config.K8sCert, contivK8Config.K8sToken)\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := v.ReadInConfig(); err != nil {\n\t\treturn fmt.Errorf(\"Could not read config at :%s, viper error: %v\", configFile, err)\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func InitKubServiceWatch(np *plugin.NetPlugin) {\n\n\twatchClient := setUpAPIClient()\n\tif watchClient == nil {\n\t\tlog.Fatalf(\"Could not init kubernetes API client\")\n\t}\n\n\tsvcCh := make(chan SvcWatchResp, 1)\n\tepCh := make(chan EpWatchResp, 1)\n\tgo func() {\n\t\tfor... | {
"audio": "",
"image": "",
"text": "\t\t\t\tcase \"WARN\":\n\t\t\t\t\tlog.Debugf(\"epWatch : %s\", epEvent.errStr)\n\t\t\t\t\tbreak\n\t\t\t\tcase \"FATAL\":\n\t\t\t\t\tlog.Errorf(\"epWatch : %s\", epEvent.errStr)\n\t\t\t\t\tbreak\n\t\t\t\tcase \"ERROR\":\n\t\t\t\t\tlog.Warnf(\"epWatch : %s\", epEvent.errStr)\n\t... | {
"audio": "",
"image": "",
"text": "\t\tselect {\n\t\t\t\t\tcase state := <-logger.stateChannel:\n\t\t\t\t\t\tswitch state {\n\t\t\t\t\t\tcase stopped:\n\t\t\t\t\t\t\tbreak recordLoop\n\t\t\t\t\t\tcase running:\n\t\t\t\t\t\t\tbreak stateLoop\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\... |
{
"audio": "",
"image": "",
"text": "func InitCNIServer(netplugin *plugin.NetPlugin) error {\n\n\tnetPlugin = netplugin\n\thostname, err := os.Hostname()\n\tif err != nil {\n\t\tlog.Fatalf(\"Could not retrieve hostname: %v\", err)\n\t}\n\n\tpluginHost = hostname\n\n\t// Set up the api client instance\n\tkubeAPICl... | {
"audio": "",
"image": "",
"text": "\tos.Remove(driverPath)\n\tos.MkdirAll(cniapi.PluginPath, 0700)\n\n\tgo func() {\n\t\tl, err := net.ListenUnix(\"unix\", &net.UnixAddr{Name: driverPath, Net: \"unix\"})\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tlog.Infof(\"k8s plugin listening on %s\", driverPath)\n... | {
"audio": "",
"image": "",
"text": "\t\t\t\tloggerRouter.\n\t\t\t\t\tError(\"Could not define the service name for the router: too many services\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tfor serviceName := range configuration.Services {\n\t\t\t\trouter.Service = serviceName\n\t\t\t}\n\t\t}\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func epCleanUp(req *epSpec) error {\n\t// first delete from netplugin\n\t// ignore any errors as this is best effort\n\tnetID := req.Network + \".\" + req.Tenant\n\tpluginErr := netPlugin.DeleteEndpoint(netID + \"-\" + req.EndpointID)\n\n\t// now delete from master\n\tdelReq :... | {
"audio": "",
"image": "",
"text": "\t\tServiceName: req.Group,\n\t\tEndpointID: req.EndpointID,\n\t}\n\n\tvar delResp master.DeleteEndpointResponse\n\tmasterErr := cluster.MasterPostReq(\"/plugin/deleteEndpoint\", &delReq, &delResp)\n\n\tif pluginErr != nil {\n\t\tlog.Errorf(\"failed to delete endpoint: %s fro... | {
"audio": "",
"image": "",
"text": " request error (%v)\", err)\n\t}\n\treq.Header.Set(\"Content-Type\", ct)\n\treq.Header.Set(\"X-Server-From\", from.String())\n\treq.Header.Set(\"X-Server-Version\", version.Version)\n\treq.Header.Set(\"X-Min-Cluster-Version\", version.MinClusterVersion)\n\treq.Header.Set(\"X-E... |
{
"audio": "",
"image": "",
"text": "func createEP(req *epSpec) (*epAttr, error) {\n\n\t// if the ep already exists, treat as error for now.\n\tnetID := req.Network + \".\" + req.Tenant\n\tep, err := utils.GetEndpoint(netID + \"-\" + req.EndpointID)\n\tif err == nil {\n\t\treturn nil, fmt.Errorf(\"the EP %s alrea... | {
"audio": "",
"image": "",
"text": " err)\n\t\tepCleanUp(req)\n\t\treturn nil, err\n\t}\n\n\tep, err = utils.GetEndpoint(netID + \"-\" + req.EndpointID)\n\tif err != nil {\n\t\tepCleanUp(req)\n\t\treturn nil, err\n\t}\n\n\tlog.Debug(ep)\n\t// need to get the subnetlen from nw state.\n\tnw, err := utils.GetNetwor... | {
"audio": "",
"image": "",
"text": " req.onlyMultipartForm() {\n\t\tbody, err := marshalMultipartForm(req.multipartForm, req.multipartFormBoundary)\n\t\tif err != nil {\n\t\t\treturn []byte(err.Error())\n\t\t}\n\t\treturn body\n\t}\n\treturn req.bodyBytes()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func getLink(ifname string) (netlink.Link, error) {\n\t// find the link\n\tlink, err := netlink.LinkByName(ifname)\n\tif err != nil {\n\t\tif !strings.Contains(err.Error(), \"Link not found\") {\n\t\t\tlog.Errorf(\"unable to find link %q. Error: %q\", ifname, err)\n\t\t\tretur... | {
"audio": "",
"image": "",
"text": " * time.Second)\n\t\tlink, err = netlink.LinkByName(ifname)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"unable to find link %q. Error %q\", ifname, err)\n\t\t}\n\t\treturn link, err\n\t}\n\treturn link, err\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\t// Attempt to find an existing bridge named with the specified name.\n\ti.Link, err = nlh.LinkByName(config.BridgeName)\n\tif err != nil {\n\t\tlogrus.Debugf(\"Did not find any interface with name %s: %v\", config.BridgeName, err)\n\t} else if _, ok := i.Link.(*netlink.B... |
{
"audio": "",
"image": "",
"text": "func nsToPID(ns string) (int, error) {\n\t// Make sure ns is well formed\n\tok := strings.HasPrefix(ns, \"/proc/\")\n\tif !ok {\n\t\treturn -1, fmt.Errorf(\"invalid",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nw name space: %v\", ns)\n\t}\n\n\telements := strings.Split(ns, \"/\")\n\treturn strconv.Atoi(elements[2])\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " == nil {\n\t\tif ns := strings.TrimSpace(string(data)); len(ns) > 0 {\n\t\t\treturn ns\n\t\t}\n\t}\n\n\treturn environment.DefaultTillerNamespace\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func setIfAttrs(pid int, ifname, cidr, cidr6, newname string) error {\n\tnsenterPath, err := osexec.LookPath(\"nsenter\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tipPath, err := osexec.LookPath(\"ip\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// find the link\n\tlink, er... | {
"audio": "",
"image": "",
"text": " %s\",\n\t\t\tcidr, newname, err)\n\t\treturn nil\n\t}\n\tlog.Infof(\"Output from ip assign: %v\", assignIP)\n\n\tif cidr6 != \"\" {\n\t\tout, err := osexec.Command(nsenterPath, \"-t\", nsPid, \"-n\", \"-F\", \"--\", ipPath,\n\t\t\t\"-6\", \"address\", \"add\", cidr6, \"dev\",... | {
"audio": "",
"image": "",
"text": " fmt.Errorf(\"Unable to bring %s interface UP: %s\", veth.peerIfc.Name, nspid)\n\t}\n\n\tif gw != nil {\n\t\tif err := netlink.AddDefaultGw(gw.String(), veth.peerIfc.Name); err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to set Default gateway: %s in pid: %d network namespace\"... |
{
"audio": "",
"image": "",
"text": "func setDefGw(pid int, gw, gw6, intfName string) error {\n\tnsenterPath, err := osexec.LookPath(\"nsenter\")\n\tif err != nil {\n\t\treturn err\n\t}\n\troutePath, err := osexec.LookPath(\"route\")\n\tif err != nil {\n\t\treturn err\n\t}\n\t// set default gw\n\tnsPid := fmt.Spr... | {
"audio": "",
"image": "",
"text": "\n\n\tif gw6 != \"\" {\n\t\tout, err := osexec.Command(nsenterPath, \"-t\", nsPid, \"-n\", \"-F\", \"--\", routePath,\n\t\t\t\"-6\", \"add\", \"default\", \"gw\", gw6, intfName).CombinedOutput()\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"unable to set default IPv6 gateway %s. Er... | {
"audio": "",
"image": "",
"text": " fmt.Errorf(\"Unable to bring %s interface UP: %s\", veth.peerIfc.Name, nspid)\n\t}\n\n\tif gw != nil {\n\t\tif err := netlink.AddDefaultGw(gw.String(), veth.peerIfc.Name); err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to set Default gateway: %s in pid: %d network namespace\"... |
{
"audio": "",
"image": "",
"text": "func getEPSpec(pInfo *cniapi.CNIPodAttr) (*epSpec, error) {\n\tresp := epSpec{}\n\n\t// Get labels from the kube api server\n\tepg, err := kubeAPIClient.GetPodLabel(pInfo.K8sNameSpace, pInfo.Name,\n\t\t\"io.contiv.net-group\")\n\tif err != nil {\n\t\tlog.Errorf(\"Error getting... | {
"audio": "",
"image": "",
"text": "\ttenant, _ := kubeAPIClient.GetPodLabel(pInfo.K8sNameSpace, pInfo.Name,\n\t\t\"io.contiv.tenant\")\n\tlog.Infof(\"labels is %s/%s/%s for pod %s\\n\", tenant, netw, epg, pInfo.Name)\n\tresp.Tenant = tenant\n\tresp.Network = netw\n\tresp.Group = epg\n\tresp.EndpointID = pInfo.I... | {
"audio": "",
"image": "",
"text": " Get the openflow port number for the interface\n\tofpPort, err := sw.ovsdbDriver.GetOfpPortNo(intfName)\n\tif err != nil {\n\t\tlog.Errorf(\"Could not find the OVS port %s. Err: %v\", intfName, err)\n\t\treturn err\n\t}\n\n\t// Add info about VTEP port to ofnet\n\tif sw.ofnet... |
{
"audio": "",
"image": "",
"text": "func deletePod(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {\n\n\tresp := cniapi.RspAddPod{}\n\n\tlogEvent(\"del pod\")\n\n\tcontent, err := ioutil.ReadAll(r.Body)\n\tif err != nil {\n\t\tlog.Errorf(\"Failed to read request: %v\", err)\... | {
"audio": "",
"image": "",
"text": " getting labels. Err: %v\", err)\n\t\tsetErrorResp(&resp, \"Error getting labels\", err)\n\t\treturn resp, err\n\t}\n\n\tnetPlugin.DeleteHostAccPort(epReq.EndpointID)\n\tif err = epCleanUp(epReq); err != nil {\n\t\tlog.Errorf(\"failed to delete pod, error: %s\", err)\n\t}\n\tr... | {
"audio": "",
"image": "",
"text": " {\n\t\treturn err\n\t}\n\n\tcontent, err := file.ReadAll()\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = ioutil.WriteFile(location, content, perm)\n\n\treturn err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func freeAddrOnErr(nwCfg *mastercfg.CfgNetworkState, epgCfg *mastercfg.EndpointGroupState,\n\tipAddress string,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " pErr *error) {\n\tif *pErr != nil {\n\t\tlog.Infof(\"Freeing %s on error\", ipAddress)\n\t\tnetworkReleaseAddress(nwCfg, epgCfg, ipAddress)\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func CreateEndpoints(stateDriver core.StateDriver, tenant *intent.ConfigTenant) error {\n\terr := validateEndpointConfig(stateDriver, tenant)\n\tif err != nil {\n\t\tlog.Errorf(\"error validating endpoint config. Error: %s\", err)\n\t\treturn err\n\t}\n\n\tfor _, network := ra... | {
"audio": "",
"image": "",
"text": "\n\t\terr = nwCfg.Read(networkID)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"error reading oper network %s. Error: %s\", network.Name, err)\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, ep := range network.Endpoints {\n\t\t\tepReq := CreateEndpointRequest{}\n\t\t\tepReq.ConfigEP = ep\n... | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func DeleteEndpoints(hostAddr string) error {\n\t// Get the state driver\n\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treadEp := &mastercfg.CfgEndpointState{}\n\treadEp.StateDriver = stateDriver\n\tepCfgs, err := readEp.ReadAll()\n\... | {
"audio": "",
"image": "",
"text": "\t\tepOper := &drivers.OperEndpointState{}\n\t\t\tepOper.StateDriver = stateDriver\n\t\t\terr := epOper.Read(epID)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Failed to read epOper: %+v\", epOper)\n\t\t\t\treturn err\n\t\t\t}\n\t\t\terr = epOper.Clear()\n\t\t\tif err != nil {... | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func DeleteEndpointID(stateDriver core.StateDriver, epID string) (*mastercfg.CfgEndpointState, error) {\n\tepCfg := &mastercfg.CfgEndpointState{}\n\tvar epgCfg *mastercfg.EndpointGroupState\n\n\tepCfg.StateDriver = stateDriver\n\terr := epCfg.Read(epID)\n\tif err != nil {\n\t\... | {
"audio": "",
"image": "",
"text": "\n\t\t\tepgCfg.StateDriver = stateDriver\n\t\t\terr = epgCfg.Read(epCfg.EndpointGroupKey)\n\t\t\tif err != nil {\n\t\t\t\tlog.Errorf(\"Error reading EPG for endpoint: %+v\", epCfg)\n\t\t\t}\n\n\t\t\tepgCfg.EpCount--\n\n\t\t\t// write updated epg state\n\t\t\terr = epgCfg.Write... | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func CreateEpBindings(epBindings *[]intent.ConfigEP) error {\n\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = validateEpBindings(epBindings)\n\tif err != nil {\n\t\tlog.Errorf(\"error validating the ep bindings. Error: %s\", err)... | {
"audio": "",
"image": "",
"text": " container '%s' and host '%s'\",\n\t\t\tep.Container, ep.Host)\n\n\t\tfor _, epCfg := range epCfgs {\n\t\t\tcfg := epCfg.(*mastercfg.CfgEndpointState)\n\t\t\tif cfg.EndpointID != ep.Container {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcfg.HomingHost = ep.Host\n\t\t\terr = cfg.Write()... | {
"audio": "",
"image": "",
"text": "\tstateDriver, err := utils.GetStateDriver()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// find the network from network id\n\tnetID := epReq.NetworkName + \".\" + epReq.TenantName\n\tnwCfg := &mastercfg.CfgNetworkState{}\n\tnwCfg.StateDriver = stateDriver\n\terr = nwCf... |
{
"audio": "",
"image": "",
"text": "func cleanupExternalContracts(endpointGroup *contivModel.EndpointGroup) error {\n\ttenant := endpointGroup.TenantName\n\tfor _, contractsGrp := range endpointGroup.ExtContractsGrps {\n\t\tcontractsGrpKey := tenant + \":\" + contractsGrp\n\t\tcontractsGrpObj := contivModel.Find... | {
"audio": "",
"image": "",
"text": " endpointGroup)\n\t\t\tmodeldb.RemoveLinkSet(&endpointGroup.LinkSets.ExtContractsGrps, contractsGrpObj)\n\n\t\t\t// Links broken, update the contracts group object.\n\t\t\terr := contractsGrpObj.Write()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t} else {\n\t\t\tl... | {
"audio": "",
"image": "",
"text": " %s)\",\n\t\t\tendpointGroup.TenantName, endpointGroup.GroupName, err.Error())\n\t}\n\n\t// get the netprofile structure by finding the netprofile\n\tprofileKey := GetNetprofileKey(endpointGroup.TenantName, endpointGroup.NetProfile)\n\tnetprofile := contivModel.FindNetprofile(... |
{
"audio": "",
"image": "",
"text": "func setupExternalContracts(endpointGroup *contivModel.EndpointGroup, extContractsGrps []string) error {\n\t// Validate presence and register consumed external contracts\n\ttenant := endpointGroup.TenantName\n\tfor _, contractsGrp := range extContractsGrps {\n\t\tcontractsGrpK... | {
"audio": "",
"image": "",
"text": " Establish the necessary links.\n\t\tmodeldb.AddLinkSet(&contractsGrpObj.LinkSets.EndpointGroups, endpointGroup)\n\t\tmodeldb.AddLinkSet(&endpointGroup.LinkSets.ExtContractsGrps, contractsGrpObj)\n\n\t\t// Links made, write the policy set object.\n\t\terr := contractsGrpObj.Wr... | {
"audio": "",
"image": "",
"text": " %s)\",\n\t\t\tendpointGroup.TenantName, endpointGroup.GroupName, err.Error())\n\t}\n\n\t// get the netprofile structure by finding the netprofile\n\tprofileKey := GetNetprofileKey(endpointGroup.TenantName, endpointGroup.NetProfile)\n\tnetprofile := contivModel.FindNetprofile(... |
{
"audio": "",
"image": "",
"text": "func (ac *APIController) ExtContractsGroupCreate(contractsGroup *contivModel.ExtContractsGroup) error {\n\tlog.Infof(\"Received ExtContractsGroupCreate: %+v\", contractsGroup)\n\n\t// Validate contracts type\n\tif contractsGroup.ContractsType != \"provided\" && contractsGroup.... | {
"audio": "",
"image": "",
"text": "\t// Make sure the tenant exists\n\ttenant := contivModel.FindTenant(contractsGroup.TenantName)\n\tif tenant == nil {\n\t\treturn core.Errorf(\"Tenant %s not found\", contractsGroup.TenantName)\n\t}\n\n\t// NOTE: Nothing more needs to be done here. This object\n\t// need not b... | {
"audio": "",
"image": "",
"text": " ok := CONST[kStringUpper]; ok {\n\t\t\t\toptions[kInt] = v\n\t\t\t} else {\n\t\t\t\t// it should be header, but we still need to validate it's type\n\t\t\t\tif vString, ok := v.(string); ok {\n\t\t\t\t\theaders[kString] = vString\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn op... |
{
"audio": "",
"image": "",
"text": "func (ac *APIController) ExtContractsGroupUpdate(contractsGroup, params *contivModel.ExtContractsGroup) error {\n\tlog.Infof(\"Received ExtContractsGroupUpdate: %+v, params: %+v\", contractsGroup, params)\n\tlog.Errorf(\"Error: external contracts",
"video": ""
} | {
"audio": "",
"image": "",
"text": " update not supported: %s\", contractsGroup.ContractsGroupName)\n\n\treturn core.Errorf(\"external contracts update not supported\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tlog.Errorf(\"executor error: %+v\", err)\n\twe.errors = append(we.errors, err)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (ac *APIController) ExtContractsGroupDelete(contractsGroup *contivModel.ExtContractsGroup) error {\n\tlog.Infof(\"Received ExtContractsGroupDelete: %+v\", contractsGroup)\n\n\t// At this moment, we let the external contracts to be deleted only\n\t// if there are no consum... | {
"audio": "",
"image": "",
"text": " isExtContractsGroupUsed(contractsGroup) == true {\n\t\tlog.Errorf(\"Error: External contracts groups is being used: %s\", contractsGroup.ContractsGroupName)\n\t\treturn core.Errorf(\"External contracts group is in-use\")\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " regeneration failed, so there is no way that we can\n\t// realize the policy revision yet. Should this be signaled\n\t// to the routine waiting for the result of this event?\n\tev.ep.SetPolicyRevision(ev.Rev)\n\tres <- struct{}{}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func MakeHTTPHandler(handlerFunc httpAPIFunc) http.HandlerFunc {\n\t// Create a closure and return an anonymous function\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\t// Call the handler\n\t\tresp, err := handlerFunc(w, r, mux.Vars(r))\n\t\tif err != nil {\n\t\... | {
"audio": "",
"image": "",
"text": "\t\t// Send HTTP response\n\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\t\t} else {\n\t\t\t\t// Send HTTP response as Json\n\t\t\t\tcontent, err := json.Marshal(resp)\n\t\t\t\tif err != nil {\n\t\t\t\t\thttp.Error(w, err.Error(), http.StatusInternalSe... | {
"audio": "",
"image": "",
"text": " {\n\t\treturn http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {\n\t\t\thandleTimeout(timeout, rw, func() { h.ServeHTTP(rw, r) })\n\t\t})\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func UnknownAction(w http.ResponseWriter, r *http.Request) {\n\tlog.Infof(\"Unknown action at %q\", r.URL.Path)\n\tcontent, _ := ioutil.ReadAll(r.Body)\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tlog.Infof(\"Body content: %s\", string(content))\n\thttp.NotFound(w, r)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " w http.ResponseWriter, r *http.Request) {\n\tc.Handler.ServeHTTP(w, r)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func HTTPPost(url string, req interface{}, resp interface{}) error {\n\t// Convert the req to json\n\tjsonStr, err := json.Marshal(req)\n\tif err != nil {\n\t\tlog.Errorf(\"Error converting request data(%#v) to Json. Err: %v\", req, err)\n\t\treturn err\n\t}\n\n\t// Perform HT... | {
"audio": "",
"image": "",
"text": " http.StatusOK {\n\t\tlog.Errorf(\"HTTP error response. Status: %s, StatusCode: %d\", res.Status, res.StatusCode)\n\t\treturn fmt.Errorf(\"HTTP error response. Status: %s, StatusCode: %d\", res.Status, res.StatusCode)\n\t}\n\n\t// Read the entire response\n\tbody, err := iouti... | {
"audio": "",
"image": "",
"text": " := http.Head(serviceURL)\n\t\tif err != nil || res.StatusCode != http.StatusOK {\n\t\t\tres, err = http.Get(serviceURL)\n\t\t\tif err == nil {\n\t\t\t\tres.Body.Close()\n\t\t\t}\n\t\t\tif err != nil || res.StatusCode != http.StatusOK {\n\t\t\t\t// request failed\n\t\t\t\tretu... |
{
"audio": "",
"image": "",
"text": "func HTTPDel(url string) error {\n\treq, err := http.NewRequest(\"DELETE\", url, nil)\n\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer res.Body.Close()\n\n\t// Check the response code\n\tif res.StatusCode == http.StatusInternalServer... | {
"audio": "",
"image": "",
"text": " response. Status: %s, StatusCode: %d\", res.Status, res.StatusCode)\n\t\treturn fmt.Errorf(\"HTTP error response. Status: %s, StatusCode: %d\", res.Status, res.StatusCode)\n\t}\n\n\tlog.Debugf(\"Results for (%s): %+v\\n\", url, res)\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := http.Head(serviceURL)\n\t\tif err != nil || res.StatusCode != http.StatusOK {\n\t\t\tres, err = http.Get(serviceURL)\n\t\t\tif err == nil {\n\t\t\t\tres.Body.Close()\n\t\t\t}\n\t\t\tif err != nil || res.StatusCode != http.StatusOK {\n\t\t\t\t// request failed\n\t\t\t\tretu... |
{
"audio": "",
"image": "",
"text": "func NewContivClient(baseURL string) (*ContivClient, error) {\n\tok, err := regexp.Match(`^https?://`, []byte(baseURL))\n\tif !ok {\n\t\treturn nil, errors.New(\"invalid URL: must begin",
"video": ""
} | {
"audio": "",
"image": "",
"text": " with http:// or https://\")\n\t} else if err != nil {\n\t\treturn nil, err\n\t}\n\n\tclient := ContivClient{\n\t\tbaseURL: baseURL,\n\t\tcustomRequestHeaders: [][2]string{},\n\t\thttpClient: &http.Client{},\n\t}\n\n\treturn &client, nil\n}",
"video": ... | {
"audio": "",
"image": "",
"text": " missing\")\n\t}\n\n\tif config.BaseURL == \"\" {\n\t\tconfig.BaseURL = defaultBaseURL\n\t}\n\n\treturn &DNSProvider{config: config}, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) SetAuthToken(token string) error {\n\n\t// setting an auth token is only allowed on secure requests.\n\t// if we didn't enforce this, the client could potentially send auth\n\t// tokens in plain text across the network.\n\tif !c.isHTTPS() {\n\t\treturn e... | {
"audio": "",
"image": "",
"text": " we will raise an error if there's already an auth token set.\n\tfor _, pair := range c.customRequestHeaders {\n\t\tif pair[0] == authTokenHeader {\n\t\t\treturn errors.New(\"an auth token has already been set\")\n\t\t}\n\t}\n\n\tc.addCustomRequestHeader(authTokenHeader, token... | {
"audio": "",
"image": "",
"text": " authorization token\n\t\tauth.Token = \"\"\n\n\t\t// Apply redacted authorization\n\t\trequest.Request.Authorization = auth\n\n\t\t// Apply redacted request\n\t\tq.ProxyRequest = request\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) Login(username, password string) (*http.Response, []byte, error) {\n\n\t// login is only allowed over a secure channel\n\tif !c.isHTTPS() {\n\t\treturn nil, nil, errors.New(\"login requires a https auth_proxy URL\")\n\t}\n\n\turl := c.baseURL + LoginPath... | {
"audio": "",
"image": "",
"text": "\t// send the login POST request\n\tresp, err := c.httpClient.Post(url, \"application/json\", bytes.NewBuffer(payload))\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tdefer resp.Body.Close()\n\n\tbody, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, ... | {
"audio": "",
"image": "",
"text": " client_id and client_secret pairs as per\n\t// https://tools.ietf.org/html/rfc6749#section-2.3.1\n\n\tusername, err := url.QueryUnescape(pair[0])\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tpassword, err := url.QueryUnescape(pair[1])\n\tif err != nil {\n\t\treturn nil, ... |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) addCustomRequestHeader(name, value string) {\n\n\t// lowercase the header name so we can easily check for duplicates in other places.\n\t// there can legitimately be many headers with the same name, but in some cases\n\t// (e.g., auth token) we want to e... | {
"audio": "",
"image": "",
"text": " there is only one.\n\t// Go internally canonicalizes them when we call Header.Add() anyways.\n\tname = strings.ToLower(name)\n\n\tc.customRequestHeaders = append(c.customRequestHeaders, [2]string{name, value})\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " the state of the charm. So returning an error\n\t\t// here in the \"missing\" case makes less sense than in other\n\t\t// places. We could simply ignore any error that surfaces for\n\t\t// that case. However, returning the error communicates to the\n\t\t// charm author that w... |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) processCustomHeaders(req *http.Request)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tfor _, pair := range c.customRequestHeaders {\n\t\treq.Header.Add(pair[0], pair[1])\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " CreateRETSVersioner(retsVersion),\n\t\tGetSessionID: CreateSessionIDer(client.Jar),\n\t}).Request\n\t// 1) apply default headers first (outermost wrapping)\n\theaders := func(ctx context.Context, req *http.Request) (*http.Response, error) {\n\t\treq.Header.Set(UserAgent... |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) AciGwPost(obj *AciGw) error {\n\t// build key and URL\n\tkeyStr := obj.Name\n\turl := c.baseURL + \"/api/v1/aciGws/\" + keyStr + \"/\"\n\n\t// http post the object\n\terr := c.httpPost(url, obj)\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\tlog.Debugf(\"Error creating aciGw %+v. Err: %v\", obj, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " GetObjNamespaceName(obj) + \"/\" + string(obj.GetUID())\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) AciGwList() (*[]*AciGw, error) {\n\t// build key and URL\n\turl := c.baseURL + \"/api/v1/aciGws/\"\n\n\t// http get the object\n\tvar objList []*AciGw\n\terr := c.httpGet(url, &objList)\n\tif err != nil {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tlog.Debugf(\"Error getting aciGws. Err: %v\", err)\n\t\treturn nil, err\n\t}\n\n\treturn &objList, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\turl = url + \"?\" + data.Encode()\n\t}\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c.doHTTP(req)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *ContivClient) AciGwDelete(name string) error {\n\t// build key and URL\n\tkeyStr := name\n\turl := c.baseURL + \"/api/v1/aciGws/\" + keyStr + \"/\"\n\n\t// http get the object\n\terr := c.httpDelete(url)\n\tif err",
"video": ""
} | {
"audio": "",
"image": "",
"text": " != nil {\n\t\tlog.Debugf(\"Error deleting aciGw %s. Err: %v\", keyStr, err)\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\turl = url + \"?\" + data.Encode()\n\t}\n\treq, err := http.NewRequest(\"GET\", url, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn c.doHTTP(req)\n}",
"video": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.