Matteo Scandolo | 4747d29 | 2019-08-05 11:50:18 -0700 | [diff] [blame^] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "flag" |
| 5 | "gerrit.opencord.org/bbsim/internal/bbsim/devices" |
| 6 | log "github.com/sirupsen/logrus" |
| 7 | "sync" |
| 8 | ) |
| 9 | |
| 10 | func getOpts() *CliOptions { |
| 11 | |
| 12 | olt_id := flag.Int("olt_id", 0, "Number of OLT devices to be emulated (default is 1)") |
| 13 | nni := flag.Int("nni", 1, "Number of NNI ports per OLT device to be emulated (default is 1)") |
| 14 | pon := flag.Int("pon", 1, "Number of PON ports per OLT device to be emulated (default is 1)") |
| 15 | onu := flag.Int("onu", 1, "Number of ONU devices per PON port to be emulated (default is 1)") |
| 16 | flag.Parse() |
| 17 | |
| 18 | o := new(CliOptions) |
| 19 | |
| 20 | o.OltID = int(*olt_id) |
| 21 | o.NumNniPerOlt = int(*nni) |
| 22 | o.NumPonPerOlt = int(*pon) |
| 23 | o.NumOnuPerPon = int(*onu) |
| 24 | |
| 25 | return o |
| 26 | } |
| 27 | |
| 28 | func init() { |
| 29 | log.SetLevel(log.DebugLevel) |
| 30 | //log.SetReportCaller(true) |
| 31 | } |
| 32 | |
| 33 | func main() { |
| 34 | |
| 35 | options := getOpts() |
| 36 | |
| 37 | log.WithFields(log.Fields{ |
| 38 | "OltID": options.OltID, |
| 39 | "NumNniPerOlt": options.NumNniPerOlt, |
| 40 | "NumPonPerOlt": options.NumPonPerOlt, |
| 41 | "NumOnuPerPon": options.NumOnuPerPon, |
| 42 | }).Info("BroadBand Simulator is on") |
| 43 | |
| 44 | wg := sync.WaitGroup{} |
| 45 | wg.Add(1) |
| 46 | |
| 47 | |
| 48 | go devices.CreateOLT(options.OltID, options.NumNniPerOlt, options.NumPonPerOlt, options.NumOnuPerPon) |
| 49 | log.Debugf("Created OLT with id: %d", options.OltID) |
| 50 | |
| 51 | wg.Wait() |
| 52 | |
| 53 | defer func() { |
| 54 | log.Info("BroadBand Simulator is off") |
| 55 | }() |
| 56 | } |