Skip to content

Commit 9f8c4a9

Browse files
authored
Merge pull request #51 from QualiSystems/dev
Release 4.0.2
2 parents 2089019 + 8ed7e0c commit 9f8c4a9

6 files changed

Lines changed: 213 additions & 105 deletions

File tree

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
pull_request:
8+
branches:
9+
- "*"
10+
release:
11+
types: [published]
12+
13+
jobs:
14+
tests:
15+
name: Run unit tests
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [2.7, 3.7]
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v2
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install pip -U
30+
pip install tox codecov
31+
- name: Set TOXENV
32+
run: |
33+
python_version="${{ matrix.python-version }}"
34+
py_version="${python_version/./}"
35+
target_branch=${{ github.base_ref || github.ref }}
36+
target_branch=(`[[ ${target_branch::10} == 'refs/heads' ]] && echo ${target_branch:11} || echo $target_branch`)
37+
echo "target_branch =" $target_branch
38+
is_master=(`[[ $target_branch == 'master' ]] && echo 'true' || echo 'false'`)
39+
is_tag=${{ startsWith(github.ref, 'refs/tags') }}
40+
echo "is_master =" $is_master
41+
echo "is_tag =" $is_tag
42+
branch=(`[[ $is_master == 'true' || $is_tag == 'true' ]] && echo 'master' || echo 'dev'`)
43+
TOXENV="py$py_version-$branch"
44+
echo $TOXENV
45+
echo "TOXENV=$TOXENV" >> $GITHUB_ENV
46+
- name: Run tox
47+
run: tox
48+
- name: Upload coverage report
49+
uses: codecov/codecov-action@v1
50+
with:
51+
fail_ci_if_error: true
52+
verbose: true
53+
pre-commit:
54+
name: Run pre-commit
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v2
59+
- name: Set up Python 3.7
60+
uses: actions/setup-python@v2
61+
with:
62+
python-version: 3.7
63+
- name: Install dependencies
64+
run: |
65+
python -m pip install pip -U
66+
pip install tox
67+
- name: Run pre-commit
68+
env:
69+
TOXENV: pre-commit
70+
run: tox
71+
build:
72+
name: Build package
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v2
77+
- name: Set up Python 3.7
78+
uses: actions/setup-python@v2
79+
with:
80+
python-version: 3.7
81+
- name: Install dependencies
82+
run: |
83+
python -m pip install pip -U
84+
pip install tox
85+
- name: Build
86+
env:
87+
TOXENV: build
88+
run: tox
89+
check-version:
90+
name: Check version
91+
# only for PRs in master
92+
if: ${{ github.base_ref == 'master' }}
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v2
97+
- name: Check version
98+
run: |
99+
git clone https://github.com/${{ github.repository }}.git ${{ github.repository }}
100+
cd ${{ github.repository }}
101+
git checkout -qf ${{ github.head_ref }}
102+
! git diff --exit-code --quiet origin/master version.txt
103+
deploy-to-test-pypi:
104+
needs: [tests, pre-commit, build]
105+
if: ${{ github.ref == 'refs/heads/dev' && github.event_name == 'push' }}
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: Checkout code
109+
uses: actions/checkout@v2
110+
- name: Set up Python 3.7
111+
uses: actions/setup-python@v2
112+
with:
113+
python-version: 3.7
114+
- name: Install dependencies
115+
run: |
116+
python -m pip install pip -U
117+
pip install tox
118+
- name: Add id to a package version
119+
run: sed -i -E "s/^([0-9]+\.[0-9]+\.[0-9]+)$/\1.${{ github.run_number }}/" version.txt
120+
- name: Build
121+
env:
122+
TOXENV: build
123+
run: tox
124+
- name: Publish
125+
uses: pypa/gh-action-pypi-publish@v1.4.1
126+
with:
127+
user: __token__
128+
password: ${{ secrets.TEST_PYPI_TOKEN }}
129+
repository_url: https://test.pypi.org/legacy/
130+
create-gh-release:
131+
needs: [tests, pre-commit, build]
132+
if: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' }}
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: Checkout code
136+
uses: actions/checkout@v2
137+
- name: Set up Python 3.7
138+
uses: actions/setup-python@v2
139+
with:
140+
python-version: 3.7
141+
- name: Install dependencies
142+
run: |
143+
python -m pip install pip -U
144+
pip install tox
145+
- name: Build
146+
env:
147+
TOXENV: build
148+
run: tox
149+
- name: Set envs
150+
run: |
151+
version="$(cat version.txt | tr -d ' \t\n\r')"
152+
repo_owner=${{ github.repository }}
153+
index=`expr index "$repo_owner" /`
154+
repo=${repo_owner:index}
155+
echo "TAG=$version" >> $GITHUB_ENV
156+
echo "REPO=$repo" >> $GITHUB_ENV
157+
- name: Create GitHub release
158+
uses: ncipollo/release-action@v1
159+
with:
160+
token: ${{ secrets.GITHUB_TOKEN }}
161+
artifacts: "dist/*"
162+
draft: true
163+
name: ${{ env.REPO }} ${{ env.TAG }}
164+
tag: ${{ env.TAG }}
165+
commit: master
166+
deploy-to-pypi:
167+
needs: [tests, pre-commit, build]
168+
if: startsWith(github.ref, 'refs/tags/')
169+
runs-on: ubuntu-latest
170+
steps:
171+
- name: Checkout code
172+
uses: actions/checkout@v2
173+
- name: Set up Python 3.7
174+
uses: actions/setup-python@v2
175+
with:
176+
python-version: 3.7
177+
- name: Install dependencies
178+
run: |
179+
python -m pip install pip -U
180+
pip install tox
181+
- name: Build
182+
env:
183+
TOXENV: build
184+
run: tox
185+
- name: Publish
186+
uses: pypa/gh-action-pypi-publish@v1.4.1
187+
with:
188+
user: __token__
189+
password: ${{ secrets.PYPI_TOKEN }}

.travis.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# cloudshell-snmp
22

3-
[![Build status](https://travis-ci.org/QualiSystems/cloudshell-snmp.svg?branch=master)](https://travis-ci.org/QualiSystems/cloudshell-snmp)
3+
[![Build status](https://github.com/QualiSystems/cloudshell-snmp/workflows/CI/badge.svg?branch=master)](https://github.com/QualiSystems/cloudshell-snmp/actions?query=branch%3Amaster)
44
[![codecov](https://codecov.io/gh/QualiSystems/cloudshell-snmp/branch/master/graph/badge.svg)](https://codecov.io/gh/QualiSystems/cloudshell-snmp)
5-
[![PyPI version](https://badge.fury.io/py/cloudshell-snmp.svg)](https://badge.fury.io/py/cloudshell-snmp)
5+
[![PyPI version](https://shields.io/pypi/v/cloudshell-snmp)](https://pypi.org/project/cloudshell-snmp)
66
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
77

88
<p align="center">

cloudshell/snmp/snmp_parameters.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,15 @@ def validate(self):
166166
if not self.snmp_user:
167167
raise Exception("SNMPv3 user is not defined")
168168

169-
if self.auth_protocol not in [self.AUTH_NO_AUTH, self.AUTH_MD5, self.AUTH_SHA]:
169+
if self.snmp_auth_protocol not in [
170+
self.AUTH_NO_AUTH,
171+
self.AUTH_MD5,
172+
self.AUTH_SHA,
173+
]:
170174
raise Exception(
171-
"Unknown Authentication Protocol {}".format(self.auth_protocol)
175+
"Unknown Authentication Protocol {}".format(self.snmp_auth_protocol)
172176
)
173-
if self.private_key_protocol not in [
177+
if self.snmp_private_key_protocol not in [
174178
self.PRIV_NO_PRIV,
175179
self.PRIV_DES,
176180
self.PRIV_3DES,
@@ -179,37 +183,40 @@ def validate(self):
179183
self.PRIV_AES256,
180184
]:
181185
raise Exception(
182-
"Unknown Privacy Protocol {}".format(self.private_key_protocol)
186+
"Unknown Privacy Protocol {}".format(self.snmp_private_key_protocol)
183187
)
184188

185189
if (
186-
self.auth_protocol == self.AUTH_NO_AUTH
187-
and self.private_key_protocol != self.PRIV_NO_PRIV
190+
self.snmp_auth_protocol == self.AUTH_NO_AUTH
191+
and self.snmp_private_key_protocol != self.PRIV_NO_PRIV
188192
):
189193
raise Exception(
190194
"{} cannot be used with {}".format(
191-
self.private_key_protocol, self.auth_protocol
195+
self.snmp_private_key_protocol, self.snmp_auth_protocol
192196
)
193197
)
194198

195-
if self.auth_protocol != self.AUTH_NO_AUTH and not self.snmp_password:
199+
if self.snmp_auth_protocol != self.AUTH_NO_AUTH and not self.snmp_password:
196200
raise Exception(
197201
"SNMPv3 Password has to be specified for Authentication "
198-
"Protocol {}".format(self.auth_protocol)
202+
"Protocol {}".format(self.snmp_auth_protocol)
199203
)
200204

201-
if self.private_key_protocol != self.PRIV_NO_PRIV and not self.snmp_private_key:
205+
if (
206+
self.snmp_private_key_protocol != self.PRIV_NO_PRIV
207+
and not self.snmp_private_key
208+
):
202209
raise Exception(
203210
"SNMPv3 Private key has to be specified for Privacy Protocol {}".format(
204-
self.private_key_protocol
211+
self.snmp_private_key_protocol
205212
)
206213
)
207214

208215
def get_valid(self):
209216
self.validate()
210-
if self.private_key_protocol == self.PRIV_NO_PRIV:
217+
if self.snmp_private_key_protocol == self.PRIV_NO_PRIV:
211218
self.snmp_private_key = ""
212-
if self.auth_protocol == self.AUTH_NO_AUTH:
219+
if self.snmp_auth_protocol == self.AUTH_NO_AUTH:
213220
self.snmp_password = ""
214221
return self
215222

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
pycryptodomex<3.10
12
pysnmp>=4.4,<5
23
ipaddress>=1.0.22,<2; python_version <= '2.7'

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.1
1+
4.0.2

0 commit comments

Comments
 (0)