[VOL-2736]:host and port should be specified as a single argument not as two separate arguments
Change-Id: I14b59b4e42b1cf0821807cdb3dd6eef2094077da
diff --git a/VERSION b/VERSION
index b915d25..f041bc6 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.4.8-dev
+2.4.8
diff --git a/cmd/openolt-adapter/main.go b/cmd/openolt-adapter/main.go
index 45cbf53..7650ad3 100644
--- a/cmd/openolt-adapter/main.go
+++ b/cmd/openolt-adapter/main.go
@@ -23,7 +23,6 @@
"fmt"
"os"
"os/signal"
- "strconv"
"syscall"
"time"
@@ -97,11 +96,11 @@
}
// Setup Log Config
- cm := conf.NewConfigManager(a.kvClient, a.config.KVStoreType, a.config.KVStoreHost, a.config.KVStorePort, a.config.KVStoreTimeout)
+ cm := conf.NewConfigManager(a.kvClient, a.config.KVStoreType, a.config.KVStoreAddress, a.config.KVStoreTimeout)
go conf.StartLogLevelConfigProcessing(cm, ctx)
// Setup Kafka Client
- if a.kafkaClient, err = newKafkaClient("sarama", a.config.KafkaAdapterHost, a.config.KafkaAdapterPort); err != nil {
+ if a.kafkaClient, err = newKafkaClient("sarama", a.config.KafkaAdapterAddress); err != nil {
logger.Fatalw("Unsupported-common-client", log.Fields{"error": err})
}
@@ -287,14 +286,13 @@
return nil, errors.New("unsupported-kv-store")
}
-func newKafkaClient(clientType, host string, port int) (kafka.Client, error) {
+func newKafkaClient(clientType, address string) (kafka.Client, error) {
logger.Infow("common-client-type", log.Fields{"client": clientType})
switch clientType {
case "sarama":
return kafka.NewSaramaClient(
- kafka.Host(host),
- kafka.Port(port),
+ kafka.Address(address),
kafka.ProducerReturnOnErrors(true),
kafka.ProducerReturnOnSuccess(true),
kafka.ProducerMaxRetries(6),
@@ -306,8 +304,7 @@
}
func (a *adapter) setKVClient() error {
- addr := a.config.KVStoreHost + ":" + strconv.Itoa(a.config.KVStorePort)
- client, err := newKVClient(a.config.KVStoreType, addr, a.config.KVStoreTimeout)
+ client, err := newKVClient(a.config.KVStoreType, a.config.KVStoreAddress, a.config.KVStoreTimeout)
if err != nil {
a.kvClient = nil
return err
@@ -318,12 +315,11 @@
}
func (a *adapter) startInterContainerProxy(ctx context.Context, retries int) (kafka.InterContainerProxy, error) {
- logger.Infow("starting-intercontainer-messaging-proxy", log.Fields{"host": a.config.KafkaAdapterHost,
- "port": a.config.KafkaAdapterPort, "topic": a.config.Topic})
+ logger.Infow("starting-intercontainer-messaging-proxy", log.Fields{"address": a.config.KafkaAdapterAddress,
+ "topic": a.config.Topic})
var err error
kip := kafka.NewInterContainerProxy(
- kafka.InterContainerHost(a.config.KafkaAdapterHost),
- kafka.InterContainerPort(a.config.KafkaAdapterPort),
+ kafka.InterContainerAddress(a.config.KafkaAdapterAddress),
kafka.MsgClient(a.kafkaClient),
kafka.DefaultTopic(&kafka.Topic{Name: a.config.Topic}))
count := 0
@@ -509,7 +505,7 @@
ad := newAdapter(cf)
p := &probe.Probe{}
- go p.ListenAndServe(fmt.Sprintf("%s:%d", ad.config.ProbeHost, ad.config.ProbePort))
+ go p.ListenAndServe(ad.config.ProbeAddress)
probeCtx := context.WithValue(ctx, probe.ProbeContextKey, p)
diff --git a/cmd/openolt-adapter/main_test.go b/cmd/openolt-adapter/main_test.go
index 5246348..bd5c81a 100644
--- a/cmd/openolt-adapter/main_test.go
+++ b/cmd/openolt-adapter/main_test.go
@@ -124,8 +124,7 @@
adapter := newMockAdapter()
type args struct {
clientType string
- host string
- port int
+ address string
}
tests := []struct {
name string
@@ -133,12 +132,12 @@
wantErr bool
}{
// TODO: Add test cases.
- {"newKafkaClient", args{clientType: "sarama", host: adapter.config.KafkaAdapterHost, port: adapter.config.KafkaAdapterPort}, false},
- {"newKafkaClient", args{clientType: "sarama", host: adapter.config.KafkaAdapterHost, port: adapter.config.KafkaAdapterPort}, false},
+ {"newKafkaClient", args{clientType: "sarama", address: adapter.config.KafkaAdapterAddress}, false},
+ {"newKafkaClient", args{clientType: "sarama", address: adapter.config.KafkaAdapterAddress}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- _, err := newKafkaClient(tt.args.clientType, tt.args.host, tt.args.port)
+ _, err := newKafkaClient(tt.args.clientType, tt.args.address)
if (err != nil) != tt.wantErr {
t.Errorf("newKafkaClient() error = %v, wantErr %v", err, tt.wantErr)
return
@@ -153,8 +152,7 @@
ad := newMockAdapter()
kip := kafka.NewInterContainerProxy(
- kafka.InterContainerHost(ad.config.KafkaAdapterHost),
- kafka.InterContainerPort(ad.config.KafkaAdapterPort),
+ kafka.InterContainerAddress(ad.config.KafkaAdapterAddress),
kafka.MsgClient(&mockKafkaClient{}),
kafka.DefaultTopic(&kafka.Topic{Name: ad.config.Topic}))
diff --git a/go.mod b/go.mod
index b82dc66..675fe88 100755
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@
github.com/cenkalti/backoff/v3 v3.1.1
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
- github.com/opencord/voltha-lib-go/v3 v3.1.12
+ github.com/opencord/voltha-lib-go/v3 v3.1.13
github.com/opencord/voltha-protos/v3 v3.3.6
go.etcd.io/etcd v0.0.0-20190930204107-236ac2a90522
google.golang.org/grpc v1.25.1
diff --git a/go.sum b/go.sum
index f2bd702..4bfcffa 100644
--- a/go.sum
+++ b/go.sum
@@ -202,8 +202,8 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v3 v3.1.12 h1:ey3mpwB0mOuoK0cnonF6O0cNJlb75ZudqGpGz/50l4k=
-github.com/opencord/voltha-lib-go/v3 v3.1.12/go.mod h1:26TG6ABl+ppP754YWhhgao9wKNL3SuUf/KztQcJFqrQ=
+github.com/opencord/voltha-lib-go/v3 v3.1.13 h1:kgf2aMkiUR5IbJpQ/E7pMNcwR2KxhLchP26CSyY+rbY=
+github.com/opencord/voltha-lib-go/v3 v3.1.13/go.mod h1:26TG6ABl+ppP754YWhhgao9wKNL3SuUf/KztQcJFqrQ=
github.com/opencord/voltha-protos/v3 v3.3.3 h1:OO0H+YMxjLFQifoYXwBp1JN5rpEVMQnhGGEdP6pLrY0=
github.com/opencord/voltha-protos/v3 v3.3.3/go.mod h1:nl1ETp5Iw3avxOaKD8BJlYY5wYI4KeV95aT1pL63nto=
github.com/opencord/voltha-protos/v3 v3.3.6 h1:en9k9R2RmPIB8mW/sK2iK11JTw78gJpVf4/wM2cV+Ow=
diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go
index b44d372..3a8d157 100644
--- a/internal/pkg/config/config.go
+++ b/internal/pkg/config/config.go
@@ -28,14 +28,11 @@
const (
EtcdStoreName = "etcd"
defaultInstanceid = "openOlt001"
- defaultKafkaadapterhost = "127.0.0.1"
- defaultKafkaadapterport = 9092
- defaultKafkaclusterhost = "127.0.0.1"
- defaultKafkaclusterport = 9094
+ defaultKafkaadapteraddress = "127.0.0.1:9092"
+ defaultKafkaclusteraddress = "127.0.0.1:9094"
defaultKvstoretype = EtcdStoreName
- defaultKvstoretimeout = 5 * time.Second //in seconds
- defaultKvstorehost = "127.0.0.1"
- defaultKvstoreport = 2379 // Consul = 8500; Etcd = 2379
+ defaultKvstoretimeout = 5 * time.Second
+ defaultKvstoreaddress = "127.0.0.1:2379" // Port: Consul = 8500; Etcd = 2379
defaultLoglevel = "WARN"
defaultBanner = false
defaultDisplayVersionOnly = false
@@ -43,8 +40,7 @@
defaultCoretopic = "rwcore"
defaultEventtopic = "voltha.events"
defaultOnunumber = 1
- defaultProbeHost = ""
- defaultProbePort = 8080
+ defaultProbeAddress = ":8080"
defaultLiveProbeInterval = 60 * time.Second
defaultNotLiveProbeInterval = 5 * time.Second // Probe more frequently when not alive
//defaultHearbeatFailReportInterval is the time in seconds the adapter will keep checking the hardware for heartbeat.
@@ -61,14 +57,11 @@
type AdapterFlags struct {
// Command line parameters
InstanceID string
- KafkaAdapterHost string
- KafkaAdapterPort int
- KafkaClusterHost string
- KafkaClusterPort int
+ KafkaAdapterAddress string
+ KafkaClusterAddress string
KVStoreType string
- KVStoreTimeout time.Duration // in seconds
- KVStoreHost string
- KVStorePort int
+ KVStoreTimeout time.Duration
+ KVStoreAddress string
Topic string
CoreTopic string
EventTopic string
@@ -76,8 +69,7 @@
OnuNumber int
Banner bool
DisplayVersionOnly bool
- ProbeHost string
- ProbePort int
+ ProbeAddress string
LiveProbeInterval time.Duration
NotLiveProbeInterval time.Duration
HeartbeatCheckInterval time.Duration
@@ -91,14 +83,11 @@
func NewAdapterFlags() *AdapterFlags {
var adapterFlags = AdapterFlags{ // Default values
InstanceID: defaultInstanceid,
- KafkaAdapterHost: defaultKafkaadapterhost,
- KafkaAdapterPort: defaultKafkaadapterport,
- KafkaClusterHost: defaultKafkaclusterhost,
- KafkaClusterPort: defaultKafkaclusterport,
+ KafkaAdapterAddress: defaultKafkaadapteraddress,
+ KafkaClusterAddress: defaultKafkaclusteraddress,
KVStoreType: defaultKvstoretype,
KVStoreTimeout: defaultKvstoretimeout,
- KVStoreHost: defaultKvstorehost,
- KVStorePort: defaultKvstoreport,
+ KVStoreAddress: defaultKvstoreaddress,
Topic: defaultTopic,
CoreTopic: defaultCoretopic,
EventTopic: defaultEventtopic,
@@ -106,8 +95,7 @@
OnuNumber: defaultOnunumber,
Banner: defaultBanner,
DisplayVersionOnly: defaultDisplayVersionOnly,
- ProbeHost: defaultProbeHost,
- ProbePort: defaultProbePort,
+ ProbeAddress: defaultProbeAddress,
LiveProbeInterval: defaultLiveProbeInterval,
NotLiveProbeInterval: defaultNotLiveProbeInterval,
HeartbeatCheckInterval: defaultHearbeatCheckInterval,
@@ -120,17 +108,11 @@
// ParseCommandArguments parses the arguments when running read-write adaptercore service
func (so *AdapterFlags) ParseCommandArguments() {
- help := fmt.Sprintf("Kafka - Adapter messaging host")
- flag.StringVar(&(so.KafkaAdapterHost), "kafka_adapter_host", defaultKafkaadapterhost, help)
+ help := fmt.Sprintf("Kafka - Adapter messaging address")
+ flag.StringVar(&(so.KafkaAdapterAddress), "kafka_adapter_address", defaultKafkaadapteraddress, help)
- help = fmt.Sprintf("Kafka - Adapter messaging port")
- flag.IntVar(&(so.KafkaAdapterPort), "kafka_adapter_port", defaultKafkaadapterport, help)
-
- help = fmt.Sprintf("Kafka - Cluster messaging host")
- flag.StringVar(&(so.KafkaClusterHost), "kafka_cluster_host", defaultKafkaclusterhost, help)
-
- help = fmt.Sprintf("Kafka - Cluster messaging port")
- flag.IntVar(&(so.KafkaClusterPort), "kafka_cluster_port", defaultKafkaclusterport, help)
+ help = fmt.Sprintf("Kafka - Cluster messaging address")
+ flag.StringVar(&(so.KafkaClusterAddress), "kafka_cluster_address", defaultKafkaclusteraddress, help)
help = fmt.Sprintf("Open OLT topic")
flag.StringVar(&(so.Topic), "adapter_topic", defaultTopic, help)
@@ -147,11 +129,8 @@
help = fmt.Sprintf("The default timeout when making a kv store request")
flag.DurationVar(&(so.KVStoreTimeout), "kv_store_request_timeout", defaultKvstoretimeout, help)
- help = fmt.Sprintf("KV store host")
- flag.StringVar(&(so.KVStoreHost), "kv_store_host", defaultKvstorehost, help)
-
- help = fmt.Sprintf("KV store port")
- flag.IntVar(&(so.KVStorePort), "kv_store_port", defaultKvstoreport, help)
+ help = fmt.Sprintf("KV store address")
+ flag.StringVar(&(so.KVStoreAddress), "kv_store_address", defaultKvstoreaddress, help)
help = fmt.Sprintf("Log level")
flag.StringVar(&(so.LogLevel), "log_level", defaultLoglevel, help)
@@ -166,10 +145,7 @@
flag.BoolVar(&(so.DisplayVersionOnly), "version", defaultDisplayVersionOnly, help)
help = fmt.Sprintf("The address on which to listen to answer liveness and readiness probe queries over HTTP.")
- flag.StringVar(&(so.ProbeHost), "probe_host", defaultProbeHost, help)
-
- help = fmt.Sprintf("The port on which to listen to answer liveness and readiness probe queries over HTTP.")
- flag.IntVar(&(so.ProbePort), "probe_port", defaultProbePort, help)
+ flag.StringVar(&(so.ProbeAddress), "probe_address", defaultProbeAddress, help)
help = fmt.Sprintf("Number of seconds for the default liveliness check")
flag.DurationVar(&(so.LiveProbeInterval), "live_probe_interval", defaultLiveProbeInterval, help)
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index 212e096..39775a0 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -712,9 +712,8 @@
if err != nil {
return olterrors.NewErrAdapter("populate-device-info-failed", log.Fields{"device-id": dh.device.Id}, err)
}
- KVStoreHostPort := fmt.Sprintf("%s:%d", dh.openOLT.KVStoreHost, dh.openOLT.KVStorePort)
// Instantiate resource manager
- if dh.resourceMgr = rsrcMgr.NewResourceMgr(ctx, dh.device.Id, KVStoreHostPort, dh.openOLT.KVStoreType, dh.device.Type, deviceInfo); dh.resourceMgr == nil {
+ if dh.resourceMgr = rsrcMgr.NewResourceMgr(ctx, dh.device.Id, dh.openOLT.KVStoreAddress, dh.openOLT.KVStoreType, dh.device.Type, deviceInfo); dh.resourceMgr == nil {
return olterrors.ErrResourceManagerInstantiating
}
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index 354382a..36a609e 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -41,8 +41,7 @@
kafkaICProxy kafka.InterContainerProxy
config *config.AdapterFlags
numOnus int
- KVStoreHost string
- KVStorePort int
+ KVStoreAddress string
KVStoreType string
exitChannel chan int
HeartbeatCheckInterval time.Duration
@@ -64,8 +63,7 @@
openOLT.coreProxy = coreProxy
openOLT.adapterProxy = adapterProxy
openOLT.eventProxy = eventProxy
- openOLT.KVStoreHost = cfg.KVStoreHost
- openOLT.KVStorePort = cfg.KVStorePort
+ openOLT.KVStoreAddress = cfg.KVStoreAddress
openOLT.KVStoreType = cfg.KVStoreType
openOLT.HeartbeatCheckInterval = cfg.HeartbeatCheckInterval
openOLT.HeartbeatFailReportInterval = cfg.HeartbeatFailReportInterval
diff --git a/internal/pkg/core/openolt_test.go b/internal/pkg/core/openolt_test.go
index 9c9094f..704c0b5 100644
--- a/internal/pkg/core/openolt_test.go
+++ b/internal/pkg/core/openolt_test.go
@@ -48,8 +48,7 @@
eventProxy *com.EventProxy
kafkaICProxy kafka.InterContainerProxy
numOnus int
- KVStoreHost string
- KVStorePort int
+ KVStoreAddress string
KVStoreType string
exitChannel chan int
lockDeviceHandlersMap sync.RWMutex
@@ -74,8 +73,7 @@
eventProxy: testOlt.eventProxy,
kafkaICProxy: testOlt.kafkaICProxy,
numOnus: testOlt.numOnus,
- KVStoreHost: testOlt.KVStoreHost,
- KVStorePort: testOlt.KVStorePort,
+ KVStoreAddress: testOlt.KVStoreAddress,
KVStoreType: testOlt.KVStoreType,
exitChannel: testOlt.exitChannel,
}
@@ -109,12 +107,12 @@
configFlags *config.AdapterFlags
want *OpenOLT
}{
- {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStorePort: 1, KVStoreType: "consul", KVStoreHost: "1.1.1.1"},
- &OpenOLT{numOnus: 1, KVStorePort: 1, KVStoreType: "consul", KVStoreHost: "1.1.1.1"}},
- {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStorePort: 2, KVStoreType: "etcd", KVStoreHost: "2.2.2.2"},
- &OpenOLT{numOnus: 2, KVStorePort: 2, KVStoreType: "etcd", KVStoreHost: "2.2.2.2"}},
- {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStorePort: 3, KVStoreType: "consul", KVStoreHost: "3.3.3.3"},
- &OpenOLT{numOnus: 3, KVStorePort: 3, KVStoreType: "consul", KVStoreHost: "3.3.3.3"}},
+ {"newopenolt-1", &fields{}, &config.AdapterFlags{OnuNumber: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"},
+ &OpenOLT{numOnus: 1, KVStoreAddress: "1.1.1.1:1", KVStoreType: "consul"}},
+ {"newopenolt-2", &fields{}, &config.AdapterFlags{OnuNumber: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"},
+ &OpenOLT{numOnus: 2, KVStoreAddress: "2.2.2.2:2", KVStoreType: "etcd"}},
+ {"newopenolt-3", &fields{}, &config.AdapterFlags{OnuNumber: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"},
+ &OpenOLT{numOnus: 3, KVStoreAddress: "3.3.3.3:3", KVStoreType: "consul"}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
diff --git a/internal/pkg/resourcemanager/resourcemanager.go b/internal/pkg/resourcemanager/resourcemanager.go
index 8f6271d..8ab03f0 100755
--- a/internal/pkg/resourcemanager/resourcemanager.go
+++ b/internal/pkg/resourcemanager/resourcemanager.go
@@ -24,7 +24,6 @@
"fmt"
"github.com/opencord/voltha-openolt-adapter/internal/pkg/olterrors"
"strconv"
- "strings"
"sync"
"time"
@@ -100,14 +99,12 @@
// OpenOltResourceMgr holds resource related information as provided below for each field
type OpenOltResourceMgr struct {
- DeviceID string // OLT device id
- HostAndPort string // Host and port of the kv store to connect to
- Args string // args
- KVStore *db.Backend // backend kv store connection handle
- DeviceType string
- Host string // Host ip of the kv store
- Port int // port of the kv store
- DevInfo *openolt.DeviceInfo // device information
+ DeviceID string // OLT device id
+ Address string // Host and port of the kv store to connect to
+ Args string // args
+ KVStore *db.Backend // backend kv store connection handle
+ DeviceType string
+ DevInfo *openolt.DeviceInfo // device information
// array of pon resource managers per interface technology
ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
@@ -137,8 +134,7 @@
}
// SetKVClient sets the KV client and return a kv backend
-func SetKVClient(backend string, Host string, Port int, DeviceID string) *db.Backend {
- addr := Host + ":" + strconv.Itoa(Port)
+func SetKVClient(backend string, addr string, DeviceID string) *db.Backend {
// TODO : Make sure direct call to NewBackend is working fine with backend , currently there is some
// issue between kv store and backend , core is not calling NewBackend directly
kvClient, err := newKVClient(backend, addr, KvstoreTimeout)
@@ -150,8 +146,7 @@
kvbackend := &db.Backend{
Client: kvClient,
StoreType: backend,
- Host: Host,
- Port: Port,
+ Address: addr,
Timeout: KvstoreTimeout,
PathPrefix: fmt.Sprintf(BasePathKvStore, DeviceID)}
@@ -161,20 +156,16 @@
// NewResourceMgr init a New resource manager instance which in turn instantiates pon resource manager
// instances according to technology. Initializes the default resource ranges for all
// the resources.
-func NewResourceMgr(ctx context.Context, deviceID string, KVStoreHostPort string, kvStoreType string, deviceType string, devInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
+func NewResourceMgr(ctx context.Context, deviceID string, KVStoreAddress string, kvStoreType string, deviceType string, devInfo *openolt.DeviceInfo) *OpenOltResourceMgr {
var ResourceMgr OpenOltResourceMgr
- logger.Debugf("Init new resource manager , host_port: %s, deviceid: %s", KVStoreHostPort, deviceID)
- ResourceMgr.HostAndPort = KVStoreHostPort
+ logger.Debugf("Init new resource manager , address: %s, deviceid: %s", KVStoreAddress, deviceID)
+ ResourceMgr.Address = KVStoreAddress
ResourceMgr.DeviceType = deviceType
ResourceMgr.DevInfo = devInfo
- IPPort := strings.Split(KVStoreHostPort, ":")
- ResourceMgr.Host = IPPort[0]
- ResourceMgr.Port, _ = strconv.Atoi(IPPort[1])
NumPONPorts := devInfo.GetPonPorts()
Backend := kvStoreType
- ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Host,
- ResourceMgr.Port, deviceID)
+ ResourceMgr.KVStore = SetKVClient(Backend, ResourceMgr.Address, deviceID)
if ResourceMgr.KVStore == nil {
logger.Error("Failed to setup KV store")
}
@@ -242,7 +233,7 @@
logger.Debugf("Device info technology %s", technology)
Ranges[technology] = TechRange
RsrcMgrsByTech[technology], err = ponrmgr.NewPONResourceManager(technology, deviceType, deviceID,
- Backend, ResourceMgr.Host, ResourceMgr.Port)
+ Backend, ResourceMgr.Address)
if err != nil {
logger.Errorf("Failed to create pon resource manager instance for technology %s", technology)
return nil
diff --git a/internal/pkg/resourcemanager/resourcemanager_test.go b/internal/pkg/resourcemanager/resourcemanager_test.go
index 2dd75ef..5b2ee29 100644
--- a/internal/pkg/resourcemanager/resourcemanager_test.go
+++ b/internal/pkg/resourcemanager/resourcemanager_test.go
@@ -70,12 +70,10 @@
// fields mocks OpenOltResourceMgr struct.
type fields struct {
DeviceID string
- HostAndPort string
+ Address string
Args string
KVStore *db.Backend
DeviceType string
- Host string
- Port int
DevInfo *openolt.DeviceInfo
ResourceMgrs map[uint32]*ponrmgr.PONResourceManager
NumOfPonPorts uint32
@@ -253,12 +251,10 @@
func testResMgrObject(testResMgr *fields) *OpenOltResourceMgr {
var rsrMgr = OpenOltResourceMgr{
DeviceID: testResMgr.DeviceID,
- HostAndPort: testResMgr.HostAndPort,
Args: testResMgr.Args,
KVStore: testResMgr.KVStore,
DeviceType: testResMgr.DeviceType,
- Host: testResMgr.Host,
- Port: testResMgr.Port,
+ Address: testResMgr.Address,
DevInfo: testResMgr.DevInfo,
ResourceMgrs: testResMgr.ResourceMgrs,
}
@@ -272,11 +268,11 @@
func TestNewResourceMgr(t *testing.T) {
type args struct {
- deviceID string
- KVStoreHostPort string
- kvStoreType string
- deviceType string
- devInfo *openolt.DeviceInfo
+ deviceID string
+ KVStoreAddress string
+ kvStoreType string
+ deviceType string
+ devInfo *openolt.DeviceInfo
}
tests := []struct {
name string
@@ -292,7 +288,7 @@
t.Run(tt.name, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- if got := NewResourceMgr(ctx, tt.args.deviceID, tt.args.KVStoreHostPort, tt.args.kvStoreType, tt.args.deviceType, tt.args.devInfo); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+ if got := NewResourceMgr(ctx, tt.args.deviceID, tt.args.KVStoreAddress, tt.args.kvStoreType, tt.args.deviceType, tt.args.devInfo); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
t.Errorf("NewResourceMgr() = %v, want %v", got, tt.want)
}
})
@@ -942,8 +938,7 @@
func TestSetKVClient(t *testing.T) {
type args struct {
backend string
- Host string
- Port int
+ address string
DeviceID string
}
tests := []struct {
@@ -951,12 +946,12 @@
args args
want *db.Backend
}{
- {"setKVClient-1", args{"consul", "1.1.1.1", 1, "olt1"}, &db.Backend{}},
- {"setKVClient-1", args{"etcd", "2.2.2.2", 2, "olt2"}, &db.Backend{}},
+ {"setKVClient-1", args{"consul", "1.1.1.1:1", "olt1"}, &db.Backend{}},
+ {"setKVClient-1", args{"etcd", "2.2.2.2:2", "olt2"}, &db.Backend{}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- if got := SetKVClient(tt.args.backend, tt.args.Host, tt.args.Port, tt.args.DeviceID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
+ if got := SetKVClient(tt.args.backend, tt.args.address, tt.args.DeviceID); reflect.TypeOf(got) != reflect.TypeOf(tt.want) {
t.Errorf("SetKVClient() = %v, want %v", got, tt.want)
}
})
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go
index ef71b07..24988be 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/config/configmanager.go
@@ -96,7 +96,7 @@
kvStoreEventChan chan *kvstore.Event
}
-func NewConfigManager(kvClient kvstore.Client, kvStoreType, kvStoreHost string, kvStorePort int, kvStoreTimeout time.Duration) *ConfigManager {
+func NewConfigManager(kvClient kvstore.Client, kvStoreType, kvStoreAddress string, kvStoreTimeout time.Duration) *ConfigManager {
var kvStorePrefix string
if prefix, present := os.LookupEnv("KV_STORE_DATAPATH_PREFIX"); present {
kvStorePrefix = prefix
@@ -111,8 +111,7 @@
Backend: &db.Backend{
Client: kvClient,
StoreType: kvStoreType,
- Host: kvStoreHost,
- Port: kvStorePort,
+ Address: kvStoreAddress,
Timeout: kvStoreTimeout,
PathPrefix: kvStorePrefix,
},
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go
index 20bacad..1e23a0f 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/db/backend.go
@@ -20,7 +20,6 @@
"context"
"errors"
"fmt"
- "strconv"
"time"
"github.com/opencord/voltha-lib-go/v3/pkg/db/kvstore"
@@ -38,9 +37,8 @@
type Backend struct {
Client kvstore.Client
StoreType string
- Host string
- Port int
Timeout time.Duration
+ Address string
PathPrefix string
alive bool // Is this backend connection alive?
liveness chan bool // channel to post alive state
@@ -49,24 +47,22 @@
}
// NewBackend creates a new instance of a Backend structure
-func NewBackend(storeType string, host string, port int, timeout time.Duration, pathPrefix string) *Backend {
+func NewBackend(storeType string, address string, timeout time.Duration, pathPrefix string) *Backend {
var err error
b := &Backend{
StoreType: storeType,
- Host: host,
- Port: port,
+ Address: address,
Timeout: timeout,
LivenessChannelInterval: DefaultLivenessChannelInterval,
PathPrefix: pathPrefix,
alive: false, // connection considered down at start
}
- address := host + ":" + strconv.Itoa(port)
if b.Client, err = b.newClient(address, timeout); err != nil {
logger.Errorw("failed-to-create-kv-client",
log.Fields{
- "type": storeType, "host": host, "port": port,
+ "type": storeType, "address": address,
"timeout": timeout, "prefix": pathPrefix,
"error": err.Error(),
})
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/client.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/client.go
index 0919a0c..0d9e3a5 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/client.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/client.go
@@ -39,6 +39,7 @@
const (
DefaultKafkaHost = "127.0.0.1"
DefaultKafkaPort = 9092
+ DefaultKafkaAddress = DefaultKafkaHost + ":" + string(DefaultKafkaPort)
DefaultGroupName = "voltha"
DefaultSleepOnError = 1
DefaultProducerFlushFrequency = 10
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
index beda537..9f9fbfc 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/kafka_inter_container_library.go
@@ -79,8 +79,7 @@
// interContainerProxy represents the messaging proxy
type interContainerProxy struct {
- kafkaHost string
- kafkaPort int
+ kafkaAddress string
defaultTopic *Topic
defaultRequestHandlerInterface interface{}
deviceDiscoveryTopic *Topic
@@ -107,15 +106,9 @@
type InterContainerProxyOption func(*interContainerProxy)
-func InterContainerHost(host string) InterContainerProxyOption {
+func InterContainerAddress(address string) InterContainerProxyOption {
return func(args *interContainerProxy) {
- args.kafkaHost = host
- }
-}
-
-func InterContainerPort(port int) InterContainerProxyOption {
- return func(args *interContainerProxy) {
- args.kafkaPort = port
+ args.kafkaAddress = address
}
}
@@ -145,9 +138,8 @@
func newInterContainerProxy(opts ...InterContainerProxyOption) *interContainerProxy {
proxy := &interContainerProxy{
- kafkaHost: DefaultKafkaHost,
- kafkaPort: DefaultKafkaPort,
- doneCh: make(chan struct{}),
+ kafkaAddress: DefaultKafkaAddress,
+ doneCh: make(chan struct{}),
}
for _, option := range opts {
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/sarama_client.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/sarama_client.go
index 468e546..581cf49 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/sarama_client.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/kafka/sarama_client.go
@@ -47,8 +47,7 @@
// SaramaClient represents the messaging proxy
type SaramaClient struct {
cAdmin sarama.ClusterAdmin
- KafkaHost string
- KafkaPort int
+ KafkaAddress string
producer sarama.AsyncProducer
consumer sarama.Consumer
groupConsumers map[string]*scc.Consumer
@@ -86,15 +85,9 @@
type SaramaClientOption func(*SaramaClient)
-func Host(host string) SaramaClientOption {
+func Address(address string) SaramaClientOption {
return func(args *SaramaClient) {
- args.KafkaHost = host
- }
-}
-
-func Port(port int) SaramaClientOption {
- return func(args *SaramaClient) {
- args.KafkaPort = port
+ args.KafkaAddress = address
}
}
@@ -202,8 +195,7 @@
func NewSaramaClient(opts ...SaramaClientOption) *SaramaClient {
client := &SaramaClient{
- KafkaHost: DefaultKafkaHost,
- KafkaPort: DefaultKafkaPort,
+ KafkaAddress: DefaultKafkaAddress,
}
client.consumerType = DefaultConsumerType
client.producerFlushFrequency = DefaultProducerFlushFrequency
@@ -695,15 +687,14 @@
}
func (sc *SaramaClient) createClusterAdmin() error {
- kafkaFullAddr := fmt.Sprintf("%s:%d", sc.KafkaHost, sc.KafkaPort)
config := sarama.NewConfig()
config.Version = sarama.V1_0_0_0
// Create a cluster Admin
var cAdmin sarama.ClusterAdmin
var err error
- if cAdmin, err = sarama.NewClusterAdmin([]string{kafkaFullAddr}, config); err != nil {
- logger.Errorw("cluster-admin-failure", log.Fields{"error": err, "broker-address": kafkaFullAddr})
+ if cAdmin, err = sarama.NewClusterAdmin([]string{sc.KafkaAddress}, config); err != nil {
+ logger.Errorw("cluster-admin-failure", log.Fields{"error": err, "broker-address": sc.KafkaAddress})
return err
}
sc.cAdmin = cAdmin
@@ -841,8 +832,7 @@
//config.Producer.RequiredAcks = sarama.WaitForAll
config.Producer.RequiredAcks = sarama.WaitForLocal
- kafkaFullAddr := fmt.Sprintf("%s:%d", sc.KafkaHost, sc.KafkaPort)
- brokers := []string{kafkaFullAddr}
+ brokers := []string{sc.KafkaAddress}
if producer, err := sarama.NewAsyncProducer(brokers, config); err != nil {
logger.Errorw("error-starting-publisher", log.Fields{"error": err})
@@ -862,8 +852,7 @@
config.Consumer.MaxProcessingTime = time.Duration(sc.maxProcessingTime) * time.Millisecond
config.Consumer.Offsets.Initial = sarama.OffsetNewest
config.Metadata.Retry.Max = sc.metadataMaxRetry
- kafkaFullAddr := fmt.Sprintf("%s:%d", sc.KafkaHost, sc.KafkaPort)
- brokers := []string{kafkaFullAddr}
+ brokers := []string{sc.KafkaAddress}
if consumer, err := sarama.NewConsumer(brokers, config); err != nil {
logger.Errorw("error-starting-consumers", log.Fields{"error": err})
@@ -887,8 +876,7 @@
//config.Consumer.MaxProcessingTime = time.Duration(DefaultMaxProcessingTime) * time.Millisecond
config.Consumer.Offsets.Initial = initialOffset
//config.Consumer.Offsets.Initial = sarama.OffsetOldest
- kafkaFullAddr := fmt.Sprintf("%s:%d", sc.KafkaHost, sc.KafkaPort)
- brokers := []string{kafkaFullAddr}
+ brokers := []string{sc.KafkaAddress}
topics := []string{topic.Name}
var consumer *scc.Consumer
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager/ponresourcemanager.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager/ponresourcemanager.go
index 4cccb84..5c10b5e 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager/ponresourcemanager.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/ponresourcemanager/ponresourcemanager.go
@@ -22,7 +22,6 @@
"encoding/json"
"errors"
"fmt"
- "strconv"
"time"
bitmap "github.com/boljen/go-bitmap"
@@ -140,8 +139,7 @@
DeviceType string
DeviceID string
Backend string // ETCD, or consul
- Host string // host ip of the KV store
- Port int // port number for the KV store
+ Address string // address of the KV store
OLTModel string
KVStore *db.Backend
KVStoreForConfig *db.Backend
@@ -167,11 +165,10 @@
return nil, errors.New("unsupported-kv-store")
}
-func SetKVClient(Technology string, Backend string, Host string, Port int, configClient bool) *db.Backend {
- addr := Host + ":" + strconv.Itoa(Port)
+func SetKVClient(Technology string, Backend string, Addr string, configClient bool) *db.Backend {
// TODO : Make sure direct call to NewBackend is working fine with backend , currently there is some
// issue between kv store and backend , core is not calling NewBackend directly
- kvClient, err := newKVClient(Backend, addr, KVSTORE_RETRY_TIMEOUT)
+ kvClient, err := newKVClient(Backend, Addr, KVSTORE_RETRY_TIMEOUT)
if err != nil {
logger.Fatalw("Failed to init KV client\n", log.Fields{"err": err})
return nil
@@ -187,8 +184,7 @@
kvbackend := &db.Backend{
Client: kvClient,
StoreType: Backend,
- Host: Host,
- Port: Port,
+ Address: Addr,
Timeout: KVSTORE_RETRY_TIMEOUT,
PathPrefix: pathPrefix}
@@ -196,27 +192,26 @@
}
// NewPONResourceManager creates a new PON resource manager.
-func NewPONResourceManager(Technology string, DeviceType string, DeviceID string, Backend string, Host string, Port int) (*PONResourceManager, error) {
+func NewPONResourceManager(Technology string, DeviceType string, DeviceID string, Backend string, Address string) (*PONResourceManager, error) {
var PONMgr PONResourceManager
PONMgr.Technology = Technology
PONMgr.DeviceType = DeviceType
PONMgr.DeviceID = DeviceID
PONMgr.Backend = Backend
- PONMgr.Host = Host
- PONMgr.Port = Port
- PONMgr.KVStore = SetKVClient(Technology, Backend, Host, Port, false)
+ PONMgr.Address = Address
+ PONMgr.KVStore = SetKVClient(Technology, Backend, Address, false)
if PONMgr.KVStore == nil {
logger.Error("KV Client initilization failed")
return nil, errors.New("Failed to init KV client")
}
// init kv client to read from the config path
- PONMgr.KVStoreForConfig = SetKVClient(Technology, Backend, Host, Port, true)
+ PONMgr.KVStoreForConfig = SetKVClient(Technology, Backend, Address, true)
if PONMgr.KVStoreForConfig == nil {
logger.Error("KV Config Client initilization failed")
return nil, errors.New("Failed to init KV Config client")
}
// Initialize techprofile for this technology
- if PONMgr.TechProfileMgr, _ = tp.NewTechProfile(&PONMgr, Backend, Host, Port); PONMgr.TechProfileMgr == nil {
+ if PONMgr.TechProfileMgr, _ = tp.NewTechProfile(&PONMgr, Backend, Address); PONMgr.TechProfileMgr == nil {
logger.Error("Techprofile initialization failed")
return nil, errors.New("Failed to init tech profile")
}
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/config.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/config.go
index 8a304be..fe3e4a2 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/config.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/config.go
@@ -76,8 +76,7 @@
// TechprofileFlags represents the set of configurations used
type TechProfileFlags struct {
- KVStoreHost string
- KVStorePort int
+ KVStoreAddress string
KVStoreType string
KVStoreTimeout time.Duration
KVBackend *db.Backend
@@ -93,12 +92,11 @@
DefaultNumGemPorts uint32
}
-func NewTechProfileFlags(KVStoreType string, KVStoreHost string, KVStorePort int) *TechProfileFlags {
+func NewTechProfileFlags(KVStoreType string, KVStoreAddress string) *TechProfileFlags {
// initialize with default values
var techProfileFlags = TechProfileFlags{
KVBackend: nil,
- KVStoreHost: KVStoreHost,
- KVStorePort: KVStorePort,
+ KVStoreAddress: KVStoreAddress,
KVStoreType: KVStoreType,
KVStoreTimeout: defaultKVStoreTimeout,
DefaultTPName: defaultTechProfileName,
diff --git a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/tech_profile.go b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/tech_profile.go
index 00208d6..afe5c09 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/tech_profile.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v3/pkg/techprofile/tech_profile.go
@@ -243,12 +243,11 @@
}
func (t *TechProfileMgr) SetKVClient() *db.Backend {
- addr := t.config.KVStoreHost + ":" + strconv.Itoa(t.config.KVStorePort)
- kvClient, err := newKVClient(t.config.KVStoreType, addr, t.config.KVStoreTimeout)
+ kvClient, err := newKVClient(t.config.KVStoreType, t.config.KVStoreAddress, t.config.KVStoreTimeout)
if err != nil {
logger.Errorw("failed-to-create-kv-client",
log.Fields{
- "type": t.config.KVStoreType, "host": t.config.KVStoreHost, "port": t.config.KVStorePort,
+ "type": t.config.KVStoreType, "address": t.config.KVStoreAddress,
"timeout": t.config.KVStoreTimeout, "prefix": t.config.TPKVPathPrefix,
"error": err.Error(),
})
@@ -257,8 +256,7 @@
return &db.Backend{
Client: kvClient,
StoreType: t.config.KVStoreType,
- Host: t.config.KVStoreHost,
- Port: t.config.KVStorePort,
+ Address: t.config.KVStoreAddress,
Timeout: t.config.KVStoreTimeout,
PathPrefix: t.config.TPKVPathPrefix}
@@ -281,10 +279,10 @@
return nil, errors.New("unsupported-kv-store")
}
-func NewTechProfile(resourceMgr iPonResourceMgr, KVStoreType string, KVStoreHost string, KVStorePort int) (*TechProfileMgr, error) {
+func NewTechProfile(resourceMgr iPonResourceMgr, KVStoreType string, KVStoreAddress string) (*TechProfileMgr, error) {
var techprofileObj TechProfileMgr
logger.Debug("Initializing techprofile Manager")
- techprofileObj.config = NewTechProfileFlags(KVStoreType, KVStoreHost, KVStorePort)
+ techprofileObj.config = NewTechProfileFlags(KVStoreType, KVStoreAddress)
techprofileObj.config.KVBackend = techprofileObj.SetKVClient()
if techprofileObj.config.KVBackend == nil {
logger.Error("Failed to initialize KV backend\n")
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 11fbc04..630585a 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -67,7 +67,7 @@
github.com/mitchellh/go-homedir
# github.com/mitchellh/mapstructure v1.1.2
github.com/mitchellh/mapstructure
-# github.com/opencord/voltha-lib-go/v3 v3.1.12
+# github.com/opencord/voltha-lib-go/v3 v3.1.13
github.com/opencord/voltha-lib-go/v3/pkg/adapters
github.com/opencord/voltha-lib-go/v3/pkg/adapters/adapterif
github.com/opencord/voltha-lib-go/v3/pkg/adapters/common