#testing steps for python-etcd3gw focal python version - Python 3.9.7 version tested - python-etcd3gw 0.2.1-3ubuntu1.20.04.1
pull-lp-source python-etcd3gw focal
# generate certs in python-etcd3gw folder openssl req -x509 -keyout localhost.key -newkey rsa:4096 -nodes -sha256 -out localhost.crt
#download etcd binaries & launch etcd locally with TLS enabled wget https://github.com/etcd-io/etcd/releases/download/v3.3.13/etcd-v3.3.13-linux-amd64.tar.gz
tar -zxvf etcd-v3.3.14-linux-amd64.tar.gz
cd etcd-v3.3.14-linux-amd64/
#spin up etcd server ./etcd --name infra0 --data-dir infra0 --cert-file=/python-etcd3gw/localhost.crt --key-file=/python-etcd3gw/localhost.key --advertise-client-urls=https://127.0.0.1:2379 --listen-client-urls=https://127.0.0.1:2379
# test cert connection endpoint curl --cacert localhost.crt --key localhost.key --cert localhost.crt https://127.0.0.1:2379/health
response {"health":"true"}
modify test.py to your config setup for etcd
#run test ./test.py
response success!
# code for test.py touch test.py chmod +rwx test.py
gedit test.py #!/usr/bin/python3
from etcd3gw import Etcd3Client
c = Etcd3Client(host="127.0.0.1", protocol="https", cert_key="localhost.key", cert_cert="localhost.crt", ca_cert="localhost.crt", timeout=10) c.put('test', 'success!') resp = c.get('test') print(b''.join(resp).decode())
#testing steps for python-etcd3gw focal 20.04.1
python version - Python 3.9.7
version tested - python-etcd3gw 0.2.1-3ubuntu1.
pull-lp-source python-etcd3gw focal
# generate certs in python-etcd3gw folder
openssl req -x509 -keyout localhost.key -newkey rsa:4096 -nodes -sha256 -out localhost.crt
#download etcd binaries & launch etcd locally with TLS enabled /github. com/etcd- io/etcd/ releases/ download/ v3.3.13/ etcd-v3. 3.13-linux- amd64.tar. gz
wget https:/
tar -zxvf etcd-v3. 3.14-linux- amd64.tar. gz
cd etcd-v3. 3.14-linux- amd64/
#spin up etcd server file=/python- etcd3gw/ localhost. crt --key-file= /python- etcd3gw/ localhost. key --advertise- client- urls=https:/ /127.0. 0.1:2379 --listen- client- urls=https:/ /127.0. 0.1:2379
./etcd --name infra0 --data-dir infra0 --cert-
# test cert connection endpoint /127.0. 0.1:2379/ health
curl --cacert localhost.crt --key localhost.key --cert localhost.crt https:/
response
{"health":"true"}
modify test.py to your config setup for etcd
#run test
./test.py
response
success!
# code for test.py
touch test.py
chmod +rwx test.py
gedit test.py
#!/usr/bin/python3
from etcd3gw import Etcd3Client
c = Etcd3Client( host="127. 0.0.1", protocol="https", cert_key= "localhost. key", cert_cert= "localhost. crt", ca_cert= "localhost. crt", timeout=10) '.join( resp).decode( ))
c.put('test', 'success!')
resp = c.get('test')
print(b'