Don Newton | 98fd881 | 2019-09-23 15:15:02 -0400 | [diff] [blame] | 1 | /* |
Don Newton | a6f5505 | 2020-01-09 10:38:45 -0500 | [diff] [blame] | 2 | Copyright 2019 the original author or authors. |
Don Newton | 98fd881 | 2019-09-23 15:15:02 -0400 | [diff] [blame] | 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package main |
| 18 | |
| 19 | import ( |
| 20 | "flag" |
Don Newton | a6f5505 | 2020-01-09 10:38:45 -0500 | [diff] [blame] | 21 | |
Don Newton | 7577f07 | 2020-01-06 12:41:11 -0500 | [diff] [blame] | 22 | "github.com/opencord/ofagent-go/settings" |
Don Newton | 98fd881 | 2019-09-23 15:15:02 -0400 | [diff] [blame] | 23 | |
| 24 | "github.com/opencord/ofagent-go/grpc" |
Don Newton | 7577f07 | 2020-01-06 12:41:11 -0500 | [diff] [blame] | 25 | l "github.com/opencord/voltha-lib-go/v2/pkg/log" |
Don Newton | 98fd881 | 2019-09-23 15:15:02 -0400 | [diff] [blame] | 26 | ) |
| 27 | |
| 28 | func main() { |
Don Newton | 7577f07 | 2020-01-06 12:41:11 -0500 | [diff] [blame] | 29 | debug := flag.Bool("debug", false, "Set Debug Level Logging") |
| 30 | var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file`") |
| 31 | var memprofile = flag.String("memprofile", "", "write memory profile to `file`") |
| 32 | |
Don Newton | 98fd881 | 2019-09-23 15:15:02 -0400 | [diff] [blame] | 33 | openflowAddress := flag.String("ofaddress", "localhost", "address of the openflow server") |
| 34 | openflowPort := flag.Uint("openflowPort", 6653, "port the openflow server is listening on") |
| 35 | volthaAddress := flag.String("volthaAddress", "localhost", "address for voltha core / afrouter") |
| 36 | volthaPort := flag.Uint("volthaPort", 50057, "port that voltha core / afrouter listens on ") |
| 37 | flag.Parse() |
| 38 | |
Don Newton | 7577f07 | 2020-01-06 12:41:11 -0500 | [diff] [blame] | 39 | logLevel := l.InfoLevel |
| 40 | if *debug { |
| 41 | logLevel = l.DebugLevel |
| 42 | settings.SetDebug(true) |
| 43 | } else { |
| 44 | settings.SetDebug(false) |
| 45 | } |
| 46 | _, err := l.AddPackage(l.JSON, logLevel, nil) |
| 47 | if err != nil { |
| 48 | l.Errorw("unable-to-register-package-to-the-log-map", l.Fields{"error": err}) |
| 49 | } |
| 50 | l.Infow("ofagent-startup params", l.Fields{"OpenFlowAddress": *openflowAddress, |
| 51 | "OpenFlowPort": *openflowPort, |
| 52 | "VolthaAddress": *volthaAddress, |
| 53 | "VolthaPort": *volthaPort, |
| 54 | "LogLevel": logLevel, |
| 55 | "CpuProfile": *cpuprofile, |
| 56 | "MemProfile": *memprofile}) |
| 57 | |
Don Newton | 98fd881 | 2019-09-23 15:15:02 -0400 | [diff] [blame] | 58 | grpc.StartClient(*volthaAddress, uint16(*volthaPort), *openflowAddress, uint16(*openflowPort)) |
| 59 | } |