Juniper / junos-terraform

Apache License 2.0
70 stars 24 forks source link

Unable to Generate Terraform API #17

Closed driftavalii closed 2 years ago

driftavalii commented 2 years ago

I am running into this error when running ./processYang with the /yang/20.3/20.3R1/junos-es/conf/junos-es-conf-protocols@2019-01-01.yang

error processing file:  junos-es-conf-protocols@2019-01-01
panic: pyang error: exit status 1

goroutine 1 [running]:
github.com/Juniper/junos-terraform/Internal/processYang.generateYinFile({0xc00001e100, 0x3b})
    /home/d/project/network-automation/juniper/junos-terraform/Internal/processYang/processYang.go:172 +0x334
github.com/Juniper/junos-terraform/Internal/processYang.CreateYinFileAndXpath({{0xc00001e100, 0x3b}, {0xc0000162a0, 0x4f}, {0xc000022190, 0x4a}, {0xc000014120, 0x4}})
    /home/d/project/network-automation/juniper/junos-terraform/Internal/processYang/processYang.go:83 +0xb7
main.main()
    /home/d/project/network-automation/juniper/junos-terraform/cmd/processYang/main.go:82 +0x3c5
(venv) d@devUbuntu:~/project/network-automation/juniper/junos-terraform/cmd/processYang$ python3 --version
Python 3.9.7
(venv) d@devUbuntu:~/project/network-automation/juniper/junos-terraform/cmd/processYang$ go version
go version go1.17.2 linux/amd64
(venv) d@devUbuntu:~/project/network-automation/juniper/junos-terraform/cmd/processYang$ pyang --version
pyang 2.5.0
(venv) d@devUbuntu:~/project/network-automation/juniper/junos-terraform/cmd/processYang$ 
(venv) d@devUbuntu:~/project/network-automation/juniper/jtafwd$ cat config.toml 
yangDir = "/home/d/project/network-automation/juniper/jtafwd"
providerDir = "/home/d/project/network-automation/juniper/jtafwd/terraform_providers"
xpathPath = "/home/d/project/network-automation/juniper/jtafwd/xpath_test.xml"
fileType = "both"
davedotdev commented 2 years ago

Hi there,

Try the latest build. I suspect it's an issue with a missing YANG model and in the earlier versions of JTAF, information leaving Pyang was suppressed. That's now not the case and you will have a clearer error message.

I ran into this myself and fixed the bug.

aprabh92 commented 2 years ago

@ driftavalii you will run into this issue if the yang files from "common" folder is missing.

please copy the below and try

(venv) root@ubuntu:/opt/aprabh/new-provider/yang/21.3/21.3R1/common# ls -lrt total 12 -rw-r--r-- 1 root root 3398 Dec 4 06:26 junos-common-types@2019-01-01.yang -rw-r--r-- 1 root root 2346 Dec 4 06:26 junos-common-odl-extensions@2019-01-01.yang -rw-r--r-- 1 root root 1806 Dec 4 06:26 junos-common-ddl-extensions@2019-01-01.yang


Creating Yin files from Yang file directory: /opt/aprabh/new-provider/junos-terraform/yang_files1 -

Yin file for junos-common-ddl-extensions@2019-01-01 is generated Yin file for junos-common-odl-extensions@2019-01-01 is generated Yin file for junos-common-types@2019-01-01 is generated Yin file for junos-es-conf-access@2019-01-01 is generated Yin file for junos-es-conf-access-profile@2019-01-01 is generated Yin file for junos-es-conf-accounting-options@2019-01-01 is generated Yin file for junos-es-conf-applications@2019-01-01 is generated

driftavalii commented 2 years ago

@aprabh92 yep, that worked, thanks