Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshsimaria committed Dec 22, 2018
1 parent 41098aa commit a2b8479
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 98 deletions.
6 changes: 0 additions & 6 deletions context.go
Expand Up @@ -43,12 +43,6 @@ func work(jctx *JCtx, statusch chan bool) {
var opts []grpc.DialOption

vendor, err := getVendor(jctx)
if *conTestData && vendor.consumeTestData != nil {
vendor.consumeTestData(jctx)
statusch <- false
return
}

if opts, err = getGPRCDialOptions(jctx, vendor); err != nil {
jLog(jctx, fmt.Sprintf("%v", err))
statusch <- false
Expand Down
2 changes: 1 addition & 1 deletion influx.go
Expand Up @@ -69,7 +69,7 @@ func pointAcculumator(jctx *JCtx) {
freq := jctx.config.Influx.AccumulatorFrequency
accumulatorCh := make(chan *metricIDB, 1024*10)
jctx.influxCtx.accumulatorCh = accumulatorCh
jLog(jctx, fmt.Sprintln("Accumulator frequency:", freq))
jLog(jctx, fmt.Sprintln("Accumulator frequency:", freq))

ticker := time.NewTicker(time.Duration(freq) * time.Millisecond)

Expand Down
3 changes: 0 additions & 3 deletions multi_vendor.go
Expand Up @@ -14,7 +14,6 @@ type vendor struct {
sendLoginCheck func(*JCtx, *grpc.ClientConn) error
dialExt func(*JCtx) grpc.DialOption
subscribe func(*grpc.ClientConn, *JCtx, chan<- bool) SubErrorCode
consumeTestData func(*JCtx)
}

func getVendor(jctx *JCtx) (*vendor, error) {
Expand All @@ -38,7 +37,6 @@ func newJuniperJUNOS() *vendor {
sendLoginCheck: loginCheckJunos,
dialExt: nil,
subscribe: subscribeJunos,
consumeTestData: nil,
}
}

Expand All @@ -49,6 +47,5 @@ func newCiscoIOSXR() *vendor {
sendLoginCheck: nil,
dialExt: dialExtensionXR,
subscribe: subscribeXR,
consumeTestData: consumeTestDataXR,
}
}
88 changes: 0 additions & 88 deletions subscribe_cisco_iosxr.go
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -162,93 +161,6 @@ func generateTestData(jctx *JCtx, data []byte) {
}
}

func consumeTestDataXR(jctx *JCtx) {
schema, err := getXRSchema(jctx)
if err != nil {
jLog(jctx, fmt.Sprintf("%s", err))
return
}

sizeFileContent, err := ioutil.ReadFile(jctx.file + ".testmeta")
if err != nil {
log.Printf("%v", err)
return
}

data, err := os.Open(jctx.file + ".testbytes")
if err != nil {
log.Printf("%v data: %v", err, data)
return
}
defer data.Close()

testRes, err := os.Create(jctx.file + ".testres")
if err != nil {
log.Printf("%v data: %v", err, data)
return
}
jctx.testRes = testRes
defer testRes.Close()

sizes := strings.Split(string(sizeFileContent), ":")
for _, size := range sizes {
if size != "" {
n, err := strconv.ParseInt(size, 10, 64)
if err != nil {
fmt.Printf("%v\n", err)
return
}
fmt.Printf("Reading %d bytes\n", n)
d := make([]byte, n)
bytesRead, err := data.Read(d)
if err != nil {
fmt.Printf("%v\n", err)
return
}
if int64(bytesRead) != n {
fmt.Printf("want %d got %d", n, bytesRead)
return
}
message := new(telemetry.Telemetry)
err = proto.Unmarshal(d, message)
if err != nil {
fmt.Printf("%v\n", err)
return
}
path := message.GetEncodingPath()
if path == "" {
jLog(jctx, "Device did not send encoding path - ignoring this message")
continue
}

ePath := strings.Split(path, "/")
if len(ePath) == 1 {
jLog(jctx, fmt.Sprintf("The message matched with top-level subscription %s\n", ePath))
for _, nodes := range schema.nodes {
for _, node := range nodes {
if strings.Compare(ePath[0], node.Name) == 0 {
for _, fields := range message.GetDataGpbkv() {
parentPath := []string{node.Name}
processTopLevelMsg(jctx, node, fields, parentPath)
}
}
}
}
} else if len(ePath) >= 2 {
jLog(jctx, fmt.Sprintf("Multi level path %s", ePath))
for _, nodes := range schema.nodes {
for _, node := range nodes {
if strings.Compare(ePath[0], node.Name) == 0 {
processMultiLevelMsg(jctx, node, ePath, message)
}
}
}

}
}
}
}

func handleOnePath(schema *schema, id int64, path string, conn *grpc.ClientConn, jctx *JCtx, statusch chan<- bool, datach chan<- struct{}) {
c := pb.NewGRPCConfigOperClient(conn)

Expand Down

0 comments on commit a2b8479

Please sign in to comment.