# ntscli-client
# Requirements
* python 3.8 or later with matching pip
* NTS-CLI compatible SSL configuration
# Architecture
The ntscli-client is combined with the ntscli-cloud-lib to build the nts command line tool.
The nts-cli-cloud lib is built separately from the ntscli-client and then updated by bumping the version
in the ntscli_client setup.py file.
# Building
## ntscli-cloud-lib
If you need to add a parameter to one of the automator messages, you will need to modify the cloud lib.
To add the new parameter, you modify the file automator.proto. You add a comment and a line like this:
// Boolean. Use this to request a test plan that only has the list of calibration tests.
google.protobuf.BoolValue calibration = 2;
To build, use:
tox -e proto
That will cause the automator.py file to be updated with the new proto.
Finally, you can install it in your local environment. Just cd to the lib directory and do a
pip install . --user
That copies it to your local environment, which you can check with:
pip freeze | grep ntscli_cloud_lib
After that, the nts client will just pick up the library automatically.
Once you are happy with the change, merge to master and then go here:
https://nts.builds.test.netflix.net/job/PYPI-NTSSER-ntscli-cloud-lib
Click the Release Next Version button to create a new release version.
To pick up the release in the client, bump the requirement version in ntscli_client setup.py:
'ntscli-cloud-lib==0.1.37'
and then you can test and release that similarly.
This keeps people from picking up stray updates that might break you.
## ntscli-client
Make changes in a feature branch. The PRs will be built here:
https://nts.builds.test.netflix.net/job/NTSSER-ntscli-client/
Any commit you push will go into Jenkins and build and the spinnaker will run tests but nothing goes public.
You make a fork branch (feature-thing-rc1) if spinnaker passes and notices that there is an "rc" in the branch name,
it will go ahead and push it to release. You can bypass this and do it manually (if the script fails, for instance) by:
* merge to master
* python setup.py version --bump patch --commit --push
This modifies a local __version__.py file to match the correct version. This is important, as it tells the --version commands what to print.
Then it does the correct git tag/commit/push.
This is provided by a library called setupmeta, which is written by Netflix employee Zoran S., who is on #python;
and is built in to newt.
If step 2 fails, force it by modifying the __version__.py file by hand, and tagging with a matching number:
* git tag v2.1.10002 (the v is important)
* git push / git push --tag as usual
Once you run the setup command, a new build will run here:
https://nts.builds.test.netflix.net/job/NTSSER-ntscli-client-master/
This build is responsible for releasing the client by pushing it to pypi. You can see all the versions of the client available on pypi by going here:
https://pypi.org/search/?q=ntscli-client
## Pypi
Pypi is currently used to host the client and make it available to partners for download and install. The account credentials for pypi can be found here:
https://secretbook.prod.security.netflix.net/group/103793/access
Access is granted to the pax team.
# Install
## Installing on the OS python:
Ubuntu only: You might need to install pip3 on Ubuntu if you haven't already:
`sudo apt install -y python3-pip`
Then this only requires python 3.8 or later, which is already installed on Ubuntu 18.04 and later, and macOS Catalina.
`pip3 install -U ntscli-client`
Ubuntu only: Ubuntu doesn't set up the user PATH to include the local user's python binary path.
You might have to do something like this if you can't find `nts` after install:
```
echo "export PATH=\"$(python3 -m site --user-base)/bin:$PATH\"" >> ~/.bashrc
source ~/.bashrc
```
# Install your security certificate
You still need a [security certificate, as documented here](https://docs.nrd.netflix.com/docs/nrdp/cert/ntscli/requesting-a-certificate/).
Once it's a decrypted zip file, you can now install it pretty easily with this tool:
`nts ssl install ~/Downloads/cloud.zip`
Manually moving it to ~/.config/netflix/cloud/(files) still works as well.
# Update Often
Use the same pip3 command, but especially for the first little while there will probably be frequent updates.
We suggest updating frequently anyway. For instance, for docker images or CI systems, you can install/update every time the image is
created or run. If a released update to the RAE requires matching client or client library updates, you would not require any additional
work to take the update.
## Versioning
We will be following standard python semantic versioning, so if you really want to pin versions, you can follow standard python practices:
```shell script
pip3 install ntscli-client<=3.0.0 # don't accidentally pick up a new major version, which could include breaking changes
pip3 install ntscli-client==0.1.4 # a specific older version
pip3 install ntscli-client>=0.1.5 # anything after a specific version
```
# Enjoy
`nts --help`
```shell script
export RAE=r3000334
export ESN=$(nts get-devices | jq -r 'map(.esn)[0]') # actually just the first ESN I find
# or for powershell:
$env:RAE = 'r3000334'
$env:ESN = 'NFANDROID2-PRV-SHIELDANDROIDTV-NVIDISHIELD=ANDROID=TV-15895-BB9C5AF4E97B69BC1A51654A94304D3AD88169C2BA2F1338192C20E940AE669E'
nts get-plan # prints to stdout
# get a plan dynamically
nts run --names AUDIO-001-TC1,ACT-004-TC11
# get a plan and run it immediately
nts get-plan | nts run --names AUDIO-001-TC1,ACT-004-TC11
# save the plan via shell redirection
nts get-plan > full_plan.json
# save the plan with an arg instead
nts get-plan --save-to full_plan.json
# Choosing what to run
## Just at run:
nts run --names AUDIO-001-TC1,ACT-004-TC11 # gets the test plan first, then filters
nts run --testplan full_plan.json --names AUDIO-001-TC1,ACT-004-TC11 # saves you the 1-2 minutes getting the test plan if you already have one
## using files
nts get-plan --save-to full_plan.json
cat full_plan.json | jq -r '{target: .target, testplan: {branch: .testplan.branch, sdkVersion: .testplan.sdkVersion, testcases: [.testplan.testcases[] | select(.category | startswith("Config"))] }}' > filtered_plan.json
cat filtered_plan.json | nts run
## built-in filtering command
nts get-plan --save-to full_plan.json
nts filter --help
nts filter --names AUDIO-001-TC1 < full_plan.json > filtered_plan.json
nts filter --names AUDIO-001-TC1 --testplan full_plan.json --save-to filtered_plan.json
nts filter --names-re "AUDIO.*TC3" full_plan.json --save-to filtered_plan.json
nts get-plan | nts filter --eyepatch --tags batch | nts run
## DIY Filtering using external tools, if you -really- want to
CURRENT_EPOCH=$(date +%s)
nts get-plan | jq -r '{target: .target, testplan: {branch: .testplan.branch, sdkVersion: .testplan.sdkVersion, testcases: [.testplan.testcases[] | select(.category | startswith("Config"))] }}' | nts run 2>${CURRENT_EPOCH}.stderr.txt > ${CURRENT_EPOCH}.json
```
#### Features
* JSON goes to stdout, logging goes to stderr: `nts get-devices > device_list.json`
* Typical shell exit codes for commands, mean you can use shell checks such as: `nts get-devices || echo FAIL`
* Multi-OS, multi-shell compatible
* Tab completion available (see `nts completion show --help`)
* Available via PYPI, using standard versioning
## Alternative Installs
#### Pre-release installs:
`pip3 install -U ntscli-client --pre`
If Netflix posts a pre-release that might include a bug fix specifically for you, you might be asked to try this.
#### Install for any user of the OS (generally discouraged):
`sudo pip3 install -U ntscli-client`
If you are managing a server that might have lots of users that need the same install, this might be a good solution if you don't prefer
using an alternate abstraction such as a virtual environment, conda environment, etc.
### Installing in an isolation environment
Python is well known for isolation environments like virtualenv, conda, pyenv, etc. These all work, and you should have no trouble using these if you prefer.
Raw data
{
"_id": null,
"home_page": "https://docs.nrd.netflix.com/docs/nrdp/cert/ntscli/",
"name": "ntscli-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "TSC",
"author_email": "davidb@netflix.com",
"download_url": "",
"platform": null,
"description": "# ntscli-client\n\n# Requirements\n\n* python 3.8 or later with matching pip\n* NTS-CLI compatible SSL configuration\n\n# Architecture\n\nThe ntscli-client is combined with the ntscli-cloud-lib to build the nts command line tool.\nThe nts-cli-cloud lib is built separately from the ntscli-client and then updated by bumping the version\nin the ntscli_client setup.py file.\n\n# Building\n## ntscli-cloud-lib\n\nIf you need to add a parameter to one of the automator messages, you will need to modify the cloud lib.\n\nTo add the new parameter, you modify the file automator.proto. You add a comment and a line like this:\n \t// Boolean. Use this to request a test plan that only has the list of calibration tests.\n \tgoogle.protobuf.BoolValue calibration = 2;\n\nTo build, use:\ntox -e proto\n\nThat will cause the automator.py file to be updated with the new proto.\n\nFinally, you can install it in your local environment. Just cd to the lib directory and do a \npip install . --user\n\nThat copies it to your local environment, which you can check with:\npip freeze | grep ntscli_cloud_lib\n\nAfter that, the nts client will just pick up the library automatically.\n\nOnce you are happy with the change, merge to master and then go here:\n\nhttps://nts.builds.test.netflix.net/job/PYPI-NTSSER-ntscli-cloud-lib\n\nClick the Release Next Version button to create a new release version.\n\nTo pick up the release in the client, bump the requirement version in ntscli_client setup.py:\n\t'ntscli-cloud-lib==0.1.37'\nand then you can test and release that similarly.\n\nThis keeps people from picking up stray updates that might break you.\n\n## ntscli-client\nMake changes in a feature branch. The PRs will be built here:\n\nhttps://nts.builds.test.netflix.net/job/NTSSER-ntscli-client/\n\nAny commit you push will go into Jenkins and build and the spinnaker will run tests but nothing goes public.\nYou make a fork branch (feature-thing-rc1) if spinnaker passes and notices that there is an \"rc\" in the branch name,\nit will go ahead and push it to release. You can bypass this and do it manually (if the script fails, for instance) by:\n\n* merge to master\n* python setup.py version --bump patch --commit --push\n\nThis modifies a local __version__.py file to match the correct version. This is important, as it tells the --version commands what to print.\nThen it does the correct git tag/commit/push.\n\nThis is provided by a library called setupmeta, which is written by Netflix employee Zoran S., who is on #python;\nand is built in to newt.\n\nIf step 2 fails, force it by modifying the __version__.py file by hand, and tagging with a matching number:\n* git tag v2.1.10002 (the v is important)\n* git push / git push --tag as usual\n\nOnce you run the setup command, a new build will run here:\n\nhttps://nts.builds.test.netflix.net/job/NTSSER-ntscli-client-master/\n\nThis build is responsible for releasing the client by pushing it to pypi. You can see all the versions of the client available on pypi by going here:\n\nhttps://pypi.org/search/?q=ntscli-client\n\n## Pypi\nPypi is currently used to host the client and make it available to partners for download and install. The account credentials for pypi can be found here:\n\nhttps://secretbook.prod.security.netflix.net/group/103793/access\n\nAccess is granted to the pax team.\n\n# Install\n\n## Installing on the OS python:\n\nUbuntu only: You might need to install pip3 on Ubuntu if you haven't already:\n\n`sudo apt install -y python3-pip`\n\nThen this only requires python 3.8 or later, which is already installed on Ubuntu 18.04 and later, and macOS Catalina.\n\n`pip3 install -U ntscli-client`\n\nUbuntu only: Ubuntu doesn't set up the user PATH to include the local user's python binary path. \nYou might have to do something like this if you can't find `nts` after install:\n\n```\necho \"export PATH=\\\"$(python3 -m site --user-base)/bin:$PATH\\\"\" >> ~/.bashrc\nsource ~/.bashrc\n```\n\n# Install your security certificate\n\nYou still need a [security certificate, as documented here](https://docs.nrd.netflix.com/docs/nrdp/cert/ntscli/requesting-a-certificate/). \nOnce it's a decrypted zip file, you can now install it pretty easily with this tool:\n\n`nts ssl install ~/Downloads/cloud.zip`\n\nManually moving it to ~/.config/netflix/cloud/(files) still works as well.\n\n# Update Often\n\nUse the same pip3 command, but especially for the first little while there will probably be frequent updates.\n\nWe suggest updating frequently anyway. For instance, for docker images or CI systems, you can install/update every time the image is \ncreated or run. If a released update to the RAE requires matching client or client library updates, you would not require any additional \nwork to take the update.\n\n## Versioning\n\nWe will be following standard python semantic versioning, so if you really want to pin versions, you can follow standard python practices:\n\n```shell script\npip3 install ntscli-client<=3.0.0 # don't accidentally pick up a new major version, which could include breaking changes\npip3 install ntscli-client==0.1.4 # a specific older version\npip3 install ntscli-client>=0.1.5 # anything after a specific version\n```\n\n# Enjoy\n\n`nts --help`\n\n```shell script\nexport RAE=r3000334\nexport ESN=$(nts get-devices | jq -r 'map(.esn)[0]') # actually just the first ESN I find\n# or for powershell:\n$env:RAE = 'r3000334'\n$env:ESN = 'NFANDROID2-PRV-SHIELDANDROIDTV-NVIDISHIELD=ANDROID=TV-15895-BB9C5AF4E97B69BC1A51654A94304D3AD88169C2BA2F1338192C20E940AE669E'\n\nnts get-plan # prints to stdout\n\n# get a plan dynamically\nnts run --names AUDIO-001-TC1,ACT-004-TC11\n# get a plan and run it immediately\nnts get-plan | nts run --names AUDIO-001-TC1,ACT-004-TC11\n# save the plan via shell redirection\nnts get-plan > full_plan.json\n\n# save the plan with an arg instead\nnts get-plan --save-to full_plan.json\n\n# Choosing what to run\n\n## Just at run:\nnts run --names AUDIO-001-TC1,ACT-004-TC11 # gets the test plan first, then filters\nnts run --testplan full_plan.json --names AUDIO-001-TC1,ACT-004-TC11 # saves you the 1-2 minutes getting the test plan if you already have one\n\n## using files\nnts get-plan --save-to full_plan.json\ncat full_plan.json | jq -r '{target: .target, testplan: {branch: .testplan.branch, sdkVersion: .testplan.sdkVersion, testcases: [.testplan.testcases[] | select(.category | startswith(\"Config\"))] }}' > filtered_plan.json\ncat filtered_plan.json | nts run \n\n## built-in filtering command\nnts get-plan --save-to full_plan.json\nnts filter --help\nnts filter --names AUDIO-001-TC1 < full_plan.json > filtered_plan.json\nnts filter --names AUDIO-001-TC1 --testplan full_plan.json --save-to filtered_plan.json\nnts filter --names-re \"AUDIO.*TC3\" full_plan.json --save-to filtered_plan.json\nnts get-plan | nts filter --eyepatch --tags batch | nts run\n\n## DIY Filtering using external tools, if you -really- want to\nCURRENT_EPOCH=$(date +%s) \nnts get-plan | jq -r '{target: .target, testplan: {branch: .testplan.branch, sdkVersion: .testplan.sdkVersion, testcases: [.testplan.testcases[] | select(.category | startswith(\"Config\"))] }}' | nts run 2>${CURRENT_EPOCH}.stderr.txt > ${CURRENT_EPOCH}.json \n```\n\n#### Features\n\n* JSON goes to stdout, logging goes to stderr: `nts get-devices > device_list.json`\n* Typical shell exit codes for commands, mean you can use shell checks such as: `nts get-devices || echo FAIL`\n* Multi-OS, multi-shell compatible\n* Tab completion available (see `nts completion show --help`)\n* Available via PYPI, using standard versioning\n\n\n## Alternative Installs\n\n#### Pre-release installs:\n\n`pip3 install -U ntscli-client --pre`\n\nIf Netflix posts a pre-release that might include a bug fix specifically for you, you might be asked to try this.\n\n#### Install for any user of the OS (generally discouraged):\n\n`sudo pip3 install -U ntscli-client`\n\nIf you are managing a server that might have lots of users that need the same install, this might be a good solution if you don't prefer\nusing an alternate abstraction such as a virtual environment, conda environment, etc.\n\n### Installing in an isolation environment\n\nPython is well known for isolation environments like virtualenv, conda, pyenv, etc. These all work, and you should have no trouble using these if you prefer.\n",
"bugtrack_url": null,
"license": "",
"summary": "",
"version": "2.1.21",
"project_urls": {
"Homepage": "https://docs.nrd.netflix.com/docs/nrdp/cert/ntscli/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7461a85af5eea16dd65a8142520e7cd48f8738f6d6f3a1b466965e0ca0e28628",
"md5": "31dd6b694601824d3cc4624bc0271b4e",
"sha256": "93131722b808e2c708d52c20a781bece323e4bab6da8a1b0e154f83f467472eb"
},
"downloads": -1,
"filename": "ntscli_client-2.1.21-py3-none-any.whl",
"has_sig": false,
"md5_digest": "31dd6b694601824d3cc4624bc0271b4e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 37025,
"upload_time": "2023-08-02T13:55:41",
"upload_time_iso_8601": "2023-08-02T13:55:41.445486Z",
"url": "https://files.pythonhosted.org/packages/74/61/a85af5eea16dd65a8142520e7cd48f8738f6d6f3a1b466965e0ca0e28628/ntscli_client-2.1.21-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-02 13:55:41",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ntscli-client"
}