Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 1 | /* |
Joey Armstrong | 11f5a57 | 2024-01-12 19:11:32 -0500 | [diff] [blame] | 2 | * Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 3 | |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 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 |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 7 | |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 9 | |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 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. |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 15 | */ |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 16 | |
Joey Armstrong | 3f0e242 | 2023-07-05 18:25:41 -0400 | [diff] [blame] | 17 | // Package config provides the Log, kvstore, Kafka configuration |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 18 | package config |
| 19 | |
| 20 | import ( |
| 21 | "flag" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 22 | "os" |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 23 | "time" |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | // Open OLT default constants |
| 27 | const ( |
Abhay Kumar | 9bcfeb2 | 2024-07-12 09:14:25 +0530 | [diff] [blame] | 28 | KVStoreName = "etcd" |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 29 | defaultInstanceid = "openOlt001" |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 30 | defaultKafkaclusteraddress = "127.0.0.1:9092" |
Abhay Kumar | 9bcfeb2 | 2024-07-12 09:14:25 +0530 | [diff] [blame] | 31 | defaultKvstoretype = KVStoreName |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 32 | defaultKvstoretimeout = 5 * time.Second |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 33 | defaultRPCTimeout = 10 * time.Second |
nikesh.krishnan | 6dd882b | 2023-03-14 10:02:41 +0530 | [diff] [blame] | 34 | defaultPerRPCRetryTimeout = 2 * time.Second |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 35 | defaultKvstoreaddress = "127.0.0.1:2379" // Port: Consul = 8500; Etcd = 2379 |
David Bainbridge | 2b3d488 | 2020-03-17 15:06:39 -0700 | [diff] [blame] | 36 | defaultLoglevel = "WARN" |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 37 | defaultBanner = false |
| 38 | defaultDisplayVersionOnly = false |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 39 | defaultEventtopic = "voltha.events" |
| 40 | defaultOnunumber = 1 |
Neha Sharma | 3f221ae | 2020-04-29 19:02:12 +0000 | [diff] [blame] | 41 | defaultProbeAddress = ":8080" |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 42 | defaultLiveProbeInterval = 60 * time.Second |
| 43 | defaultNotLiveProbeInterval = 5 * time.Second // Probe more frequently when not alive |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 44 | // defaultHeartbeatCheckInterval is the time in seconds the adapter will keep checking the hardware for heartbeat. |
Girish Gowdra | 495dde4 | 2021-03-17 14:59:56 -0700 | [diff] [blame] | 45 | defaultHeartbeatCheckInterval = 15 * time.Second |
| 46 | // defaultHeartbeatFailReportInterval is the time adapter will wait before updating the state to the core. |
| 47 | defaultHeartbeatFailReportInterval = 0 * time.Second |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 48 | defaultGrpcAddress = ":50060" |
| 49 | defaultCoreEndpoint = ":55555" |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 50 | // defaultGrpcTimeoutInterval is the time in seconds a grpc call will wait before returning error. |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 51 | defaultGrpcTimeoutInterval = 2 * time.Second |
| 52 | defaultCurrentReplica = 1 |
| 53 | defaultTotalReplicas = 1 |
| 54 | defaultTraceEnabled = false |
| 55 | defaultTraceAgentAddress = "127.0.0.1:6831" |
| 56 | defaultLogCorrelationEnabled = true |
| 57 | defaultOmccEncryption = false |
| 58 | defaultEnableONUStats = false |
| 59 | defaultEnableGEMStats = false |
| 60 | defaultMinBackoffRetryDelay = 500 * time.Millisecond |
| 61 | defaultMaxBackoffRetryDelay = 10 * time.Second |
| 62 | defaultAdapterEndpoint = "adapter-open-olt" |
| 63 | defaultCheckOnuDevExistenceAtOnuDiscovery = false |
Sridhar Ravindra | ab785f2 | 2025-07-21 17:20:55 +0530 | [diff] [blame] | 64 | defaultForceOnuDiscIndProcessing = false |
nikesh.krishnan | 6dd882b | 2023-03-14 10:02:41 +0530 | [diff] [blame] | 65 | defaultMaxRetries = 10 |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 66 | ) |
| 67 | |
| 68 | // AdapterFlags represents the set of configurations used by the read-write adaptercore service |
| 69 | type AdapterFlags struct { |
| 70 | // Command line parameters |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 71 | AdapterName string |
| 72 | InstanceID string // NOTE what am I used for? why not cli but only ENV? TODO expose in the chart |
| 73 | KafkaClusterAddress string |
| 74 | KVStoreType string |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 75 | KVStoreAddress string |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 76 | EventTopic string |
| 77 | LogLevel string |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 78 | ProbeAddress string |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 79 | GrpcAddress string |
| 80 | CoreEndpoint string |
| 81 | TraceAgentAddress string |
| 82 | AdapterEndpoint string |
| 83 | KVStoreTimeout time.Duration |
| 84 | RPCTimeout time.Duration |
| 85 | PerRPCRetryTimeout time.Duration |
| 86 | OnuNumber int |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 87 | LiveProbeInterval time.Duration |
| 88 | NotLiveProbeInterval time.Duration |
| 89 | HeartbeatCheckInterval time.Duration |
| 90 | HeartbeatFailReportInterval time.Duration |
| 91 | GrpcTimeoutInterval time.Duration |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 92 | CurrentReplica int |
| 93 | TotalReplicas int |
Akash Kankanala | 041a212 | 2024-10-16 15:49:22 +0530 | [diff] [blame] | 94 | MinBackoffRetryDelay time.Duration |
| 95 | MaxBackoffRetryDelay time.Duration |
| 96 | MaxRetries uint |
| 97 | Banner bool |
| 98 | DisplayVersionOnly bool |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 99 | TraceEnabled bool |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 100 | LogCorrelationEnabled bool |
| 101 | OmccEncryption bool |
| 102 | EnableONUStats bool |
| 103 | EnableGEMStats bool |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 104 | CheckOnuDevExistenceAtOnuDiscovery bool |
Sridhar Ravindra | ab785f2 | 2025-07-21 17:20:55 +0530 | [diff] [blame] | 105 | ForceOnuDiscIndProcessing bool |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 106 | } |
| 107 | |
Girish Gowdru | 6a80bbd | 2019-07-02 07:36:09 -0700 | [diff] [blame] | 108 | // NewAdapterFlags returns a new RWCore config |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 109 | func NewAdapterFlags() *AdapterFlags { |
| 110 | var adapterFlags = AdapterFlags{ // Default values |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 111 | InstanceID: defaultInstanceid, |
| 112 | KafkaClusterAddress: defaultKafkaclusteraddress, |
| 113 | KVStoreType: defaultKvstoretype, |
| 114 | KVStoreTimeout: defaultKvstoretimeout, |
| 115 | KVStoreAddress: defaultKvstoreaddress, |
| 116 | EventTopic: defaultEventtopic, |
| 117 | LogLevel: defaultLoglevel, |
| 118 | OnuNumber: defaultOnunumber, |
| 119 | Banner: defaultBanner, |
| 120 | DisplayVersionOnly: defaultDisplayVersionOnly, |
| 121 | ProbeAddress: defaultProbeAddress, |
| 122 | LiveProbeInterval: defaultLiveProbeInterval, |
| 123 | NotLiveProbeInterval: defaultNotLiveProbeInterval, |
| 124 | HeartbeatCheckInterval: defaultHeartbeatCheckInterval, |
| 125 | HeartbeatFailReportInterval: defaultHeartbeatFailReportInterval, |
| 126 | GrpcAddress: defaultGrpcAddress, |
| 127 | CoreEndpoint: defaultCoreEndpoint, |
| 128 | GrpcTimeoutInterval: defaultGrpcTimeoutInterval, |
| 129 | TraceEnabled: defaultTraceEnabled, |
| 130 | TraceAgentAddress: defaultTraceAgentAddress, |
| 131 | LogCorrelationEnabled: defaultLogCorrelationEnabled, |
| 132 | OmccEncryption: defaultOmccEncryption, |
| 133 | EnableONUStats: defaultEnableONUStats, |
| 134 | EnableGEMStats: defaultEnableGEMStats, |
| 135 | RPCTimeout: defaultRPCTimeout, |
nikesh.krishnan | 6dd882b | 2023-03-14 10:02:41 +0530 | [diff] [blame] | 136 | PerRPCRetryTimeout: defaultPerRPCRetryTimeout, |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 137 | MinBackoffRetryDelay: defaultMinBackoffRetryDelay, |
| 138 | MaxBackoffRetryDelay: defaultMaxBackoffRetryDelay, |
| 139 | CheckOnuDevExistenceAtOnuDiscovery: defaultCheckOnuDevExistenceAtOnuDiscovery, |
Sridhar Ravindra | ab785f2 | 2025-07-21 17:20:55 +0530 | [diff] [blame] | 140 | ForceOnuDiscIndProcessing: defaultForceOnuDiscIndProcessing, |
nikesh.krishnan | 6dd882b | 2023-03-14 10:02:41 +0530 | [diff] [blame] | 141 | MaxRetries: defaultMaxRetries, |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 142 | } |
| 143 | return &adapterFlags |
| 144 | } |
| 145 | |
| 146 | // ParseCommandArguments parses the arguments when running read-write adaptercore service |
| 147 | func (so *AdapterFlags) ParseCommandArguments() { |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 148 | flag.StringVar(&(so.KafkaClusterAddress), |
| 149 | "kafka_cluster_address", |
| 150 | defaultKafkaclusteraddress, |
| 151 | "Kafka - Cluster messaging address") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 152 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 153 | flag.StringVar(&(so.EventTopic), |
| 154 | "event_topic", |
| 155 | defaultEventtopic, |
| 156 | "Event topic") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 157 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 158 | flag.StringVar(&(so.KVStoreType), |
| 159 | "kv_store_type", |
| 160 | defaultKvstoretype, |
| 161 | "KV store type") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 162 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 163 | flag.DurationVar(&(so.KVStoreTimeout), |
| 164 | "kv_store_request_timeout", |
| 165 | defaultKvstoretimeout, |
| 166 | "The default timeout when making a kv store request") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 167 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 168 | flag.StringVar(&(so.KVStoreAddress), |
| 169 | "kv_store_address", |
| 170 | defaultKvstoreaddress, |
| 171 | "KV store address") |
Devmalya Paul | fb990a5 | 2019-07-09 10:01:49 -0400 | [diff] [blame] | 172 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 173 | flag.StringVar(&(so.LogLevel), |
| 174 | "log_level", |
| 175 | defaultLoglevel, |
| 176 | "Log level") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 177 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 178 | flag.IntVar(&(so.OnuNumber), |
| 179 | "onu_number", |
| 180 | defaultOnunumber, |
| 181 | "Number of ONUs") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 182 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 183 | flag.BoolVar(&(so.Banner), |
| 184 | "banner", |
| 185 | defaultBanner, |
| 186 | "Show startup banner log lines") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 187 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 188 | flag.BoolVar(&(so.DisplayVersionOnly), |
| 189 | "version", |
| 190 | defaultDisplayVersionOnly, |
| 191 | "Show version information and exit") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 192 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 193 | flag.StringVar(&(so.ProbeAddress), |
| 194 | "probe_address", |
| 195 | defaultProbeAddress, |
| 196 | "The address on which to listen to answer liveness and readiness probe queries over HTTP.") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 197 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 198 | flag.DurationVar(&(so.LiveProbeInterval), |
| 199 | "live_probe_interval", |
| 200 | defaultLiveProbeInterval, |
| 201 | "Number of seconds for the default liveliness check") |
Matt Jeanneret | f880eb6 | 2019-07-16 20:08:03 -0400 | [diff] [blame] | 202 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 203 | flag.DurationVar(&(so.NotLiveProbeInterval), |
| 204 | "not_live_probe_interval", |
| 205 | defaultNotLiveProbeInterval, |
| 206 | "Number of seconds for liveliness check if probe is not running") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 207 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 208 | flag.DurationVar(&(so.HeartbeatCheckInterval), |
| 209 | "heartbeat_check_interval", |
| 210 | defaultHeartbeatCheckInterval, |
| 211 | "Number of seconds for heartbeat check interval") |
Rohan Agrawal | 828bf4e | 2019-10-22 10:13:19 +0000 | [diff] [blame] | 212 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 213 | flag.DurationVar(&(so.HeartbeatFailReportInterval), |
| 214 | "heartbeat_fail_interval", |
| 215 | defaultHeartbeatFailReportInterval, |
| 216 | "Number of seconds adapter has to wait before reporting core on the heartbeat check failure") |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 217 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 218 | flag.DurationVar(&(so.GrpcTimeoutInterval), |
| 219 | "grpc_timeout_interval", |
| 220 | defaultGrpcTimeoutInterval, |
| 221 | "Number of seconds for GRPC timeout") |
cbabu | 116b73f | 2019-12-10 17:56:32 +0530 | [diff] [blame] | 222 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 223 | flag.IntVar(&(so.CurrentReplica), |
| 224 | "current_replica", |
| 225 | defaultCurrentReplica, |
| 226 | "Replica number of this particular instance") |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 227 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 228 | flag.IntVar(&(so.TotalReplicas), |
| 229 | "total_replica", |
| 230 | defaultTotalReplicas, |
| 231 | "Total number of instances for this adapter") |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 232 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 233 | flag.BoolVar(&(so.TraceEnabled), |
| 234 | "trace_enabled", |
| 235 | defaultTraceEnabled, |
| 236 | "Whether to send logs to tracing agent?") |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 237 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 238 | flag.StringVar(&(so.TraceAgentAddress), |
| 239 | "trace_agent_address", |
| 240 | defaultTraceAgentAddress, |
| 241 | "The address of tracing agent to which span info should be sent") |
Matteo Scandolo | 3ad5d2b | 2020-04-02 17:02:04 -0700 | [diff] [blame] | 242 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 243 | flag.BoolVar(&(so.LogCorrelationEnabled), |
| 244 | "log_correlation_enabled", |
| 245 | defaultLogCorrelationEnabled, |
| 246 | "Whether to enrich log statements with fields denoting operation being executed for achieving correlation?") |
Matteo Scandolo | 3ad5d2b | 2020-04-02 17:02:04 -0700 | [diff] [blame] | 247 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 248 | flag.BoolVar(&(so.OmccEncryption), |
| 249 | "omcc_encryption", |
| 250 | defaultOmccEncryption, |
| 251 | "OMCI Channel encryption status") |
Girish Kumar | 11e1597 | 2020-06-15 14:51:10 +0000 | [diff] [blame] | 252 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 253 | flag.BoolVar(&(so.EnableONUStats), |
| 254 | "enable_onu_stats", |
| 255 | defaultEnableONUStats, |
| 256 | "Enable ONU Statistics") |
Girish Kumar | 11e1597 | 2020-06-15 14:51:10 +0000 | [diff] [blame] | 257 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 258 | flag.BoolVar(&(so.EnableGEMStats), |
| 259 | "enable_gem_stats", |
| 260 | defaultEnableGEMStats, |
| 261 | "Enable GEM Statistics") |
Girish Kumar | 11e1597 | 2020-06-15 14:51:10 +0000 | [diff] [blame] | 262 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 263 | flag.StringVar(&(so.GrpcAddress), |
| 264 | "grpc_address", |
| 265 | defaultGrpcAddress, |
| 266 | "Adapter GRPC Server address") |
kesavand | 494c208 | 2020-08-31 11:16:12 +0530 | [diff] [blame] | 267 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 268 | flag.StringVar(&(so.CoreEndpoint), |
| 269 | "core_endpoint", |
| 270 | defaultCoreEndpoint, |
| 271 | "Core endpoint") |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 272 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 273 | flag.StringVar(&(so.AdapterEndpoint), |
| 274 | "adapter_endpoint", |
| 275 | defaultAdapterEndpoint, |
| 276 | "Adapter Endpoint") |
| 277 | |
| 278 | flag.DurationVar(&(so.RPCTimeout), |
| 279 | "rpc_timeout", |
| 280 | defaultRPCTimeout, |
| 281 | "The default timeout when making an RPC request") |
| 282 | |
| 283 | flag.DurationVar(&(so.MinBackoffRetryDelay), |
| 284 | "min_retry_delay", |
| 285 | defaultMinBackoffRetryDelay, |
| 286 | "The minimum number of milliseconds to delay before a connection retry attempt") |
| 287 | |
nikesh.krishnan | 6dd882b | 2023-03-14 10:02:41 +0530 | [diff] [blame] | 288 | flag.DurationVar(&(so.PerRPCRetryTimeout), |
| 289 | "per_rpc_retry_timeout", |
| 290 | defaultPerRPCRetryTimeout, |
| 291 | "The default timeout per RPC retry") |
| 292 | |
khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 293 | flag.DurationVar(&(so.MaxBackoffRetryDelay), |
| 294 | "max_retry_delay", |
| 295 | defaultMaxBackoffRetryDelay, |
| 296 | "The maximum number of milliseconds to delay before a connection retry attempt") |
Gamze Abaka | fcbd6e7 | 2020-12-17 13:25:16 +0000 | [diff] [blame] | 297 | |
nikesh.krishnan | 6dd882b | 2023-03-14 10:02:41 +0530 | [diff] [blame] | 298 | flag.UintVar(&(so.MaxRetries), |
| 299 | "max_grpc_client_retry", |
| 300 | defaultMaxRetries, |
| 301 | "The maximum number of times olt adaptor will retry in case grpc request timeouts") |
| 302 | |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 303 | flag.BoolVar(&(so.CheckOnuDevExistenceAtOnuDiscovery), |
| 304 | "check_onu_exist_on_discovery", |
| 305 | defaultCheckOnuDevExistenceAtOnuDiscovery, |
| 306 | "Whether to check for flows only or child device before honoring discovery?") |
Sridhar Ravindra | ab785f2 | 2025-07-21 17:20:55 +0530 | [diff] [blame] | 307 | flag.BoolVar(&(so.ForceOnuDiscIndProcessing), |
| 308 | "force_onu_disc_processing", |
| 309 | defaultForceOnuDiscIndProcessing, |
| 310 | "Skip the check for onu device existence on onu discovery") |
Abhilash Laxmeshwar | d0f58cf | 2022-06-01 12:15:19 +0530 | [diff] [blame] | 311 | |
Abhilash Laxmeshwar | f9942e9 | 2020-01-07 15:32:44 +0530 | [diff] [blame] | 312 | flag.Parse() |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 313 | containerName := getContainerInfo() |
| 314 | if len(containerName) > 0 { |
| 315 | so.InstanceID = containerName |
| 316 | } |
Girish Gowdru | 0c588b2 | 2019-04-23 23:24:56 -0400 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | func getContainerInfo() string { |
| 320 | return os.Getenv("HOSTNAME") |
| 321 | } |