Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Mgmt reorg -- use translib APIs from sonic-mgmt-common repo (#35)
Browse files Browse the repository at this point in the history
* Use translib APIs from sonic-mgmt-common repo

1) Removed dependency on sonic-mgmt-framework repo. All translib
dependencies now use the new sonic-mgmt-common repo.

2) Cleaned up go dependency download & patching logic in Makefile. All
translib and cvl related libraries and patches are now handled in
sonic-mgmt-common repo itself. Telemetry Makefile now manages only
telemetry specific dependencies.

* Fix incremental build for go module vendroing
  • Loading branch information
sachinholla authored Jun 14, 2020
1 parent 9a263d5 commit fa8d498
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 72 deletions.
80 changes: 27 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,46 @@ export PATH := $(PATH):$(GOPATH)/bin

INSTALL := /usr/bin/install
DBDIR := /var/run/redis/sonic-db/
GO := /usr/local/go/bin/go
GO ?= /usr/local/go/bin/go
TOP_DIR := $(abspath ..)
GO_MGMT_PATH=$(TOP_DIR)/sonic-mgmt-framework
BUILD_DIR := $(GOPATH)/bin
export CVL_SCHEMA_PATH := $(GO_MGMT_PATH)/src/cvl/schema
MGMT_COMMON_DIR := $(TOP_DIR)/sonic-mgmt-common
BUILD_DIR := build/bin
export CVL_SCHEMA_PATH := $(MGMT_COMMON_DIR)/build/cvl/schema
export GOBIN := $(abspath $(BUILD_DIR))

SRC_FILES=$(shell find . -name '*.go' | grep -v '_test.go' | grep -v '/tests/')
TEST_FILES=$(wildcard *_test.go)
TELEMETRY_TEST_DIR = $(GO_MGMT_PATH)/build/tests/gnmi_server
TELEMETRY_TEST_DIR = build/tests/gnmi_server
TELEMETRY_TEST_BIN = $(TELEMETRY_TEST_DIR)/server.test
ifeq ($(SONIC_TELEMETRY_READWRITE),y)
BLD_FLAGS := -tags readwrite
endif

.phony: mgmt-deps
GO_DEPS := vendor/.done
PATCHES := $(wildcard patches/*.patch)
PATCHES += $(shell find $(MGMT_COMMON_DIR)/patches -type f)

all: sonic-telemetry $(TELEMETRY_TEST_BIN)

go.mod:
/usr/local/go/bin/go mod init github.com/Azure/sonic-telemetry
mgmt-deps:
rm -rf cvl
rm -rf translib
cp -r ../sonic-mgmt-framework/src/cvl ./
cp -r ../sonic-mgmt-framework/src/translib ./
find cvl -name \*\.go -exec sed -i -e 's/\"translib/\"github.com\/Azure\/sonic-telemetry\/translib/g' {} \;
find translib -name \*\.go -exec sed -i -e 's/\"translib/\"github.com\/Azure\/sonic-telemetry\/translib/g' {} \;
find cvl -name \*\.go -exec sed -i -e 's/\"cvl/\"github.com\/Azure\/sonic-telemetry\/cvl/g' {} \;
find translib -name \*\.go -exec sed -i -e 's/\"cvl/\"github.com\/Azure\/sonic-telemetry\/cvl/g' {} \;
sed -i -e 's/\.\.\/\.\.\/\.\.\/models\/yang/\.\.\/\.\.\/\.\.\/sonic-mgmt-framework\/models\/yang/' translib/ocbinds/oc.go
sed -i -e 's/\$$GO run \$$BUILD_GOPATH\/src\/github.com\/openconfig\/ygot\/generator\/generator.go/generator/' translib/ocbinds/oc.go
$(GO) get github.com/openconfig/gnmi@89b2bf29312cda887da916d0f3a32c1624b7935f
$(GO) get github.com/openconfig/ygot@724a6b18a9224343ef04fe49199dfb6020ce132a
$(GO) get github.com/openconfig/goyang@064f9690516f4f72db189f4690b84622c13b7296
$(GO) get github.com/openconfig/goyang@064f9690516f4f72db189f4690b84622c13b7296
$(GO) mod init github.com/Azure/sonic-telemetry

$(GO_DEPS): go.mod $(PATCHES)
# FIXME temporary workaround for crypto not downloading..
$(GO) get golang.org/x/crypto/ssh/terminal@e9b2fee46413
$(GO) get github.com/jipanyang/gnxi@f0a90cca6fd0041625bcce561b71f849c9b65a8d
$(GO) install github.com/openconfig/ygot/generator
$(GO) get -x github.com/golang/glog@23def4e6c14b4da8ac2ed8007337bc5eb5007998
rm -rf vendor
$(GO) mod vendor
ln -s vendor src
cp -r $(GOPATH)/pkg/mod/github.com/openconfig/[email protected]/* vendor/github.com/openconfig/gnmi/
cp -r $(GOPATH)/pkg/mod/github.com/openconfig/[email protected]/* vendor/github.com/openconfig/goyang/
cp -r $(GOPATH)/pkg/mod/github.com/openconfig/[email protected]/* vendor/github.com/openconfig/ygot/
$(MGMT_COMMON_DIR)/patches/apply.sh vendor
cp -r $(GOPATH)/pkg/mod/golang.org/x/[email protected] vendor/golang.org/x/crypto
chmod -R u+w vendor
patch -d vendor -p0 <patches/gnmi_cli.all.patch
patch -d vendor/github.com/antchfx/jsonquery -p1 < ../sonic-mgmt-framework/patches/jsonquery.patch
patch -d vendor/github.com/openconfig/goyang -p1 < ../sonic-mgmt-framework/goyang-modified-files/goyang.patch
patch -d vendor/github.com/openconfig -p1 < ../sonic-mgmt-framework/ygot-modified-files/ygot.patch
$(GO) generate github.com/Azure/sonic-telemetry/translib/ocbinds
make -C $(GO_MGMT_PATH)/src/cvl/schema
make -C $(GO_MGMT_PATH)/models
make -C $(GO_MGMT_PATH)/models/yang
make -C $(GO_MGMT_PATH)/models/yang/sonic

sonic-telemetry: go.mod mgmt-deps
touch $@

go-deps: $(GO_DEPS)

go-deps-clean:
$(RM) -r vendor

sonic-telemetry: $(GO_DEPS)
$(GO) install -mod=vendor $(BLD_FLAGS) github.com/Azure/sonic-telemetry/telemetry
$(GO) install -mod=vendor $(BLD_FLAGS) github.com/Azure/sonic-telemetry/dialout/dialout_client_cli
$(GO) install github.com/jipanyang/gnxi/gnmi_get
Expand All @@ -73,22 +55,18 @@ check:
sudo mkdir -p ${DBDIR}
sudo cp ./testdata/database_config.json ${DBDIR}
sudo mkdir -p /usr/models/yang || true
sudo find $(GO_MGMT_PATH)/models -name '*.yang' -exec cp {} /usr/models/yang/ \;
sudo find $(MGMT_COMMON_DIR)/models -name '*.yang' -exec cp {} /usr/models/yang/ \;
-$(GO) test -mod=vendor $(BLD_FLAGS) -v github.com/Azure/sonic-telemetry/gnmi_server
-$(GO) test -mod=vendor $(BLD_FLAGS) -v github.com/Azure/sonic-telemetry/dialout/dialout_client

clean:
rm -rf cvl
rm -rf translib
rm -rf vendor
chmod -f -R u+w $(GOPATH)/pkg || true
rm -rf $(GOPATH)
rm -f src
$(RM) -r build
$(RM) -r vendor

$(TELEMETRY_TEST_BIN): $(TEST_FILES) $(SRC_FILES)
mkdir -p $(@D)
cp -r testdata $(@D)/
$(GO) test -mod=vendor $(BLD_FLAGS) -c -cover github.com/Azure/sonic-telemetry/gnmi_server -o $@
cp -r testdata $(TELEMETRY_TEST_DIR)
cp -r $(GO_MGMT_PATH)/src/cvl/schema $(TELEMETRY_TEST_DIR)

install:
$(INSTALL) -D $(BUILD_DIR)/telemetry $(DESTDIR)/usr/sbin/telemetry
Expand All @@ -97,10 +75,6 @@ install:
$(INSTALL) -D $(BUILD_DIR)/gnmi_set $(DESTDIR)/usr/sbin/gnmi_set
$(INSTALL) -D $(BUILD_DIR)/gnmi_cli $(DESTDIR)/usr/sbin/gnmi_cli

mkdir -p $(DESTDIR)/usr/bin/
cp -r $(GO_MGMT_PATH)/src/cvl/schema $(DESTDIR)/usr/sbin
mkdir -p $(DESTDIR)/usr/models/yang
find $(GO_MGMT_PATH)/models -name '*.yang' -exec cp {} $(DESTDIR)/usr/models/yang/ \;

deinstall:
rm $(DESTDIR)/usr/sbin/telemetry
Expand Down
14 changes: 3 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ module github.com/Azure/sonic-telemetry
go 1.12

require (
github.com/Azure/sonic-mgmt-common v0.0.0-00010101000000-000000000000
github.com/Workiva/go-datastructures v1.0.50
github.com/antchfx/jsonquery v1.1.0
github.com/antchfx/xmlquery v1.2.1
github.com/antchfx/xpath v1.1.2 // indirect
github.com/c9s/goprocinfo v0.0.0-20191125144613-4acdd056c72d
github.com/go-redis/redis v6.15.6+incompatible
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/golang/protobuf v1.3.2
github.com/google/gnxi v0.0.0-20191016182648-6697a080bc2d
github.com/jipanyang/gnmi v0.0.0-20180820232453-cb4d464fa018
Expand All @@ -19,17 +16,12 @@ require (
github.com/onsi/ginkgo v1.10.3 // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c
github.com/openconfig/goyang v0.0.0-20190924211109-064f9690516f
github.com/openconfig/ygot v0.6.1-0.20190723223108-724a6b18a922
github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3 // indirect
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413 // indirect
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 // indirect
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553
golang.org/x/text v0.3.0
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect
golang.org/x/sys v0.0.0-20190412213103-97732733099d // indirect
google.golang.org/grpc v1.25.1
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
)

replace github.com/Azure/sonic-mgmt-framework => ../sonic-mgmt-framework
replace github.com/Azure/sonic-mgmt-common => ../sonic-mgmt-common
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-redis/redis v6.15.6+incompatible h1:H9evprGPLI8+ci7fxQx6WNZHJSb7be8FqJQRhdQZ5Sg=
github.com/go-redis/redis v6.15.6+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-redis/redis/v7 v7.0.0-beta.3.0.20190824101152-d19aba07b476/go.mod h1:xhhSbUMTsleRPur+Vgx9sUHtyN33bdjxY+9/0n9Ig8s=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 h1:uHTyIjqVhYRhLbJ8nIiOJHkEZZ+5YoOsAbD3sk82NiE=
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
Expand All @@ -41,20 +42,18 @@ github.com/jipanyang/gnxi v0.0.0-20181221084354-f0a90cca6fd0/go.mod h1:vL9tMB3I6
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.3 h1:OoxbjfXVZyod1fmWYhI7SEyaD8B00ynP3T+D5GiyHOY=
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1 h1:K0jcRCwNQM3vFGh1ppMtDh/+7ApJrjldlX8fA0jDTLQ=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c h1:a380JP+B7xlMbEQOlha1buKhzBPXFqgFXplyWCEIGEY=
github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c/go.mod h1:t+O9It+LKzfOAhKTT5O0ehDix+MTqbtT0T9t+7zzOvc=
github.com/openconfig/gnmi v0.0.0-20200307010808-e7106f7f5493 h1:e/znXbq+Yiws97a4lJYlUeRw9OGxT2q27L4aMUb0GuM=
github.com/openconfig/goyang v0.0.0-20190924211109-064f9690516f h1:BaekRUaWpfaRBP3mShDZaNi4+EHbdli7D6YXc/TP3lo=
github.com/openconfig/goyang v0.0.0-20190924211109-064f9690516f/go.mod h1:dhXaV0JgHJzdrHi2l+w0fZrwArtXL7jEFoiqLEdmkvU=
github.com/openconfig/ygot v0.6.0 h1:kJJFPBrczC6TDnz/HMlFTJEdW2CuyUftV13XveIukg0=
github.com/openconfig/ygot v0.6.1-0.20190723223108-724a6b18a922 h1:zBLb75mrLMxabjsAhPk/2qxbht+BwHKFWBvRAB4Fd2U=
github.com/openconfig/ygot v0.6.1-0.20190723223108-724a6b18a922/go.mod h1:o30svNf7O0xK+R35tlx95odkDmZWS9JyWWQSmIhqwAs=
github.com/openconfig/ygot v0.6.1-0.20191216180356-029bc88c228c h1:Ow7KYdHwjrPrRozqmYGtEEdEX5/owpE4dgRUvxmbSsI=
github.com/openconfig/ygot v0.6.1-0.20191216180356-029bc88c228c/go.mod h1:o30svNf7O0xK+R35tlx95odkDmZWS9JyWWQSmIhqwAs=
github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3 h1:YtFkrqsMEj7YqpIhRteVxJxCeC3jJBieuLr0d4C4rSA=
github.com/pborman/getopt v0.0.0-20190409184431-ee0cd42419d3/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down Expand Up @@ -109,6 +108,7 @@ gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 1 addition & 1 deletion sonic_data_client/transl_data_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"time"
"fmt"
"reflect"
"github.com/Azure/sonic-telemetry/translib"
"github.com/Azure/sonic-mgmt-common/translib"
"bytes"
"encoding/json"
)
Expand Down
2 changes: 1 addition & 1 deletion transl_utils/transl_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
log "github.com/golang/glog"
gnmipb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/Azure/sonic-telemetry/translib"
"github.com/Azure/sonic-mgmt-common/translib"
)

func GnmiTranslFullPath(prefix, path *gnmipb.Path) *gnmipb.Path {
Expand Down

0 comments on commit fa8d498

Please sign in to comment.