gNOI 系统服务
总结 使用 gNOI System 服务对目标网络设备执行系统操作,包括重新启动设备、升级软件以及对网络进行故障排除。
概述
gNOI System 服务提供 RPC,用于在网络设备上执行多种不同的系统操作,包括以下操作:
- 重新启动设备
- 执行 ping 和 traceroute 命令以排除网络故障
- 升级软件
- 执行路由引擎切换
proto 定义文件位于 https://github.com/openconfig/gnoi/blob/master/system/system.proto。
如果系统故障,进程 gnoi-system 将重新启动。要手动重新启动,请使用 restart gnoi-system 命令。
网络设备配置
开始之前:
- 按照配置 gRPC 服务中的说明,在网络设备上 配置 gRPC 服务。
- 按照配置 gNOI 服务中的说明,配置网络管理系统以支持 gNOI 操作。
使用 System 服务 RPC 不需要其他配置。
Ping 和 Traceroute
您可以在网络设备上执行 ping 和 traceroute 命令,以排除网络上的问题。
| 版本中引入的 | RPC | 说明 |
|---|---|---|
Ping() |
Ping 设备。 默认数据包数:5 |
Junos OS Evolved 22.2R1 |
Traceroute() |
在目标设备上执行 traceroute 命令并回流式传输结果。 默认跃点计数:30 |
Junos OS Evolved 22.2R1 |
示例:Ping
在此示例中,客户端执行 gnoi_ping_request.py Python 应用程序。应用程序会将 Ping() RPC 发送至网络设备,然后网络设备对指定设备执行 ping 操作。
应用程序gnoi_ping_request.py会导入模块grpc_channel以建立通道。配置 gNOI 服务中介绍了该grpc_channel模块。应用程序的参数存储在 gnoi_ping_request_args.txt 文件中。此处显示应用程序和参数文件。
gnoi_ping_request.py
"""gRPC gNOI ping request utility."""
from __future__ import print_function
import argparse
import logging
from getpass import getpass
import system_pb2
import system_pb2_grpc
from grpc_channel import grpc_authenticate_channel_mutual
def get_args(parser):
parser.add_argument('--server',
dest='server',
type=str,
default='localhost',
help='Server IP or name. Default is localhost')
parser.add_argument('--port',
dest='port',
nargs='?',
type=int,
default=50051,
help='The server port. Default is 50051')
parser.add_argument('--client_key',
dest='client_key',
type=str,
default='',
help='Full path of the client private key. Default ""')
parser.add_argument('--client_cert',
dest='client_cert',
type=str,
default='',
help='Full path of the client certificate. Default ""')
parser.add_argument('--root_ca_cert',
dest='root_ca_cert',
required=True,
type=str,
help='Full path of the Root CA certificate.')
parser.add_argument('--user_id',
dest='user_id',
required=True,
type=str,
help='User ID for RPC call credentials.')
# Ping request arguments
parser.add_argument('--destination',
dest='destination',
type=str,
default=None,
help='Destination IP. Default None')
parser.add_argument('--source',
dest='source',
type=str,
default=None,
help='Source IP. Default None')
parser.add_argument('--count',
dest='count',
type=int,
default=None,
help='Count of packets. Default None')
parser.add_argument('--interval',
dest='interval',
type=int,
default=None,
help='Interval of packets in nanoseconds. Default None')
parser.add_argument('--wait',
dest='wait',
type=int,
default=None,
help='Wait of packets in nanoseconds. Default None')
parser.add_argument('--size',
dest='size',
type=int,
default=None,
help='Size of packets. Default None')
parser.add_argument('--dnfragment',
dest='dnfragment',
type=int,
default=0,
help='Do not fragment. Default 0 (False)')
parser.add_argument('--dnresolve',
dest='dnresolve',
type=int,
default=0,
help='Do not resolve. Default 0 (False)')
parser.add_argument('--l3protocol',
dest='l3protocol',
type=int,
default=None,
help='L3 protocol (1=ipv4,2=ipv6). Default None')
parser.add_argument('--timeout',
dest='timeout',
type=int,
default=30,
help='Timeout for ping. Default: 30 seconds')
args = parser.parse_args()
return args
def send_rpc(channel, metadata, args):
stub = system_pb2_grpc.SystemStub(channel)
print("Executing GNOI::System::Ping Request RPC")
req = system_pb2.PingRequest()
if args.count != None:
req.count = args.count
if args.source != None:
req.source = args.source
if args.destination != None:
req.destination = args.destination
if args.interval != None:
req.interval = args.interval
if args.wait != None:
req.wait = args.wait
if args.size != None:
req.size = args.size
if args.dnfragment != 0:
req.do_not_fragment = args.dnfragment
if args.dnresolve != 0:
req.do_not_resolve = args.dnresolve
if args.l3protocol != None:
req.l3protocol = args.l3protocol
try:
print("Ping Request Response starts\n")
count = 1
for ping in stub.Ping(request=req, metadata=metadata, timeout=args.timeout):
print("Response Source%s: %s " % (count, ping.source))
print("Time%s: %s" % (count, ping.time))
print("Sent%s: %s" % (count, ping.sent))
print("Receive%s: %s" % (count, ping.received))
print("Mintime%s: %s" % (count, ping.min_time))
print("Avgtime%s: %s" % (count, ping.avg_time))
print("Stddev%s: %s" % (count, ping.std_dev))
print("Bytes%s: %s" % (count, ping.bytes))
print("Sequence%s: %s" % (count, ping.sequence))
print("TTL%s: %s" % (count, ping.ttl))
count += 1
print("Ping Request Response ends\n")
except Exception as e:
logging.error('Error: %s', e)
print(e)
def main():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
args = get_args(parser)
grpc_server_password = getpass("gRPC server password for executing RPCs: ")
metadata = [('username', args.user_id),
('password', grpc_server_password)]
try:
# Establish grpc channel to network device
channel = grpc_authenticate_channel_mutual(
args.server, args.port, args.root_ca_cert, args.client_key, args.client_cert)
response = send_rpc(channel, metadata, args)
except Exception as e:
logging.error('Received error: %s', e)
print(e)
if __name__ == '__main__':
logging.basicConfig(filename='gnoi-testing.log',
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
main()
gnoi_ping_request_args.txt
--server=10.0.2.1 --port=50051 --root_ca_cert=/etc/pki/certs/serverRootCA.crt --client_key=/home/lab/certs/client.key --client_cert=/home/lab/certs/client.crt --user_id=gnoi-user --destination=10.0.3.1 --source=10.0.2.1 --count=5
执行应用程序
在客户端上执行应用程序,这将提示服务器密码,获取 RPC 调用凭据。表示 PingResponse 设备发送了五次 ping。最终响应包括 ping 请求的汇总统计信息,其中显示设备发送了 5 次 ping,收到了 5 个响应。
lab@gnoi-client:~/src/gnoi/proto$ python3 gnoi_ping_request.py @gnoi_ping_request_args.txt gRPC server password for executing RPCs: Creating channel Executing GNOI::System::Ping Request RPC Ping Request Response starts Response Source1: 10.0.3.1 Time1: 741000 Sent1: 0 Receive1: 0 Mintime1: 0 Avgtime1: 0 Stddev1: 0 Bytes1: 64 Sequence1: 1 TTL1: 59 Response Source2: 10.0.3.1 Time2: 734000 Sent2: 0 Receive2: 0 Mintime2: 0 Avgtime2: 0 Stddev2: 0 Bytes2: 64 Sequence2: 2 TTL2: 59 Response Source3: 10.0.3.1 Time3: 704000 Sent3: 0 Receive3: 0 Mintime3: 0 Avgtime3: 0 Stddev3: 0 Bytes3: 64 Sequence3: 3 TTL3: 59 Response Source4: 10.0.3.1 Time4: 767000 Sent4: 0 Receive4: 0 Mintime4: 0 Avgtime4: 0 Stddev4: 0 Bytes4: 64 Sequence4: 4 TTL4: 59 Response Source5: 10.0.3.1 Time5: 800000 Sent5: 0 Receive5: 0 Mintime5: 0 Avgtime5: 0 Stddev5: 0 Bytes5: 64 Sequence5: 5 TTL5: 59 Response Source6: 10.0.3.1 Time6: 4111000000 Sent6: 5 Receive6: 5 Mintime6: 704000 Avgtime6: 749000 Stddev6: 32000 Bytes6: 0 Sequence6: 0 TTL6: 0 Ping Request Response ends
重新启动设备
使用 System 服务 RPC 远程重新启动设备,检查重新启动的状态,并根据需要取消重新启动。您可以在设备或特定子组件上执行这些 RPC。Junos 设备支持以下重新启动方法:
-
冷 (1):可用于所有类型的重启。
-
电源关闭 (2):用于 FPC 重新启动。
-
停止 (3):用于主动控制处理器重新启动。
-
POWERUP (7):用于 FPC 重新启动。
| 版本中引入的 | RPC | 说明 |
|---|---|---|
Reboot() |
重新启动目标。一次只能对目标执行一次重新启动请求。 您可以选择配置将来重新启动的延迟,单独重新启动子组件,并在重新启动开始时添加消息。以纳秒为单位配置延迟。 Junos 设备支持以下重新启动方法:
|
Junos OS Evolved 22.2R1 |
RebootStatus() |
返回重新启动的状态。 | Junos OS Evolved 22.2R1 |
CancelReboot() |
取消悬而未决的重新启动请求。 | Junos OS Evolved 22.2R1 |
示例:重新启动
在此示例中,客户端执行 gnoi_reboot_request.py Python 应用程序。应用程序发送重新启动请求,然后检查重新启动的状态。
应用程序允许用户在几秒钟内设置重新启动延迟。由于应用 RebootRequest() 以纳秒为单位来解释延迟,从而将用户输入转换为纳秒的请求。在此示例中,客户端为重新启动操作指定 60 秒的延迟。
应用程序gnoi_reboot_request.py会导入模块grpc_channel以建立通道。配置 gNOI 服务中介绍了该grpc_channel模块。应用程序的参数存储在 reboot_status_request_args.txt 文件中。此处显示应用程序和参数文件。
gnoi_reboot_status_request.py
"""gRPC gNOI reboot request and reboot status utility."""
from __future__ import print_function
import argparse
import logging
from getpass import getpass
import types_pb2
import system_pb2
import system_pb2_grpc
from grpc_channel import grpc_authenticate_channel_mutual
def get_args(parser):
parser.add_argument('--server',
dest='server',
type=str,
default='localhost',
help='Server IP or name. Default is localhost')
parser.add_argument('--port',
dest='port',
nargs='?',
type=int,
default=50051,
help='The server port. Default is 50051')
parser.add_argument('--client_key',
dest='client_key',
type=str,
default='',
help='Full path of the client private key. Default ""')
parser.add_argument('--client_cert',
dest='client_cert',
type=str,
default='',
help='Full path of the client certificate. Default ""')
parser.add_argument('--root_ca_cert',
dest='root_ca_cert',
required=True,
type=str,
help='Full path of the Root CA certificate.')
parser.add_argument('--user_id',
dest='user_id',
required=True,
type=str,
help='User ID for RPC call credentials.')
# Arguments for RebootRequest
parser.add_argument('--method',
dest='method',
type=int,
default=1,
help='Reboot method. Valid value: 0 (UNKNOWN), 1 (COLD), 2 (POWERDOWN), 3 (HALT), 6 (reserved), 7 (POWERUP). Default 1')
parser.add_argument('--delay',
dest='delay',
type=int,
default=None,
help='Delay in seconds before rebooting. Default 0')
parser.add_argument('--message',
dest='message',
type=str,
default=None,
help='Message for rebooting.')
parser.add_argument('--force',
dest='force',
type=int,
default=None,
help='Force reboot. Valid value 0|1. Default 0')
parser.add_argument('--subcomponents',
dest='subcomponents',
type=str,
default='',
help='Subcomponents to reboot. Valid value re0,re1,fpc0,fpc8,etc. Default ""')
args = parser.parse_args()
return args
def send_rpc(channel, metadata, args):
# RebootRequest
stub = system_pb2_grpc.SystemStub(channel)
print("Executing GNOI::System::Reboot RPC")
req = system_pb2.RebootRequest()
# Add RebootRequest arguments
req.method = args.method
if args.delay != None:
# gNOI delay is in nanoseconds. Convert from seconds to nanoseconds.
req.delay = args.delay*(10**9)
if args.message != None:
req.message = args.message
if args.force != None:
req.force = args.force
for subcomponent in args.subcomponents.split(","):
if subcomponent == "":
continue
elem_key = {}
elem_key["%s" % subcomponent] = subcomponent
path_elem = [types_pb2.PathElem(
name="%s" % subcomponent, key=elem_key)]
path = types_pb2.Path(origin="origin", elem=path_elem)
req.subcomponents.extend([path])
# RebootStatus
print("Executing GNOI::System::Reboot Status RPC")
req_status = system_pb2.RebootStatusRequest()
try:
reboot_response = stub.Reboot(
request=req, metadata=metadata, timeout=60)
status_response = stub.RebootStatus(
request=req_status, metadata=metadata, timeout=60)
print("Reboot status response received. %s" % status_response)
except Exception as e:
logging.error('Error: %s', e)
print(e)
else:
logging.info('Received reboot status: %s', status_response)
def main():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
args = get_args(parser)
grpc_server_password = getpass("gRPC server password for executing RPCs: ")
metadata = [('username', args.user_id),
('password', grpc_server_password)]
try:
# Establish grpc channel to network device
channel = grpc_authenticate_channel_mutual(
args.server, args.port, args.root_ca_cert, args.client_key, args.client_cert)
send_rpc(channel, metadata, args)
except Exception as e:
print(e)
logging.error('Received error: %s', e)
if __name__ == '__main__':
logging.basicConfig(filename='gnoi-testing.log',
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
main()
reboot_status_request_args.txt
--server=10.0.2.1 --port=50051 --root_ca_cert=/etc/pki/certs/serverRootCA.crt --client_key=/home/lab/certs/client.key --client_cert=/home/lab/certs/client.crt --user_id=gnoi-user --message="Testing gNOI reboot" --delay=60
执行应用程序
当客户端执行应用程序时,应用程序会提示为 RPC 调用凭据输入服务器密码。然后,应用程序在 60 秒延迟后重新启动服务器,并返回适用的重新启动状态消息。在服务器重新启动之前,也会在服务器上显示下 reason 的消息集。在此示例中,登录到服务器的任何用户都会在重新启动之前看到“测试 gNOI 重新启动”。
lab@gnoi-client:~/src/gnoi/proto$ python3 gnoi_reboot_status_request.py @reboot_status_request_args.txt gRPC server password for executing RPCs: Creating channel Executing GNOI::System::Reboot RPC Executing GNOI::System::Reboot Status RPC Reboot status response received! active: true wait: 59266969677 when: 1651788480000000000 reason: "Testing gNOI reboot" count: 5
升级软件
表 3 列出了支持软件升级的 system.proto RPC。
| 版本中引入的 | RPC | 说明 |
|---|---|---|
SetPackage() |
在目标设备上安装软件映像。 |
Junos OS Evolved 22.2R1 |
您可以使用 RPC 将 SetPackage() 软件映像复制到目标设备并安装它。源软件映像必须位于本地网络管理系统上。如果文件复制操作成功,且目标位置已存在同名文件,则该文件将被覆盖。如果目标位置不存在,或者写入数据时出错,RPC 将返回错误。
默认情况下,SetPackage()不重新启动设备并激活软件。您必须在消息中activateSetPackageRequest将选项显式设置为 1,才能激活新软件。如果激活该软件,设备将重新启动并使用新的软件映像。如果未激活软件,则必须重新启动相关节点以完成安装并激活新软件映像。
示例:安装软件包
在此示例中,客户端会执行 gnoi_system_set_package.py Python 应用程序,该应用程序将执行以下操作:
- 将软件包从本地网络管理系统复制到网络设备。
- 将软件包安装在网络设备上。
- 重新启动网络设备,从而激活新软件映像。
应用程序使用适当的参数构造 SetPackageRequest 消息,以定义复制和安装操作的请求。然后,应用程序调用 SetPackage() RPC,将请求发送至网络设备。消息 SetPackageRequest 包含以下组件:
- 包含软件映像的路径和文件信息的初始
Package消息。参数activate设置为 1 (True),以重新启动设备并激活软件。 - 连续消息中的软件图像文件内容流,不超过 64KB。
- 最后一条消息,带有文件校验和,用于验证文件内容的完整性。
应用程序gnoi_system_set_package.py会导入模块grpc_channel以建立通道。配置 gNOI 服务中介绍了该grpc_channel模块。应用程序参数存储在文件中args_system_set_package.txt。应用程序和参数文件如下所示:
gnoi_system_set_package.py
"""gRPC gNOI OS Upgrade Utility."""
from __future__ import print_function
import argparse
import hashlib
import logging
from functools import partial
from getpass import getpass
import system_pb2
import system_pb2_grpc
from grpc_channel import grpc_authenticate_channel_mutual
MAX_BYTES = 65536
def get_args(parser):
parser.add_argument('--server',
dest='server',
type=str,
default='localhost',
help='Server IP or name. Default is localhost')
parser.add_argument('--port',
dest='port',
nargs='?',
type=int,
default=50051,
help='The server port. Default is 50051')
parser.add_argument('--client_key',
dest='client_key',
type=str,
default='',
help='Full path of the client private key. Default ""')
parser.add_argument('--client_cert',
dest='client_cert',
type=str,
default='',
help='Full path of the client certificate. Default ""')
parser.add_argument('--root_ca_cert',
dest='root_ca_cert',
required=True,
type=str,
help='Full path of the Root CA certificate.')
parser.add_argument('--user_id',
dest='user_id',
required=True,
type=str,
help='User ID for RPC call credentials.')
parser.add_argument('--activate',
dest='activate',
type=int,
default=0,
help='Reboot and activate the package. Default: 0 (Do not reboot/activate). Valid value: 1 (Reboot/activate).')
parser.add_argument('--filename',
dest='filename',
type=str,
default='',
help='Destination path and filename of the package. Default ""')
parser.add_argument('--source_package',
dest='source_package',
type=str,
default='',
help='Full path of the source file to send. Default ""')
parser.add_argument('--timeout',
dest='timeout',
type=int,
default=None,
help='Timeout in seconds.')
parser.add_argument('--version',
dest='version',
type=str,
default='',
help='Version of the package. Default ""')
args = parser.parse_args()
return args
def send_rpc(channel, metadata, args):
stub = system_pb2_grpc.SystemStub(channel)
print("Executing GNOI::System::SetPackage")
# Create request
# Add file information to request
req = system_pb2.SetPackageRequest()
req.package.activate = args.activate
req.package.filename = args.filename
it = []
it.append(req)
# Prepare hash generator
gen_hash = hashlib.sha256()
# Read source package and add to request
with open(args.source_package, "rb") as fd:
# Read data in 64 KB chunks and calculate checksum and data messages
for data in iter(partial(fd.read, MAX_BYTES), b''):
req = system_pb2.SetPackageRequest()
req.contents = data
it.append(req)
gen_hash.update(data)
# Add checksum to request
req = system_pb2.SetPackageRequest()
req.hash.hash = gen_hash.hexdigest().encode()
req.hash.method = 1
it.append(req)
# Install the package
try:
logging.info('Installing package %s', args.source_package)
print('SetPackage start.')
response = stub.SetPackage(
iter(it), metadata=metadata, timeout=args.timeout)
print('SetPackage complete.')
except Exception as e:
logging.error('Software install error: %s', e)
print(e)
else:
logging.info('SetPackage complete.')
return response
def main():
parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
args = get_args(parser)
grpc_server_password = getpass("gRPC server password for executing RPCs: ")
metadata = [('username', args.user_id),
('password', grpc_server_password)]
try:
# Establish grpc channel to network device
channel = grpc_authenticate_channel_mutual(
args.server, args.port, args.root_ca_cert, args.client_key, args.client_cert)
response = send_rpc(channel, metadata, args)
except Exception as e:
logging.error('Error: %s', e)
print(e)
if __name__ == '__main__':
logging.basicConfig(filename='gnoi-install.log',
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
main()
args_system_set_package.txt
--server=10.0.2.1 --port=50051 --root_ca_cert=/etc/pki/certs/serverRootCA.crt --client_key=/home/lab/certs/client.key --client_cert=/home/lab/certs/client.crt --user_id=gnoi-user --activate=1 --filename=/var/tmp/junos-evo-install-ptx-x86-64-22.2R1.13-EVO.iso --source_package=/home/lab/images/junos-evo-install-ptx-x86-64-22.2R1.13-EVO.iso --timeout=1800
执行应用程序
当客户端执行应用程序时,应用程序会将软件包从本地设备复制到网络设备,安装它,然后重新启动设备以完成安装。
lab@gnoi-client:~/src/gnoi/proto$ python3 gnoi_system_set_package.py @args_system_set_package.txt gRPC server password for executing RPCs: Creating channel Executing GNOI::System::SetPackage SetPackage start. SetPackage complete.
路由引擎切换
您可以使用 SwitchControlProcessor() RPC 执行路由引擎切换。
在两个路由引擎出现后,连续路由引擎切换事件之间的间隔必须至少为 400 秒。
| 版本中引入的 | RPC | 说明 |
|---|---|---|
SwitchControlProcessor() |
从当前路由引擎切换到指定的路由引擎。如果当前和指定的路由引擎相同,则为 NOOP。如果目标不存在,RPC 将返回错误。
注意:
Junos 设备不支持 |
Junos OS Evolved 22.2R1 |
示例:路由引擎切换
在此示例中,gNOI 客户端执行 gnoi_system_switch_control_processor.py 应用程序以执行路由引擎切换。客户端通过包括 control_processor 参数来指定哪个交换机控制处理器或路由引擎应是主路由引擎。如果目标路由引擎不存在,RPC 将返回错误 INVALID_ARGUMENT 。
应用程序会导入模块grpc_channel以建立通道。配置 gNOI 服务中介绍了该grpc_channel模块。
gnoi_system_switch_control_processor.py
"""gNOI Routing Engine switchover request utility."""
from __future__ import print_function
import argparse
import logging
from getpass import getpass
import system_pb2
import system_pb2_grpc
import types_pb2
from grpc_channel import grpc_authenticate_channel_mutual
def get_args(parser):
parser.add_argument('--server',
dest='server',
type=str,
default='localhost',
help='Server IP or name. Default is localhost')
parser.add_argument('--port',
dest='port',
nargs='?',
type=int,
default=50051,
help='The server port. Default is 50051')
parser.add_argument('--client_key',
dest='client_key',
type=str,
default='',
help='Full path of the client private key. Default ""')
parser.add_argument('--client_cert',
dest='client_cert',
type=str,
default='',
help='Full path of the client certificate. Default ""')
parser.add_argument('--root_ca_cert',
dest='root_ca_cert',
required=True,
type=str,
help='Full path of the Root CA certificate.')
parser.add_argument('--user_id',
dest='user_id',
required=True,
type=str,
help='User ID for RPC call credentials.')
parser.add_argument('--control_processor',
dest='control_processor',
type=str,
default='re1',
help='Control processor that will assume the role of primary. Default is re1. Valid values are re0,re1.')
args = parser.parse_args()
return args
def send_rpc(channel, metadata, processor):
stub = system_pb2_grpc.SystemStub(channel)
print("Executing GNOI::System::SwitchControlProcessor")
elem_key = {}
elem_key["%s" % processor] = processor
path_elem = [types_pb2.PathElem(name="%s" % processor, key=elem_key)]
path = types_pb2.Path(origin="origin", elem=path_elem)
req = system_pb2.SwitchControlProcessorRequest(control_processor=path)
# Send the request
try:
response = stub.SwitchControlProcessor(
req, metadata=metadata, timeout=60)
print("SwitchControlProcessor response:\n", response)
except Exception as e:
logging.error('Switchover error: %s', e)
print(e)
else:
logging.info('SwitchControlProcessor response:\n %s', response)
return response
def main():
parser = argparse.ArgumentParser()
args = get_args(parser)
grpc_server_password = getpass("gRPC server password for executing RPCs: ")
metadata = [('username', args.user_id),
('password', grpc_server_password)]
try:
# Establish grpc channel to network device
channel = grpc_authenticate_channel_mutual(
args.server, args.port, args.root_ca_cert, args.client_key, args.client_cert)
response = send_rpc(channel, metadata, args.control_processor)
except Exception as e:
logging.error('Received error: %s', e)
print(e)
if __name__ == '__main__':
logging.basicConfig(filename='gnoi-testing.log',
format='%(asctime)s %(levelname)-8s %(message)s',
level=logging.INFO,
datefmt='%Y-%m-%d %H:%M:%S')
main()
执行应用程序
客户端执行应用程序并将参数re1设置为control_processor,以便 re1 成为主要路由引擎。
lab@gnoi-client:~/src/gnoi/proto$ python3 gnoi_system_switch_control_processor.py --server 10.0.2.1 --port 50051 --root_ca_cert /etc/pki/certs/serverRootCA.crt --client_key /home/lab/certs/client.key --client_cert /home/lab/certs/client.crt --user_id gnoi-user --control_processor re1 gRPC server password for executing RPCs: Creating channel Executing GNOI::System::SwitchControlProcessor SwitchControlProcessor response: version: "22.2R1.13-EVO" uptime: 1652478709000000000
执行操作后,re1 是目标设备上的主路由引擎。
{master}
lab@gnoi-server-re1>