Skip to content

Commit

Permalink
Resolved GitHub issue CiscoDevNet#1069
Browse files Browse the repository at this point in the history
Signed-off-by: ygorelik <yangorelik@yahoo.com>
  • Loading branch information
ygorelik committed Oct 17, 2022
1 parent 89e24be commit bf17e18
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 196 deletions.
10 changes: 10 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* Added SSL support for NetconfServiceProvider in Go
* Improved installation script to allow use Python system installation
* Allow custom Python installation in YDK installation script
* install_ydk.sh: Installation of Python YDK packages should not require root access ([#1069](https://github.com/CiscoDevNet/ydk-gen/issues/1069))


#### Resolved GitHub issues
* Go function EntityEqual result depends on parameters order ([#1053](https://github.com/CiscoDevNet/ydk-gen/issues/1053))
Expand All @@ -21,6 +23,14 @@
* The installation script fails on fresh new CentOS 7 docker container ([#1064](https://github.com/CiscoDevNet/ydk-gen/issues/1064))
* ExecutorService fails on non-ietf RPC with Libyang error ([#1067](https://github.com/CiscoDevNet/ydk-gen/issues/1067))

### Resolved non-GitHub issues
* Upgraded third party packages Sphinx (1.5.6) and wheel (0.37.1) due to documentation
generation issues on Mac Big Sur
* Fixed installation script for the case, when virtual environment is not used

#### Documentation improvements
* Fixed documentation issue [#1066](https://github.com/CiscoDevNet/ydk-gen/issues/1066)

#### Bundle improvements
* Updated cisco-ios-xr bundle (profile cisco-ios-xr_6_7_3.json) to support Cisco IOS XR 6.7.3
* Updated openconfig bundle (profile openconfig_0_1_9.json) to support YANG models of revision "2020-05-06"
Expand Down
51 changes: 28 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,45 +157,49 @@ source .env
```

The YDK extensively uses Python scripts for building its components and model API packages (bundles).
By default the YDK uses Python system installation.
In order to isolate YDK Python environment from system installation, the script can build Python3 virtual environment.
If built, the user must manually activate virtual environment when generating model bundles and/or running YDK based application.
By default the Python virtual environment is installed under `$HOME/venv` directory.
For different location the PYTHON_VENV environment variable should be set to that location.

**NOTE.** It is strongly recommended to use Python virtual environment on Centos/RHEL and Mac platforms.

When installing YDK for Python or Go programming languages, the third party dependencies and C++ packages must be installed first.
This step requires sudo/root access to the installation platform.
Here is simple example of core YDK installation for Python programming language and Python virtual environment:

```
git clone https://gitlab.com/yangorelik/ydk-gen.git
cd ydk-gen
git checkout tags/0.9.1.1 -b master
export YDKGEN_HOME=`pwd` # optional
export PYTHON_VENV=$HOME/ydk_vne # optional
./install_ydk.sh --core --venv
./install_ydk.sh --cpp --core --venv # This step requires sudo access!
./install_ydk.sh --py --core --venv
```

The script also allows to install individual components like dependencies, core, and service packages
The script also allows installing individual components like dependencies, core, and service packages
for specified programming language or for all supported languages.
Full set of script capabilities could be viewed like this:

```
./install_ydk.sh --help
usage: install_ydk [ {--cpp|--py|--go|--all} ] [-c] [-s gnmi] [-h] [-n] [-v] [-p path]
Options and arguments:
--cpp install YDK for C++ programming language
--cpp install YDK for C++ programming language;
requires sudo access for dependencies and libraries installation
--go install YDK for Go programming language
--py|--python install YDK for Python programming language (default)
--all install YDK for all supported programming languages
--py|--python install YDK for Python programming language
--all install YDK for all available programming languages
requires sudo access for dependencies and libraries installation
-v|--venv create python virtual environment
-c|--core install YDK core packages
-s|--service gnmi install gNMI service package
-n|--no-deps skip installation of dependencies
-n|--no-deps skip installation of dependencies;
applicable only with --cpp and --all options
-p|--python-dir path set Python3 installation root directory;
if not specified, system installation assumed
-h|--help print this help message and exit
Environment variables:
YDKGEN_HOME specifies location of ydk-gen git repository;
if not set, $HOME/ydk-gen is assumed
Expand Down Expand Up @@ -273,10 +277,11 @@ and YDK gNMI service package.

### gNMI service installation

Here is simple example how gNMI service package for Python could be added:
Here is simple example how gNMI service package for Python virtual environment could be added:

```
cd ydk-gen
./install_ydk.sh --cpp --service gnmi -v # requires sudo access
./install_ydk.sh --py --service gnmi -v
```

Expand All @@ -301,7 +306,7 @@ All the YDK components/packages can be generated by using Python script `generat
```
cd ydk-gen
source .env
./generate.py --help
python3 generate.py --help
usage: generate.py [-h] [-l] [--core] [--service SERVICE] [--bundle BUNDLE]
[--adhoc-bundle-name ADHOC_BUNDLE_NAME]
[--adhoc-bundle ADHOC_BUNDLE [ADHOC_BUNDLE ...]]
Expand Down Expand Up @@ -368,7 +373,7 @@ All other attributes, like `"author"` and `"copyright"`, are optional and will n
{
"name":"cisco-ios-xr",
"version": "6.5.3",
"core_version": "0.9.0",
"core_version": "0.9.1",
"author": "Cisco",
"copyright": "Cisco",
"description": "Cisco IOS-XR Native Models From Git",
Expand Down Expand Up @@ -432,7 +437,7 @@ YDK runtime environment must be activated prior to these procedures.
If applicable, the Python virtual environment must be activated prior to these procedures

```
./generate.py --python --bundle profiles/bundles/<name-of-profile>.json -i
python3 generate.py --python --bundle profiles/bundles/<name-of-profile>.json -i
```

Check Python packages installed:
Expand All @@ -447,13 +452,13 @@ ydk-models-<name-of-bundle> (0.5.1)
### For Go

```
./generate.py --go --bundle profiles/bundles/<name-of-profile>.json -i
python3 generate.py --go --bundle profiles/bundles/<name-of-profile>.json -i
```

### For C++

```
./generate.py --cpp --bundle profiles/bundles/<name-of-profile>.json -is
python3 generate.py --cpp --bundle profiles/bundles/<name-of-profile>.json -is
```

## Writing your first app
Expand All @@ -476,10 +481,10 @@ For example, the below sequence of commands will generate the documentation for
(for C++, use `--cpp`; for Go, use `--go`).

```
./generate.py --python --bundle profiles/bundles/ietf_0_1_1.json
./generate.py --python --bundle profiles/bundles/openconfig_0_1_1.json
./generate.py --python --bundle profiles/bundles/cisco_ios_xr_6_1_1.json
./generate.py --python --core --generate-doc
python3 generate.py --python --bundle profiles/bundles/ietf_0_1_1.json
python3 generate.py --python --bundle profiles/bundles/openconfig_0_1_1.json
python3 generate.py --python --bundle profiles/bundles/cisco_ios_xr_6_1_1.json
python3 generate.py --python --core --generate-doc
```

**Note.** The documentation generation for bundles can take few hours due to their size. If you have previously
Expand All @@ -490,8 +495,8 @@ the add-on documentation generation time can be reduced. Adding cisco-ios-xr doc
mkdir gen-api/cache
mv gen-api/python gen-api/cache
./generate.py --python --bundle profiles/bundles/cisco_ios_xr_6_6_3.json
./generate.py --python --core --generate-doc --output-directory gen-api --cached-output-dir
python3 generate.py --python --bundle profiles/bundles/cisco_ios_xr_6_6_3.json
python3 generate.py --python --core --generate-doc --output-directory gen-api --cached-output-dir
```

## Generating an "Adhoc" YDK-Py Bundle
Expand All @@ -501,7 +506,7 @@ just few models. It is called an "adhoc" bundle. Such a bundle generated without
Here is simple example:

```
./generate.py -i --adhoc-bundle-name test --adhoc-bundle \
python3 generate.py -i --adhoc-bundle-name test --adhoc-bundle \
/opt/git-repos/clean-yang/vendor/cisco/xr/621/Cisco-IOS-XR-ipv4-bgp-oper*.yang \
/opt/git-repos/clean-yang/vendor/cisco/xr/621/Cisco-IOS-XR-types.yang
/opt/git-repos/clean-yang/vendor/cisco/xr/621/Cisco-IOS-XR-ipv4-bgp-datatypes.yang
Expand Down Expand Up @@ -569,7 +574,7 @@ Other times, when the problem is not so evident, it is recommended to try runnin
`[--verbose|-v]` flag, which may reveal syntax problems with the YANG models being used. For example:

```
./generate.py --python --bundle profiles/bundles/ietf_0_1_1.json --verbose
python3 generate.py --python --bundle profiles/bundles/ietf_0_1_1.json --verbose
```

Also, it may be a good idea to obtain a local copy of the YANG models and compile them using `pyang` to ensure
Expand Down
Loading

0 comments on commit bf17e18

Please sign in to comment.