-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from akarneliuk/0.8.3
0.8.3
- Loading branch information
Showing
13 changed files
with
206 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"""This example shows how to authenticate against the device | ||
using token instead of username/password""" | ||
# Modules | ||
from pygnmi.client import gNMIclient | ||
|
||
# Variables | ||
from inventory import hosts | ||
|
||
# Body | ||
if __name__ == "__main__": | ||
|
||
# Get Token | ||
with open("token.tok") as f: | ||
TOKEN = f.read().strip('\n') | ||
|
||
for host in hosts: | ||
with gNMIclient(target=(host["ip_address"], host["port"]), | ||
token=TOKEN, skip_verify=False) as gc: | ||
|
||
result = gc.capabilities() | ||
|
||
print(f"{host['ip_address']}: {result}\n\n") |
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
examples/pure_python/subscribe_with_history_extension_1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""This example shows how to use the History extension | ||
with range option | ||
Per GNMI spec, /extension/history/range requires | ||
`STREAM` mode of telemetery subscription""" | ||
# Modules | ||
from pygnmi.client import gNMIclient | ||
|
||
|
||
# Variables | ||
TELEMETRY_REQUEST2 = { | ||
'subscription': [ | ||
{ | ||
'path': 'openconfig:/interfaces/interface/state/counters', | ||
'mode': 'target_defined' | ||
} | ||
], | ||
'mode': 'stream', | ||
'encoding': 'proto' | ||
} | ||
|
||
EXTENSION2 = { | ||
'history': { | ||
'range': { | ||
'start': '2022-07-23T09:47:00Z', | ||
'end': '2022-07-24T8:57:00Z' | ||
} | ||
} | ||
} | ||
|
||
|
||
# Body | ||
with open("token.tok") as f: | ||
TOKEN = f.read().strip('\n') | ||
|
||
with gNMIclient(target=('192.168.0.5', '443'), token=TOKEN, skip_verify=True) as gconn: | ||
for item in gconn.subscribe2(subscribe=TELEMETRY_REQUEST2, target="leaf1", extension=EXTENSION2): | ||
print(item) |
35 changes: 35 additions & 0 deletions
35
examples/pure_python/subscribe_with_history_extension_2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""This example shows how to use the History extension | ||
with snapshit_time option. | ||
Per GNMI spec, /extension/history/snapshot_time requires | ||
`ONCE` mode of telemetery subscription""" | ||
# Modules | ||
from pygnmi.client import gNMIclient | ||
|
||
|
||
# Variables | ||
|
||
TELEMETRY_REQUEST1 = { | ||
'subscription': [ | ||
{ | ||
'path': 'openconfig:/interfaces/interface[name=Ethernet2]/state/counters', | ||
'mode': 'target_defined' | ||
} | ||
], | ||
'mode': 'once', | ||
'encoding': 'proto' | ||
} | ||
|
||
EXTENSION1 = { | ||
'history': { | ||
'snapshot_time': '2022-07-24T8:57:00Z' | ||
} | ||
} | ||
|
||
# Body | ||
with open("token.tok") as f: | ||
TOKEN = f.read().strip('\n') | ||
|
||
with gNMIclient(target=('192.168.0.5', '443'), token=TOKEN, skip_verify=True) as gconn: | ||
for item in gconn.subscribe2(subscribe=TELEMETRY_REQUEST1, target="leaf1", extension=EXTENSION1): | ||
print(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.