Skip to content

Instantly share code, notes, and snippets.

@mwiget
Created August 11, 2017 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwiget/10bcb25ef7dd027afe574f4bbddaf9bf to your computer and use it in GitHub Desktop.
Save mwiget/10bcb25ef7dd027afe574f4bbddaf9bf to your computer and use it in GitHub Desktop.
getconfig via grpc response limit
__author__ = ""
__copyright__ = "Copyright (c) 2017 Juniper Networks, Inc."
import os
from grpc.beta import implementations
import op.protos.authentication_service_pb2 as authentication_service_pb2
import op.protos.openconfig_service_pb2 as openconfig_service_pb2
import common.app_globals
import json
channel = implementations.insecure_channel("172.18.0.2", 50051)
stub = authentication_service_pb2.beta_create_Login_stub(channel)
request = authentication_service_pb2.LoginRequest(
user_name="root", password="lutubuheihaegaizeethahni", client_id='me')
login_response = stub.LoginCheck(request, 10)
print "Received response from the LoginCheck: %s" % login_response.result
stub = openconfig_service_pb2.beta_create_OpenconfigRpcApi_stub(channel)
get_request = openconfig_service_pb2.GetRequestList(operation_id="1001", operation=1,
path="/configuration/interfaces")
# path="/configuration/ietf-softwire:softwire-config")
request = openconfig_service_pb2.GetRequest(
request_id=1002, encoding=1, get_request=[get_request])
response = stub.Get(request, common.app_globals.RPC_TIMEOUT_SECONDS)
for rsp in response.response:
print rsp.value
if rsp.response_code == openconfig_service_pb2.OK and rsp.value != "":
print rsp
print "rsp len=%d" % len(rsp.value)
root@f1acf173d6b3:~# python getconfig.py
Received response from the LoginCheck: True
{"configuration": {"interfaces": {"interface": [{"unit": [{"family": {"inet6": {"address": [{"name": "fd00:4601::16/64"}]}, "inet": {"address": [{"name": "172.20.1.16/24"}]}}, "name": 0}], "name": "ge-0/0/0", "mtu": 9000}, {"unit": [{"family": {"inet6": {"address": [{"name": "fd00:4602::16/64"}]}, "inet": {"address": [{"name": "172.20.2.16/24"}]}}, "name": 0}], "name": "ge-0/0/1", "mtu": 9000}, {"unit": [{"family": {"inet6": {"address": [{"name": "fd00:4603::16/64", "ndp": [{"name": "fd00:4603::1", "mac": "02:02:02:02:02:02"}]}]}, "inet": {"address": [{"name": "172.20.3.16/24", "arp": [{"name": "172.20.3.1", "mac": "02:02:02:02:02:02"}]}]}}, "name": 0}], "name": "ge-0/0/2", "mtu": 9000}, {"unit": [{"family": {"inet6": {"address": [{"name": "fd00:4604::16/64", "ndp": [{"name": "fd00:4604::1", "mac": "02:02:02:02:02:02"}]}]}, "inet": {"address": [{"name": "172.20.4.16/24", "arp": [{"name": "172.20.4.1", "mac": "02:02:02:02:02:02"}]}]}}, "name": 0}], "name": "ge-0/0/3", "mtu": 9000}, {"unit": [{"family": {"inet"
operation_id: "1001"
path: "/configuration/interfaces"
value: "{\"configuration\": {\"interfaces\": {\"interface\": [{\"unit\": [{\"family\": {\"inet6\": {\"address\": [{\"name\": \"fd00:4601::16/64\"}]}, \"inet\": {\"address\": [{\"name\": \"172.20.1.16/24\"}]}}, \"name\": 0}], \"name\": \"ge-0/0/0\", \"mtu\": 9000}, {\"unit\": [{\"family\": {\"inet6\": {\"address\": [{\"name\": \"fd00:4602::16/64\"}]}, \"inet\": {\"address\": [{\"name\": \"172.20.2.16/24\"}]}}, \"name\": 0}], \"name\": \"ge-0/0/1\", \"mtu\": 9000}, {\"unit\": [{\"family\": {\"inet6\": {\"address\": [{\"name\": \"fd00:4603::16/64\", \"ndp\": [{\"name\": \"fd00:4603::1\", \"mac\": \"02:02:02:02:02:02\"}]}]}, \"inet\": {\"address\": [{\"name\": \"172.20.3.16/24\", \"arp\": [{\"name\": \"172.20.3.1\", \"mac\": \"02:02:02:02:02:02\"}]}]}}, \"name\": 0}], \"name\": \"ge-0/0/2\", \"mtu\": 9000}, {\"unit\": [{\"family\": {\"inet6\": {\"address\": [{\"name\": \"fd00:4604::16/64\", \"ndp\": [{\"name\": \"fd00:4604::1\", \"mac\": \"02:02:02:02:02:02\"}]}]}, \"inet\": {\"address\": [{\"name\": \"172.20.4.16/24\", \"arp\": [{\"name\": \"172.20.4.1\", \"mac\": \"02:02:02:02:02:02\"}]}]}}, \"name\": 0}], \"name\": \"ge-0/0/3\", \"mtu\": 9000}, {\"unit\": [{\"family\": {\"inet\""
response_code: OK
message: ""
rsp len=1024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment