blob: 44fc805962eca0e03d1d10e59b1deec8eceb4d76 [file] [log] [blame]
Girish Gowdra64503432020-01-07 10:59:10 +05301/*
2 * Copyright 2018-present Open Networking Foundation
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
17package config
18
19import (
20 "flag"
21 "fmt"
22 "github.com/opencord/voltha-lib-go/v2/pkg/log"
23 "strconv"
24 "strings"
25)
26
27// Open OLT default constants
28const (
29 defaultOpenOltAgentIp = "10.90.0.114"
30 defaultOpenOltAgentPort = 9191
31 defaultNumOfOnu = 128
32 defaultNumOfSubscribersPerOnu = 1
33 defaultWorkFlowName = "ATT"
34 defaultTimeIntervalBetweenSubs = 5 // in seconds
35 defaultNniIntfId = 0
36 defaultKVstoreHost = "192.168.1.11"
37 defaultKVstorePort = 2379
38 defaultTpIDs = "64"
39)
40
41// OpenOltScaleTesterConfigConfig represents the set of configurations used by the read-write adaptercore service
42type OpenOltScaleTesterConfig struct {
43 // Command line parameters
44 OpenOltAgentAddress string
45 OpenOltAgentIP string
46 OpenOltAgentPort uint
47 NniIntfID uint
48 NumOfOnu uint
49 SubscribersPerOnu uint
50 WorkflowName string
51 TimeIntervalBetweenSubs uint // in seconds
52 KVStoreHost string
53 KVStorePort int
54 TpIDsString string
55 TpIDList []int
56}
57
58func init() {
59 _, _ = log.AddPackage(log.JSON, log.WarnLevel, nil)
60}
61
62func GetTpIDList(tpIDsStr string) []int {
63 stringSlice := strings.Split(tpIDsStr, ",")
64 var tpIDSlice []int
65 for _, s := range stringSlice {
66 if tpID, err := strconv.Atoi(s); err == nil {
67 tpIDSlice = append(tpIDSlice, tpID)
68 }
69 }
70 log.Debugw("parsed-tp-id-slice", log.Fields{"tpIDSlice": tpIDSlice})
71 return tpIDSlice
72}
73
74// NewOpenOltScaleTesterConfig returns a new RWCore config
75func NewOpenOltScaleTesterConfig() *OpenOltScaleTesterConfig {
76 var OpenOltScaleTesterConfig = OpenOltScaleTesterConfig{ // Default values
77 OpenOltAgentAddress: defaultOpenOltAgentIp + ":" + strconv.Itoa(defaultOpenOltAgentPort),
78 NumOfOnu: defaultNumOfOnu,
79 SubscribersPerOnu: defaultNumOfSubscribersPerOnu,
80 WorkflowName: defaultWorkFlowName,
81 TimeIntervalBetweenSubs: defaultTimeIntervalBetweenSubs,
82 NniIntfID: defaultNniIntfId,
83 KVStoreHost: defaultKVstoreHost,
84 KVStorePort: defaultKVstorePort,
85 TpIDList: GetTpIDList(defaultTpIDs),
86 }
87 return &OpenOltScaleTesterConfig
88}
89
90// ParseCommandArguments parses the arguments for OpenOltScale Tester
91func (st *OpenOltScaleTesterConfig) ParseCommandArguments() {
92
93 help := fmt.Sprintf("OpenOLT Agent IP Address")
94 flag.StringVar(&(st.OpenOltAgentIP), "openolt_agent_ip_address", defaultOpenOltAgentIp, help)
95
96 help = fmt.Sprintf("OpenOLT Agent gRPC port")
97 flag.UintVar(&(st.OpenOltAgentPort), "openolt_agent_port", defaultOpenOltAgentPort, help)
98
99 help = fmt.Sprintf("OpenOLT Agent Nni Intf Id")
100 flag.UintVar(&(st.NniIntfID), "openolt_agent_nni_intf_id", defaultNniIntfId, help)
101
102 help = fmt.Sprintf("Number of ONU")
103 flag.UintVar(&(st.NumOfOnu), "num_of_onu", defaultNumOfOnu, help)
104
105 help = fmt.Sprintf("Subscribers per ONU")
106 flag.UintVar(&(st.SubscribersPerOnu), "subscribers_per_onu", defaultNumOfSubscribersPerOnu, help)
107
108 help = fmt.Sprintf("Workflow name")
109 flag.StringVar(&(st.WorkflowName), "workflow_name", defaultWorkFlowName, help)
110
111 help = fmt.Sprintf("Time Interval Between provisioning each subscriber")
112 flag.UintVar(&(st.TimeIntervalBetweenSubs), "time_interval_between_subs", defaultTimeIntervalBetweenSubs, help)
113
114 help = fmt.Sprintf("KV store host")
115 flag.StringVar(&(st.KVStoreHost), "kv_store_host", defaultKVstoreHost, help)
116
117 help = fmt.Sprintf("KV store port")
118 flag.IntVar(&(st.KVStorePort), "kv_store_port", defaultKVstorePort, help)
119
120 help = fmt.Sprintf("Command seperated TP ID list for Workflow")
121 flag.StringVar(&(st.TpIDsString), "tp_ids", defaultTpIDs, help)
122
123 flag.Parse()
124
125}