Skip to content
Snippets Groups Projects
Commit be5abea2 authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

Merge upstream develop

parents d8824d8b 8c5a0b7d
No related branches found
No related tags found
2 merge requests!30Gosdn cli features flow,!18Develop
run:
timeout: 5m
issues-exit-code: 1
output:
format: code-climate
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
path-prefix: ""
linters-settings:
gocyclo:
min-complexity: 15
golint:
min-confidence: 0.8
linters:
disable-all: true
enable:
- gofmt
- golint
- gocyclo
- govet
issues:
exclude-use-default: false
run:
timeout: 5m
issues-exit-code: 1
output:
format: code-climate
print-issued-lines: true
print-linter-name: true
uniq-by-line: true
path-prefix: ""
linters-settings:
gocyclo:
min-complexity: 15
golint:
min-confidence: 0.8
linters:
disable-all: true
enable:
- gofmt
- golint
- gocyclo
- govet
stages:
- test
code-quality-master:
image: golangci/golangci-lint:latest-alpine
tags:
- docker
stage: test
only:
- merge_requests
except:
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != "master"
script:
- git config --global url."https://$GO_MODULES_USER:$GO_MODULES_ACCESS_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de"
# writes golangci-lint output to gl-code-quality-report.json
- golangci-lint run --config .ci/.golangci-master.yml | tee gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.json
code-quality:
image: golangci/golangci-lint:latest-alpine
tags:
- docker
stage: test
only:
- merge_requests
except:
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"
script:
- git config --global url."https://$GO_MODULES_USER:$GO_MODULES_ACCESS_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de"
# writes golangci-lint output to gl-code-quality-report.json
- golangci-lint run --config .ci/.golangci.yml | tee gl-code-quality-report.json
artifacts:
reports:
codequality: gl-code-quality-report.json
Documentation: Documentation:
image: image:
...@@ -13,4 +52,4 @@ Documentation: ...@@ -13,4 +52,4 @@ Documentation:
- pandoc --filter pandoc-citeproc --bibliography=bibliography.bib --csl=acm-sig-proceedings.csl --variable papersize=a4paper -s *.md -o documentation.pdf - pandoc --filter pandoc-citeproc --bibliography=bibliography.bib --csl=acm-sig-proceedings.csl --variable papersize=a4paper -s *.md -o documentation.pdf
artifacts: artifacts:
paths: paths:
- documentation/design/documentation.pdf - documentation/design/documentation.pdf
\ No newline at end of file
...@@ -35,7 +35,9 @@ func createDriver(uri, username, password string, encrypted bool) neo4j.Driver { ...@@ -35,7 +35,9 @@ func createDriver(uri, username, password string, encrypted bool) neo4j.Driver {
}, },
) )
logError("failed creating database Driver", err) if err != nil {
log.Info("failed creating database Driver:", err)
}
return driver return driver
} }
...@@ -45,7 +47,9 @@ func createSession(driver neo4j.Driver) neo4j.Session { ...@@ -45,7 +47,9 @@ func createSession(driver neo4j.Driver) neo4j.Session {
sessionConfig := neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite} sessionConfig := neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite}
session, err := driver.NewSession(sessionConfig) session, err := driver.NewSession(sessionConfig)
logError("failed creating database session", err) if err != nil {
log.Info("failed creating database session:", err)
}
return session return session
} }
...@@ -71,7 +75,9 @@ func (d Database) StoreNodes(json string) { ...@@ -71,7 +75,9 @@ func (d Database) StoreNodes(json string) {
"stringToAdd": json, "stringToAdd": json,
}) })
logError("failed storing Nodes into database", err) if err != nil {
log.Info("failed storing Nodes into database:", err)
}
log.Info("successfully added Nodes into database") log.Info("successfully added Nodes into database")
} }
...@@ -96,7 +102,9 @@ func (d Database) StoreNodeEdgePoints(json string) { ...@@ -96,7 +102,9 @@ func (d Database) StoreNodeEdgePoints(json string) {
"stringToAdd": json, "stringToAdd": json,
}) })
logError("failed storing NodeEdgePoints into database", err) if err != nil {
log.Info("failed storing NodeEdgePoints into database:", err)
}
setNodeNodeEdgePointsRelation(session) setNodeNodeEdgePointsRelation(session)
...@@ -104,7 +112,7 @@ func (d Database) StoreNodeEdgePoints(json string) { ...@@ -104,7 +112,7 @@ func (d Database) StoreNodeEdgePoints(json string) {
} }
func (d Database) StoreConnections(json string){} func (d Database) StoreConnections(json string) {}
//setNodeNodeEdgePointsRelation creates the database relations between "nodes" and "node edge points" //setNodeNodeEdgePointsRelation creates the database relations between "nodes" and "node edge points"
func setNodeNodeEdgePointsRelation(session neo4j.Session) { func setNodeNodeEdgePointsRelation(session neo4j.Session) {
...@@ -118,14 +126,13 @@ func setNodeNodeEdgePointsRelation(session neo4j.Session) { ...@@ -118,14 +126,13 @@ func setNodeNodeEdgePointsRelation(session neo4j.Session) {
_, err := session.Run( _, err := session.Run(
query, map[string]interface{}{}) query, map[string]interface{}{})
logError("failed storing NodeNodeEdgePointsRelation into database", err) if err != nil {
log.Info("failed storing NodeNodeEdgePointsRelation into database:", err)
}
log.Info("successfully stored NodeNodeEdgePointsRelation into database") log.Info("successfully stored NodeNodeEdgePointsRelation into database")
} }
//logError logs error with custom and error message //logError logs error with custom and error message
func logError(message string, err error) { func logError(message string, err error) {
if err != nil {
log.Info("%v: %v", message, err)
}
} }
...@@ -13,7 +13,6 @@ require ( ...@@ -13,7 +13,6 @@ require (
github.com/neo4j/neo4j-go-driver v1.8.3 github.com/neo4j/neo4j-go-driver v1.8.3
github.com/rivo/tview v0.0.0-20200915114512-42866ecf6ca6 github.com/rivo/tview v0.0.0-20200915114512-42866ecf6ca6
golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
golang.org/x/tools v0.0.0-20190617190820-da514acc4774
google.golang.org/genproto v0.0.0-20200519141106-08726f379972 // indirect google.golang.org/genproto v0.0.0-20200519141106-08726f379972 // indirect
google.golang.org/grpc v1.29.1 google.golang.org/grpc v1.29.1
google.golang.org/protobuf v1.23.0 google.golang.org/protobuf v1.23.0
......
...@@ -3,13 +3,13 @@ package main ...@@ -3,13 +3,13 @@ package main
import ( import (
pb "code.fbi.h-da.de/cocsn/gosdn/cliInterface" pb "code.fbi.h-da.de/cocsn/gosdn/cliInterface"
"context" "context"
"flag"
"fmt" "fmt"
"github.com/rivo/tview" "github.com/rivo/tview"
"google.golang.org/grpc" "google.golang.org/grpc"
"log" "log"
"os" "os"
"time" "time"
"flag"
) )
const ( const (
...@@ -29,18 +29,18 @@ var ( ...@@ -29,18 +29,18 @@ var (
type cliClientConfig struct { type cliClientConfig struct {
goSDNCLIAddr4 *string goSDNCLIAddr4 *string
goSDNCLIPort4 *int goSDNCLIPort4 *int
interactive *bool interactive *bool
goSDNCommand *string goSDNCommand *string
} }
type commandOptions struct { type commandOptions struct {
name string name string
description string description string
command func(conn *grpc.ClientConn) () command func(conn *grpc.ClientConn)
} }
var commandList = map[string] commandOptions { var commandList = map[string]commandOptions{
"hello": {"hello", "test connection to goSDN controller", goSDNSayHello}, "hello": {"hello", "test connection to goSDN controller", goSDNSayHello},
"shutdown": {"shutdown", "request goSDN controller to shutdown", goSDNShutdown}, "shutdown": {"shutdown", "request goSDN controller to shutdown", goSDNShutdown},
"testdb" : {"testdb", "test all database connections", goSDNTestDB}, "testdb" : {"testdb", "test all database connections", goSDNTestDB},
"tapigetnodes" : {"testdb", "test all database connections", goSDNTestDB}, "tapigetnodes" : {"testdb", "test all database connections", goSDNTestDB},
...@@ -50,7 +50,7 @@ var commandList = map[string] commandOptions { ...@@ -50,7 +50,7 @@ var commandList = map[string] commandOptions {
gosdn-cli allows to mode of operations: gosdn-cli allows to mode of operations:
- interactive: text GUI to operate goSDN - interactive: text GUI to operate goSDN
- non-interactive: basic CLI without text GUI - non-interactive: basic CLI without text GUI
*/ */
func main() { func main() {
// This holds the basic configuration for gosdn-cli // This holds the basic configuration for gosdn-cli
...@@ -65,7 +65,7 @@ func main() { ...@@ -65,7 +65,7 @@ func main() {
flag.Parse() flag.Parse()
// Print complete command list and exit // Print complete command list and exit
if (*printCommandList == true) { if *printCommandList == true {
for _, element := range commandList { for _, element := range commandList {
fmt.Println(element.name + "\t" + element.description) fmt.Println(element.name + "\t" + element.description)
} }
...@@ -88,11 +88,11 @@ func main() { ...@@ -88,11 +88,11 @@ func main() {
log.Println(("Connected to " + conn.Target())) log.Println(("Connected to " + conn.Target()))
// Check for non-interactive or interactive mode // Check for non-interactive or interactive mode
if(*myConfiguration.interactive == false) { if *myConfiguration.interactive == false {
log.Println("starting in non-interactive mode") log.Println("starting in non-interactive mode")
// Lookup command or die // Lookup command or die
_, found := commandList[*myConfiguration.goSDNCommand] _, found := commandList[*myConfiguration.goSDNCommand]
if(found) { if found {
// Excecute desired command // Excecute desired command
commandList[*myConfiguration.goSDNCommand].command(conn) commandList[*myConfiguration.goSDNCommand].command(conn)
} else { } else {
...@@ -119,9 +119,9 @@ func main() { ...@@ -119,9 +119,9 @@ func main() {
} }
} }
func goSDNSayHello(conn *grpc.ClientConn) {
func goSDNSayHello (conn *grpc.ClientConn) { func goSDNSayHello (conn *grpc.ClientConn) {
c := pb.NewGrpcCliClient(conn) c := pb.NewGrpcCliClient(conn)
// Contact the server and print out its response. // Contact the server and print out its response.
...@@ -137,10 +137,9 @@ func goSDNSayHello (conn *grpc.ClientConn) { ...@@ -137,10 +137,9 @@ func goSDNSayHello (conn *grpc.ClientConn) {
} }
log.Printf("Greeting: %s", r.String()) log.Printf("Greeting: %s", r.String())
} }
func goSDNShutdown (conn *grpc.ClientConn) { func goSDNShutdown(conn *grpc.ClientConn) {
c := pb.NewGrpcCliClient(conn) c := pb.NewGrpcCliClient(conn)
...@@ -158,6 +157,6 @@ func goSDNShutdown (conn *grpc.ClientConn) { ...@@ -158,6 +157,6 @@ func goSDNShutdown (conn *grpc.ClientConn) {
log.Printf("Greeting: %s", r.GetMessage()) log.Printf("Greeting: %s", r.GetMessage())
} }
func goSDNTestDB(conn *grpc.ClientConn){ func goSDNTestDB(conn *grpc.ClientConn) {
// TODO: fill with code // TODO: fill with code
} }
\ No newline at end of file
...@@ -45,27 +45,27 @@ func Output(out io.Writer) { ...@@ -45,27 +45,27 @@ func Output(out io.Writer) {
} }
func Debug(args ...interface{}) { func Debug(args ...interface{}) {
log(DEBUG, args) log(DEBUG, args...)
} }
func Info(args ...interface{}) { func Info(args ...interface{}) {
log(INFO, args) log(INFO, args...)
} }
func Warn(args ...interface{}) { func Warn(args ...interface{}) {
log(WARNING, args) log(WARNING, args...)
} }
func Error(args ...interface{}) { func Error(args ...interface{}) {
log(ERROR, args) log(ERROR, args...)
} }
func Fatal(args ...interface{}) { func Fatal(args ...interface{}) {
log(FATAL, args) log(FATAL, args...)
} }
func Panic(args ...interface{}) { func Panic(args ...interface{}) {
log(PANIC, args) log(PANIC, args...)
} }
func log(level Level, args ...interface{}) { func log(level Level, args ...interface{}) {
......
...@@ -48,7 +48,7 @@ func (c *Core) Init(socket, configfile string) { ...@@ -48,7 +48,7 @@ func (c *Core) Init(socket, configfile string) {
c.AttachDatabase() c.AttachDatabase()
//TODO: Create client config/CLI adapter //TODO: Create client config/CLI adapter
c.clients["ciena-mcp"] = ciena.NewMCPClient( "141.100.70.170", "", "", &c.database) c.clients["ciena-mcp"] = ciena.NewMCPClient("141.100.70.170", "", "", &c.database)
} }
func (c *Core) AttachDatabase() { func (c *Core) AttachDatabase() {
......
...@@ -9,7 +9,7 @@ type YANGConsumer struct { ...@@ -9,7 +9,7 @@ type YANGConsumer struct {
Data *bytes.Buffer Data *bytes.Buffer
} }
func (yc YANGConsumer)Consume(reader io.Reader, _ interface{}) error { func (yc YANGConsumer) Consume(reader io.Reader, _ interface{}) error {
_,err := yc.Data.ReadFrom(reader) _, err := yc.Data.ReadFrom(reader)
return err return err
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment