Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | //Package config provides the Log, kvstore, Kafka configuration |
| 18 | package config |
| 19 | |
| 20 | import ( |
| 21 | "flag" |
| 22 | "fmt" |
| 23 | "os" |
| 24 | "time" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 25 | ) |
| 26 | |
| 27 | // Open ONU default constants |
| 28 | const ( |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 29 | etcdStoreName = "etcd" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 30 | defaultInstanceid = "openonu" |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 31 | defaultKafkaadapteraddress = "127.0.0.1:9092" |
| 32 | defaultKafkaclusteraddress = "127.0.0.1:9092" |
Himani Chawla | 6d2ae15 | 2020-09-02 13:11:20 +0530 | [diff] [blame] | 33 | defaultKvstoretype = etcdStoreName |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 34 | defaultKvstoretimeout = 5 * time.Second |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 35 | defaultKvstoreaddress = "127.0.0.1:2379" |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 36 | defaultLoglevel = "WARN" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 37 | defaultBanner = false |
| 38 | defaultDisplayVersionOnly = false |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 39 | defaultAccIncrEvto = false |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 40 | defaultTopic = "openonu" |
Holger Hildebrandt | a768fe9 | 2020-10-01 13:06:21 +0000 | [diff] [blame] | 41 | defaultCoreTopic = "rwcore" |
| 42 | defaultEventTopic = "voltha.events" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 43 | defaultOnunumber = 1 |
| 44 | defaultProbeHost = "" |
| 45 | defaultProbePort = 8080 |
| 46 | defaultLiveProbeInterval = 60 * time.Second |
| 47 | defaultNotLiveProbeInterval = 5 * time.Second // Probe more frequently when not alive |
| 48 | //defaultHearbeatFailReportInterval is the time in seconds the adapter will keep checking the hardware for heartbeat. |
| 49 | defaultHearbeatCheckInterval = 30 * time.Second |
| 50 | // defaultHearbeatFailReportInterval is the time adapter will wait before updating the state to the core. |
| 51 | defaultHearbeatFailReportInterval = 180 * time.Second |
| 52 | //defaultKafkaReconnectRetries -1: reconnect endlessly. |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 53 | defaultKafkaReconnectRetries = -1 |
| 54 | defaultCurrentReplica = 1 |
| 55 | defaultTotalReplicas = 1 |
| 56 | defaultMaxTimeoutInterAdapterComm = 30 * time.Second |
Holger Hildebrandt | 38985dc | 2021-02-18 16:25:20 +0000 | [diff] [blame] | 57 | defaultMaxTimeoutReconciling = 10 * time.Second |
Andrea Campanella | 3d7c931 | 2021-01-19 09:20:49 +0100 | [diff] [blame] | 58 | defaultOnuVendorIds = "OPEN,ALCL,BRCM,TWSH,ALPH,ISKT,SFAA,BBSM,SCOM,ARPX,DACM,ERSN,HWTC,CIGG,ADTN,ARCA,AVMG" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 59 | |
| 60 | // For Tracing |
| 61 | defaultTraceEnabled = false |
| 62 | defaultTraceAgentAddress = "127.0.0.1:6831" |
| 63 | defaultLogCorrelationEnabled = true |
Girish Gowdra | af0ad63 | 2021-01-27 13:00:01 -0800 | [diff] [blame] | 64 | |
Himani Chawla | 075f164 | 2021-03-15 19:23:24 +0530 | [diff] [blame] | 65 | defaultMetricsEnabled = false |
| 66 | defaultMibAuditInterval = 0 |
| 67 | defaultAlarmAuditInterval = 300 * time.Second |
Girish Gowdra | 0b23584 | 2021-03-09 13:06:46 -0800 | [diff] [blame] | 68 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 69 | defaultOmciTimeout = 3 * time.Second |
| 70 | defaultDlToAdapterTimeout = 10 * time.Second |
| 71 | defaultDlToOnuTimeoutPer4MB = 60 * time.Minute //assumed for 4 MB of the image |
Matteo Scandolo | 20d180c | 2021-06-10 17:20:21 +0200 | [diff] [blame] | 72 | //Mask to indicate which possibly active ONU UNI state is really reported to the core |
| 73 | // compare python code - at the moment restrict active state to the first ONU UNI port |
| 74 | // check is limited to max 16 uni ports - cmp above UNI limit!!! |
| 75 | defaultUniPortMask = 0x0001 |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 76 | ) |
| 77 | |
| 78 | // AdapterFlags represents the set of configurations used by the read-write adaptercore service |
| 79 | type AdapterFlags struct { |
| 80 | // Command line parameters |
| 81 | InstanceID string |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 82 | KafkaAdapterAddress string |
| 83 | KafkaClusterAddress string // NOTE this is unused across the adapter |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 84 | KVStoreType string |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 85 | KVStoreTimeout time.Duration |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 86 | KVStoreAddress string |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 87 | Topic string |
| 88 | CoreTopic string |
| 89 | EventTopic string |
| 90 | LogLevel string |
| 91 | OnuNumber int |
| 92 | Banner bool |
| 93 | DisplayVersionOnly bool |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 94 | AccIncrEvto bool |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 95 | ProbeHost string |
| 96 | ProbePort int |
| 97 | LiveProbeInterval time.Duration |
| 98 | NotLiveProbeInterval time.Duration |
| 99 | HeartbeatCheckInterval time.Duration |
| 100 | HeartbeatFailReportInterval time.Duration |
| 101 | KafkaReconnectRetries int |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 102 | CurrentReplica int |
| 103 | TotalReplicas int |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 104 | MaxTimeoutInterAdapterComm time.Duration |
Holger Hildebrandt | 38985dc | 2021-02-18 16:25:20 +0000 | [diff] [blame] | 105 | MaxTimeoutReconciling time.Duration |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 106 | TraceEnabled bool |
| 107 | TraceAgentAddress string |
| 108 | LogCorrelationEnabled bool |
Andrea Campanella | 3d7c931 | 2021-01-19 09:20:49 +0100 | [diff] [blame] | 109 | OnuVendorIds string |
Girish Gowdra | af0ad63 | 2021-01-27 13:00:01 -0800 | [diff] [blame] | 110 | MetricsEnabled bool |
Holger Hildebrandt | e3677f1 | 2021-02-05 14:50:56 +0000 | [diff] [blame] | 111 | MibAuditInterval time.Duration |
Girish Gowdra | 0b23584 | 2021-03-09 13:06:46 -0800 | [diff] [blame] | 112 | OmciTimeout time.Duration |
Himani Chawla | 075f164 | 2021-03-15 19:23:24 +0530 | [diff] [blame] | 113 | AlarmAuditInterval time.Duration |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 114 | DownloadToAdapterTimeout time.Duration |
| 115 | DownloadToOnuTimeout4MB time.Duration |
Matteo Scandolo | 20d180c | 2021-06-10 17:20:21 +0200 | [diff] [blame] | 116 | UniPortMask int |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | // NewAdapterFlags returns a new RWCore config |
| 120 | func NewAdapterFlags() *AdapterFlags { |
| 121 | var adapterFlags = AdapterFlags{ // Default values |
| 122 | InstanceID: defaultInstanceid, |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 123 | KafkaAdapterAddress: defaultKafkaadapteraddress, |
| 124 | KafkaClusterAddress: defaultKafkaclusteraddress, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 125 | KVStoreType: defaultKvstoretype, |
| 126 | KVStoreTimeout: defaultKvstoretimeout, |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 127 | KVStoreAddress: defaultKvstoreaddress, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 128 | Topic: defaultTopic, |
Holger Hildebrandt | a768fe9 | 2020-10-01 13:06:21 +0000 | [diff] [blame] | 129 | CoreTopic: defaultCoreTopic, |
| 130 | EventTopic: defaultEventTopic, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 131 | LogLevel: defaultLoglevel, |
| 132 | OnuNumber: defaultOnunumber, |
| 133 | Banner: defaultBanner, |
| 134 | DisplayVersionOnly: defaultDisplayVersionOnly, |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 135 | AccIncrEvto: defaultAccIncrEvto, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 136 | ProbeHost: defaultProbeHost, |
| 137 | ProbePort: defaultProbePort, |
| 138 | LiveProbeInterval: defaultLiveProbeInterval, |
| 139 | NotLiveProbeInterval: defaultNotLiveProbeInterval, |
| 140 | HeartbeatCheckInterval: defaultHearbeatCheckInterval, |
| 141 | HeartbeatFailReportInterval: defaultHearbeatFailReportInterval, |
| 142 | KafkaReconnectRetries: defaultKafkaReconnectRetries, |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 143 | CurrentReplica: defaultCurrentReplica, |
| 144 | TotalReplicas: defaultTotalReplicas, |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 145 | MaxTimeoutInterAdapterComm: defaultMaxTimeoutInterAdapterComm, |
Holger Hildebrandt | 38985dc | 2021-02-18 16:25:20 +0000 | [diff] [blame] | 146 | MaxTimeoutReconciling: defaultMaxTimeoutReconciling, |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 147 | TraceEnabled: defaultTraceEnabled, |
| 148 | TraceAgentAddress: defaultTraceAgentAddress, |
| 149 | LogCorrelationEnabled: defaultLogCorrelationEnabled, |
Andrea Campanella | 3d7c931 | 2021-01-19 09:20:49 +0100 | [diff] [blame] | 150 | OnuVendorIds: defaultOnuVendorIds, |
Girish Gowdra | af0ad63 | 2021-01-27 13:00:01 -0800 | [diff] [blame] | 151 | MetricsEnabled: defaultMetricsEnabled, |
Holger Hildebrandt | e3677f1 | 2021-02-05 14:50:56 +0000 | [diff] [blame] | 152 | MibAuditInterval: defaultMibAuditInterval, |
Himani Chawla | 075f164 | 2021-03-15 19:23:24 +0530 | [diff] [blame] | 153 | AlarmAuditInterval: defaultAlarmAuditInterval, |
Girish Gowdra | 0b23584 | 2021-03-09 13:06:46 -0800 | [diff] [blame] | 154 | OmciTimeout: defaultOmciTimeout, |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 155 | DownloadToAdapterTimeout: defaultDlToAdapterTimeout, |
| 156 | DownloadToOnuTimeout4MB: defaultDlToOnuTimeoutPer4MB, |
Matteo Scandolo | 20d180c | 2021-06-10 17:20:21 +0200 | [diff] [blame] | 157 | UniPortMask: defaultUniPortMask, |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 158 | } |
| 159 | return &adapterFlags |
| 160 | } |
| 161 | |
| 162 | // ParseCommandArguments parses the arguments when running read-write adaptercore service |
| 163 | func (so *AdapterFlags) ParseCommandArguments() { |
| 164 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 165 | help := "Kafka - Adapter messaging address" |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 166 | flag.StringVar(&(so.KafkaAdapterAddress), "kafka_adapter_address", defaultKafkaadapteraddress, help) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 167 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 168 | help = "Kafka - Cluster messaging address" |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 169 | flag.StringVar(&(so.KafkaClusterAddress), "kafka_cluster_address", defaultKafkaclusteraddress, help) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 170 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 171 | help = "Open ONU topic" |
Andrea Campanella | 961734c | 2021-01-18 11:44:47 +0100 | [diff] [blame] | 172 | baseAdapterTopic := flag.String("adapter_topic", defaultTopic, help) |
Holger Hildebrandt | a768fe9 | 2020-10-01 13:06:21 +0000 | [diff] [blame] | 173 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 174 | help = "Core topic" |
Holger Hildebrandt | a768fe9 | 2020-10-01 13:06:21 +0000 | [diff] [blame] | 175 | flag.StringVar(&(so.CoreTopic), "core_topic", defaultCoreTopic, help) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 176 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 177 | help = "Event topic" |
Holger Hildebrandt | a768fe9 | 2020-10-01 13:06:21 +0000 | [diff] [blame] | 178 | flag.StringVar(&(so.EventTopic), "event_topic", defaultEventTopic, help) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 179 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 180 | help = "KV store type" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 181 | flag.StringVar(&(so.KVStoreType), "kv_store_type", defaultKvstoretype, help) |
| 182 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 183 | help = "The default timeout when making a kv store request" |
mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 184 | flag.DurationVar(&(so.KVStoreTimeout), "kv_store_request_timeout", defaultKvstoretimeout, help) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 185 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 186 | help = "KV store address" |
Matteo Scandolo | 127c59d | 2021-01-28 11:31:18 -0800 | [diff] [blame] | 187 | flag.StringVar(&(so.KVStoreAddress), "kv_store_address", defaultKvstoreaddress, help) |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 188 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 189 | help = "Log level" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 190 | flag.StringVar(&(so.LogLevel), "log_level", defaultLoglevel, help) |
| 191 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 192 | help = "Number of ONUs" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 193 | flag.IntVar(&(so.OnuNumber), "onu_number", defaultOnunumber, help) |
| 194 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 195 | help = "Show startup banner log lines" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 196 | flag.BoolVar(&(so.Banner), "banner", defaultBanner, help) |
| 197 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 198 | help = "Show version information and exit" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 199 | flag.BoolVar(&(so.DisplayVersionOnly), "version", defaultDisplayVersionOnly, help) |
| 200 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 201 | help = "Acceptance of incremental EVTOCD configuration" |
mpagenko | dff5dda | 2020-08-28 11:52:01 +0000 | [diff] [blame] | 202 | flag.BoolVar(&(so.AccIncrEvto), "accept_incr_evto", defaultAccIncrEvto, help) |
| 203 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 204 | help = "The address on which to listen to answer liveness and readiness probe queries over HTTP" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 205 | flag.StringVar(&(so.ProbeHost), "probe_host", defaultProbeHost, help) |
| 206 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 207 | help = "The port on which to listen to answer liveness and readiness probe queries over HTTP" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 208 | flag.IntVar(&(so.ProbePort), "probe_port", defaultProbePort, help) |
| 209 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 210 | help = "Number of seconds for the default liveliness check" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 211 | flag.DurationVar(&(so.LiveProbeInterval), "live_probe_interval", defaultLiveProbeInterval, help) |
| 212 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 213 | help = "Number of seconds for liveliness check if probe is not running" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 214 | flag.DurationVar(&(so.NotLiveProbeInterval), "not_live_probe_interval", defaultNotLiveProbeInterval, help) |
| 215 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 216 | help = "Number of seconds for heartbeat check interval" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 217 | flag.DurationVar(&(so.HeartbeatCheckInterval), "hearbeat_check_interval", defaultHearbeatCheckInterval, help) |
| 218 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 219 | help = "Number of seconds adapter has to wait before reporting core on the hearbeat check failure" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 220 | flag.DurationVar(&(so.HeartbeatFailReportInterval), "hearbeat_fail_interval", defaultHearbeatFailReportInterval, help) |
| 221 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 222 | help = "Number of retries to connect to Kafka" |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 223 | flag.IntVar(&(so.KafkaReconnectRetries), "kafka_reconnect_retries", defaultKafkaReconnectRetries, help) |
| 224 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 225 | help = "Replica number of this particular instance" |
Holger Hildebrandt | 0f9b88d | 2020-04-20 13:33:25 +0000 | [diff] [blame] | 226 | flag.IntVar(&(so.CurrentReplica), "current_replica", defaultCurrentReplica, help) |
| 227 | |
| 228 | help = "Total number of instances for this adapter" |
| 229 | flag.IntVar(&(so.TotalReplicas), "total_replica", defaultTotalReplicas, help) |
| 230 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 231 | help = "Maximum Number of seconds for the default interadapter communication timeout" |
Himani Chawla | d96df18 | 2020-09-28 11:12:02 +0530 | [diff] [blame] | 232 | flag.DurationVar(&(so.MaxTimeoutInterAdapterComm), "max_timeout_interadapter_comm", |
| 233 | defaultMaxTimeoutInterAdapterComm, help) |
| 234 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 235 | help = "Maximum Number of seconds for the default ONU reconciling timeout" |
Holger Hildebrandt | 38985dc | 2021-02-18 16:25:20 +0000 | [diff] [blame] | 236 | flag.DurationVar(&(so.MaxTimeoutReconciling), "max_timeout_reconciling", |
| 237 | defaultMaxTimeoutReconciling, help) |
| 238 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 239 | help = "Whether to send logs to tracing agent" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 240 | flag.BoolVar(&(so.TraceEnabled), "trace_enabled", defaultTraceEnabled, help) |
| 241 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 242 | help = "The address of tracing agent to which span info should be sent" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 243 | flag.StringVar(&(so.TraceAgentAddress), "trace_agent_address", defaultTraceAgentAddress, help) |
| 244 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 245 | help = "Whether to enrich log statements with fields denoting operation being executed for achieving correlation" |
dbainbri | 4d3a0dc | 2020-12-02 00:33:42 +0000 | [diff] [blame] | 246 | flag.BoolVar(&(so.LogCorrelationEnabled), "log_correlation_enabled", defaultLogCorrelationEnabled, help) |
| 247 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 248 | help = "List of Allowed ONU Vendor Ids" |
Andrea Campanella | 3d7c931 | 2021-01-19 09:20:49 +0100 | [diff] [blame] | 249 | flag.StringVar(&(so.OnuVendorIds), "allowed_onu_vendors", defaultOnuVendorIds, help) |
| 250 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 251 | help = "Whether to enable metrics collection" |
Girish Gowdra | af0ad63 | 2021-01-27 13:00:01 -0800 | [diff] [blame] | 252 | flag.BoolVar(&(so.MetricsEnabled), "metrics_enabled", defaultMetricsEnabled, help) |
| 253 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 254 | help = "Mib Audit Interval in seconds - the value zero will disable Mib Audit" |
Holger Hildebrandt | e3677f1 | 2021-02-05 14:50:56 +0000 | [diff] [blame] | 255 | flag.DurationVar(&(so.MibAuditInterval), "mib_audit_interval", defaultMibAuditInterval, help) |
| 256 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 257 | help = "OMCI timeout duration - this timeout value is used on the OMCI channel for waiting on response from ONU" |
Girish Gowdra | 0b23584 | 2021-03-09 13:06:46 -0800 | [diff] [blame] | 258 | flag.DurationVar(&(so.OmciTimeout), "omci_timeout", defaultOmciTimeout, help) |
| 259 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 260 | help = "Alarm Audit Interval in seconds - the value zero will disable alarm audit" |
Himani Chawla | 075f164 | 2021-03-15 19:23:24 +0530 | [diff] [blame] | 261 | flag.DurationVar(&(so.AlarmAuditInterval), "alarm_audit_interval", defaultAlarmAuditInterval, help) |
| 262 | |
mpagenko | c26d4c0 | 2021-05-06 14:27:57 +0000 | [diff] [blame] | 263 | help = "File download to adapter timeout in seconds" |
| 264 | flag.DurationVar(&(so.DownloadToAdapterTimeout), "download_to_adapter_timeout", defaultDlToAdapterTimeout, help) |
| 265 | |
| 266 | help = "File download to ONU timeout in minutes for a block of 4MB" |
| 267 | flag.DurationVar(&(so.DownloadToOnuTimeout4MB), "download_to_onu_timeout_4MB", defaultDlToOnuTimeoutPer4MB, help) |
| 268 | |
Matteo Scandolo | 20d180c | 2021-06-10 17:20:21 +0200 | [diff] [blame] | 269 | help = "The bitmask to identify UNI ports that need to be enabled" |
| 270 | flag.IntVar(&(so.UniPortMask), "uni_port_mask", defaultUniPortMask, help) |
| 271 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 272 | flag.Parse() |
| 273 | containerName := getContainerInfo() |
| 274 | if len(containerName) > 0 { |
| 275 | so.InstanceID = containerName |
| 276 | } |
| 277 | |
Andrea Campanella | 961734c | 2021-01-18 11:44:47 +0100 | [diff] [blame] | 278 | so.Topic = fmt.Sprintf("%s_%d", *baseAdapterTopic, int32(so.CurrentReplica)) |
| 279 | |
Holger Hildebrandt | fa07499 | 2020-03-27 15:42:06 +0000 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | func getContainerInfo() string { |
| 283 | return os.Getenv("HOSTNAME") |
| 284 | } |