gRPC エージェント

gRPC エージェント

gRPC エージェントについて

Cisco NX-OS gRPC プロトコルは、ネットワーク デバイスを管理し、その構成データを取得してインストールするためのメカニズムを定義します。プロトコルは、クライアントがデバイス構成を管理するために使用できる完全で正式なアプリケーション プログラミング インターフェイス(API)を公開します。

Cisco NX-OS gRPC プロトコルは、リモート プロシージャ コール(RPC)パラダイムを使用します。このパラダイムでは、外部クライアントが、Google プロトコル バッファ(GPB)で定義された API コールとそのサービス固有の引数を使用してデバイス設定を操作します。これらの GPB 定義 API は、同じ GPB 定義 API コンテキストで応答を返すデバイスへの RPC コールを透過的に引き起こします。

gRPC エージェントは、TLS によるセキュアな転送と、AAA によるユーザー認証と認可を提供します。

Cisco NX-OS gRPC プロトコルの機能上の目的は、特にステートレスとステートフルの両方の構成操作に関して、NETCONF によって提供されるプロトコルをミラーリングして、運用の柔軟性を最大限に高めることです。

Cisco NX-OS gRPC エージェントは、次のプロトコル操作をサポートしています。

  • 結果

  • GetConfig

  • GetOper

  • edit-config

  • start-session

  • CloseSession

  • kill-session

gRPC エージェントは、次の 2 種類の操作をサポートしています:

  • ステートレス操作は、セッションを作成せずに単一のメッセージ内で完全に実行されます。

  • ステートフル操作は、複数のメッセージを使用して実行されます。実行される動作のシーケンスは、次のとおりです:

    1. セッションを開始します。このアクションは、一意のセッション ID を取得します。

    2. セッション ID を使用してセッションタスクを実行します。

    3. セッションを終了します。このアクションにより、セッション ID が無効になります。

次にあるのは、サポートされている操作です。gRPC エージェントによってエクスポートされる .proto ファイルの RPC 定義については、付録を参照してください。

動作

説明

start-session

クライアントとサーバー間の新しいセッションを開始し、一意のセッション ID を取得します。

edit-config

指定された YANG データ サブセットをターゲット データストアに書き込みます。

GetConfig

送信元データストアから指定された YANG 構成データのサブセットを取得します。

GetOper

送信元データストアから指定された YANG 動作データを取得します。

結果

指定された YANG 構成および動作データを送信元データストアから取得します。

KillSession

セッションを強制終了します。

CloseSession

セッションの適切な終了を要求します。

GetConfig、GetOper、および Get はステートレス操作であるため、セッション ID は必要ありません。

EditConfig は、ステートレスまたはステートフルのいずれかです。ステートレス操作の場合は、SessionID を 0 に指定します。ステートフル操作の場合、有効な(ゼロ以外の)SessionID が必要です。

gRPC エージェントは、セッションのタイムアウトをサポートします。セッションのアイドル タイムアウトはデバイスで構成できます。アイドル セッションは終了して削除されます。

gRPC に関する注意事項と制限事項

gRPC エージェントには、次のガイドラインと制限があります。

  • Cisco NX-OS リリース 9.3(3)以降では、カスタム gRPC 証明書を構成している場合、reload ascii コマンドを入力すると構成が失われます。デフォルトの day-1 証明書に戻ります。reload ascii コマンドを入力すると、スイッチがリロードされます。スイッチが再び起動したら、gRPC カスタム証明書を再設定する必要があります。

  • gRPC は、RFC 6536 で指定されている拡張ロールベース アクセス コントロール(RBAC)をサポートしていません。「network-admin」ロールを持つユーザーのみに、gRPC エージェントへのアクセス権が付与されます。

  • Nexus デバイス向けの gRPCトラフィックは、デフォルト クラスのコントロール プレーンポリサー(CoPP)にヒットします。gRPC ドロップの可能性を抑えるには、管理クラスの gRPC 構成ポートを使用して、カスタム CoPP ポリシーを構成してください。

  • NX-OS 9.3(1)以降、gRPC クライアントからスイッチへの gRPCGet および GetConfig 要求には、明示的な名前空間とフィルタが含まれている必要があります。この要件は、OpenConfig YANG およびデバイス モデルへの要求に影響します。次のようなメッセージが表示された場合、要求は名前空間を伝送していません。
    Request without namespace and filter is an unsupported operation

    次の例は、この変更前の動作を使用した Get リクエストと応答を示しています。この例は、サポートされなくなった動作が原因で発生するエラーメッセージを示しています。

    要求:
    client-host % cat payload.json {
    }
    
    応答:
    {"rpc-reply":
        {"rpc-error":{ … Request without filtering is an unsupported operation” …}}
    }
    

    次に、NX-OS リリース 9.3(1)以降での正しい動作の Get リクエストと応答の例を示します。

    要求:
    client-host % cat payload.json {
        "namespace": "http://cisco.com/ns/yang/cisco-nx-os-device",
        "System": {}
    }
    
    応答:
    {"rpc-reply":
        {"data":{"System": ...}}
    }
    

Cisco NX-OS リリース 9.3(3) 以降の gRPC エージェントの構成

gRPC エージェントは、次の構成コマンドをサポートしています。

パラメータ

説明

grpc port

ポート番号を設定します。port-id の範囲は 1024 ~ 65535 です。50051 がデフォルトです。

grpc 証明書

証明書トラストポイント ID を指定します。詳細については、『Cisco Nexus 9000 Series NX-OS Security Configuration Guide, Release 9.3(x)』の「Installing Identity Certificates」セクションを参照してください。https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/93x/security/configuration/guide/b-cisco-nexus-9000-nx-os-security-configuration-guide-93x/b-cisco-nexus-9000-nx-os-security-configuration-guide-93x_chapter_011010.html#task_2088148

(注)  

 

このコマンドは、Cisco NX-OS リリース 9.3(3) 以降で使用できます。

(注)  

 

証明書が無効で、試行に 5 回連続して失敗した場合、サーバは次の syslog で保留状態になります。

2020 May 17 00:35:44 n9k %NXSDK-4-WARNING_MSG: 
grpc (5459) Reached maximal mgt server retry. Verify certificate and port config are valid.

gRPC エージェントは、構成ファイル( /etc/mtx.conf )の [grpc] セクションで次の構成パラメータをサポートします。

パラメータ

説明

idle_timeout

(オプション)アイドル状態のクライアント セッションが切断されるまでのタイムアウトを分単位で指定します。

デフォルトのタイムアウトは 5 分です。

値を 0 に設定するとタイムアウトが無効になります。

limit

(オプション)同時クライアント セッションの最大数を指定します。

デフォルト制限値は 5 セッションです。

範囲は 1 ~ 50 です。

security

セキュアな接続のタイプを指定します。

有効な選択肢は、次のとおりです。

  • TLS の TLS

  • セキュアでない接続の場合は NONE

変更した構成ファイルを有効にするには、次のコマンドを使用して gRPC エージェントを再起動またはリロードする必要があります:

操作

コマンド

エージェントを再起動します

grpcctl restart

または

grpcctl stop

grpcctl start

構成をリロードします

grpcctl reload

証明書について

Cisco NX-OS 9.3(1)を使用した新しいスイッチ展開の場合、スイッチは 1 日限りの一時証明書を生成して、カスタム証明書をインストールするのに十分な時間を許可します。この一時的な 1 日証明書は、Cisco NX-OS の以前のバージョンで生成されたハードコードされたデフォルト証明書を置き換えます。スイッチのリロードまたはシステム スイッチオーバー イベントが発生すると、一時的な 1 日証明書が再生成されます。

たとえば、以前の NX-OS バージョンから NX-OS 9.3(1)にアップグレードする場合など、スイッチにカスタム証明書がすでにインストールされている場合、既存の証明書はアップグレード後も保持され、使用されます。

次に、構成ファイルの [grpc] セクションの例を示します:


[grpc]
mtxadapter=/opt/mtx/lib/libmtxadaptergrpc.1.0.1.so
idle_timeout=10
limit=1
lport=50051
security=TLS
cert=/etc/grpc.pem
key=/etc/grpc.key

Cisco NX-OS リリース 9.3(3) 以降では、 lport=50051 grpc port コマンドに置き換えられました。 cert=/etc/grpc.pem key=/etc/grpc.key は不要になり、 grpc certficate コマンドに置き換えられました。

gRPC の構成

gRPC 機能は、 grpc コマンドを使用して構成します。

コマンドで使用される証明書をスイッチにインポートするには、『Cisco Nexus 9000 Series NX-OS Security Configuration Guide, Release 9.3(x)』の「Installing Identity Certificates」セクションを参照してください。grpc certificate https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/93x/security/configuration/guide/b-cisco-nexus-9000-nx-os-security-configuration-guide-93x/b-cisco-nexus-9000-nx-os-security-configuration-guide-93x_chapter_011010.html#task_2088148


(注)  


インストールされている ID 証明書または と の値を変更すると、gRPC サーバーが再起動して変更が適用される場合があります。grpc port grpc certificate gRPC サーバーが再起動すると、アクティブなサブスクリプションはすべてドロップされるため、再サブスクライブする必要があります。


手順

  コマンドまたはアクション 目的

ステップ 1

configure terminal

例:

switch# configure terminal
switch-1(config)#

グローバル コンフィギュレーション モードを開始します。

ステップ 2

feature grpc

例:

switch# feature grpc
switch-1(config)#

ダイヤルイン用の gNMI インターフェイスをサポートする gRPC エージェントを有効にします。

ステップ 3

grpc port port-id

例:

switch(config)# grpc port 50051

ポート番号を設定します。port-id の範囲は 1024 ~ 65535 です。50051 がデフォルトです。

(注)  

 

このコマンドは、Cisco NX-OS リリース 9.3(3) 以降で使用できます。

ステップ 4

grpc certificate 証明書 ID

例:

switch-1(config)# grpc certificate cert-1

証明書トラストポイント ID を指定します。詳細については、『Cisco Nexus 9000 Series NX-OS Security Configuration Guide, Release 9.3(x)』の「Installing Identity Certificates」セクションを参照してください。https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus9000/sw/93x/security/configuration/guide/b-cisco-nexus-9000-nx-os-security-configuration-guide-93x/b-cisco-nexus-9000-nx-os-security-configuration-guide-93x_chapter_011010.html#task_2088148

(注)  

 

このコマンドは、Cisco NX-OS リリース 9.3(3) 以降で使用できます。

Cisco NX-OS リリース 9.3(2)以前の gRPC エージェントの構成

gRPC エージェントは、構成ファイル( /etc/mtx.conf )の [grpc] セクションで次の構成パラメータをサポートします。

パラメータ

説明

idle_timeout

(オプション)アイドル状態のクライアント セッションが切断されるまでのタイムアウトを分単位で指定します。

デフォルトのタイムアウトは 5 分です。

値を 0 に設定するとタイムアウトが無効になります。

limit

(オプション)同時クライアント セッションの最大数を指定します。

デフォルト制限値は 5 セッションです。

範囲は 1 ~ 50 です。

lport

(任意) gRPC エージェントがリッスンするポート番号を指定します。

デフォルトのポートは 50051 です。

key

TLS 認証のキー ファイルの場所を指定します。

デフォルトの場所は /opt/mtx/etc/grpc.key です。

cert

TLS 認証の認定ファイルの場所を指定します。

デフォルトの場所は /opt/mtx/etc/grpc.pem です。

NX-OS リリース 9.3(1)以降では、gRPC エージェントの証明書にいくつかの変更が加えられています。以下の「証明書について」を参照してください。

security

セキュアな接続のタイプを指定します。

有効な選択肢は、次のとおりです。

  • TLS の TLS

  • セキュアでない接続の場合は NONE

変更した構成ファイルを有効にするには、次のコマンドを使用して gRPC エージェントを再起動またはリロードする必要があります:

操作

コマンド

エージェントを再起動します

grpcctl restart

または

grpcctl stop

grpcctl start

構成をリロードします

grpcctl reload

証明書について

Cisco NX-OS 9.3(1)を使用した新しいスイッチ展開の場合、スイッチは 1 日限りの一時証明書を生成して、カスタム証明書をインストールするのに十分な時間を許可します。この一時的な 1 日証明書は、Cisco NX-OS の以前のバージョンで生成されたハードコードされたデフォルト証明書を置き換えます。スイッチのリロードまたはシステム スイッチオーバー イベントが発生すると、一時的な 1 日証明書が再生成されます。

たとえば、以前の NX-OS バージョンから NX-OS 9.3(1)にアップグレードする場合など、スイッチにカスタム証明書がすでにインストールされている場合、既存の証明書はアップグレード後も保持され、使用されます。

次に、構成ファイルの [grpc] セクションの例を示します:


[grpc]
mtxadapter=/opt/mtx/lib/libmtxadaptergrpc.1.0.1.so
idle_timeout=10
limit=1
lport=50051
security=TLS
cert=/etc/grpc.pem
key=/etc/grpc.key


(注)  


以下の場合、ハードコードされたキーがある場合は、それを削除し、永続的な場所にカスタム キーをインストールする必要があります。
[ハードコードされた証明書の削除(Delete the Hard-Coded Certificate)]

9.3(1)より前のバージョンの NX-OS を使用してスイッチを導入した場合は、ハードコードされた証明書を削除する必要があります。

[証明書の場所を変更します(Change the Certificate Location)]

証明書の以前のデフォルトの場所(/etc/mtx.conf file )は永続的ではなくなりました。

デフォルトでは、/etc/mtx.conf.user ファイルは存在しないため、ファイルを作成し、キーと証明書の新しい場所を指定して、変更を永続的にする必要があります。次に例を示します。
[grpc]
cert="new location"
key="new location"

(注)  


デュアル スーパーバイザ モジュールを搭載したスイッチの場合、証明書ファイルをアップロードし、アクティブ スーパーバイザとスタンバイ スーパーバイザの両方で /etc/mtx.conf.user ファイルを変更する必要があります。両方のスーパーバイザでこれを行わないと、証明書ファイルはスイッチオーバー後に永続的ではありません。
[期限切れの証明書の交換(Replace an Expired Certificate)]

一時的な 1 日証明書の有効期限が切れている場合は、それを削除して新しい証明書に置き換えます。

[構成をリロードします(Reload the Configuration File )]
スイッチをリロードするかどうかに応じて、適切なオプションを使用します:
  • スイッチをリロードせずに新しい証明書を使用するために gRPC エージェントを再起動する場合は、次の手順を実行します:
    1. 証明書とキーを /etc/mtx.conf に追加します。

    2. 変更した構成ファイルを有効にするには、 no feature grpc を発行して gRPC エージェントを無効にしてから、再度有効にするためにfeature grpc を発行します。

  • スイッチをリロードする場合は、/etc/mtx.conf.user を変更するだけで十分です。/etc/mtx.conf を変更する必要はありません。

gRPC エージェントの使用

一般的なコマンド

gRPC エージェントを有効または無効にするには、 [no] feature grpc コマンドを発行します。

一般的なコマンド

gRPC エージェントで使用可能な制御コマンドは次のとおりです。

grpcctl { status | start | restart | reload | stop }

エージェント ステータスの表示


bash-4.2# grpcctl status
xosdsd is stopped
grpcctl is stopped

エージェントの起動


bash-4.2# grpcctl start
Starting Grpc Agent: [OK]

例:JSON フォーマットの基本的な YANG パス


client-host % cat payload.json 
{
  "namespace": "http://cisco.com/ns/yang/cisco-nx-os-device",
  "System": {
    "bgp-items": {
      "inst-items": {
        "dom-items": {
          "Dom-list": {
            "name": "default",
            "rtrId": "7.7.7.7",
            "holdIntvl": "100"
          }
        }
      }
    }
  }
}


(注)  


JSON 構造は、読みやすいように整形されています。


サーバーへの EditConfig 要求の送信


client-host % ./grpc_client -username=admin -password=cisco -operation=EditConfig -e_oper=Merge -def_op=Merge -err_op=stop-on-error -infile=payload.json -reqid=1 -source=running -tls=true -serverAdd=192.0.20.123 -lport=50051

######################################################
Starting the client service
######################################################
TLS set true for client requests1ems.cisco.com
TLS FLAG:1
192.0.20.123:50051
All the client connections are secured
Sending EditConfig request to the server
sessionid is
0
reqid:1
{"rpc-reply":{"ok":""}}

サーバーへの GetConfig 要求の送信


client-host % ./grpc_client -username=admin -password=cisco -operation=GetConfig -infile=payload.json -reqid=1 -source=running -tls=true -serverAdd=192.0.20.123 -lport=50051

######################################################
Starting the client service
######################################################
TLS set true for client requests1ems.cisco.com
TLS FLAG:1
192.0.20.123:50051
All the client connections are secured
Sending GetConfig request to the server 
in get config
Got the response from the server
#########################################
Yang Json is:
#########################################
{"rpc-reply":{"data":{"System":{"bgp-items":{"inst-items":{"dom-items":{"Dom-list":{"name":"default","rtrId":"7.7.7.7","holdIntvl":"100"}}}}}}}}
#########################################
client-host % 

gRPC エージェントのトラブルシューティング

接続のトラブルシューティング

  • クライアント システムから、エージェントがポートでリッスンしていることを確認します。次に例を示します。

    
    client-host % nc –z 192.0.20.222 50051
    Connection to 192.0.20.222 50051 port [tcp/*] succeeded!
    client-host % echo $?
    0
    client-host %
    
    
  • NX-OS で、 を発行して gRPC エージェントのステータスを確認します show feature | grep grpc

gRPC Protobuf ファイル

gRPC エージェントは、/opt/mtx/etc/nxos_grpc.proto にある proto 定義ファイルでサポートされている操作とデータ構造をエクスポートします。ファイルは、gRPC エージェント RPM に含まれています。次に、定義を示します。


// Copyright 2016, Cisco Systems Inc.
// All rights reserved.

syntax = "proto3";

package NXOSExtensibleManagabilityService;

// Service provided by Cisco NX-OS gRPC Agent
service gRPCConfigOper {

    // Retrieves the specified YANG configuration data subset from the
    // source datastore
    rpc GetConfig(GetConfigArgs) returns(stream GetConfigReply) {};

    // Retrieves the specified YANG operational data from the source datastore
    rpc GetOper(GetOperArgs) returns(stream GetOperReply) {};

    // Retrieves the specified YANG configuration and operational data
    // subset from the source datastore
    rpc Get(GetArgs) returns(stream GetReply){};

    // Writes the specified YANG data subset to the target datastore
    rpc EditConfig(EditConfigArgs) returns(EditConfigReply) {};

    // Starts a new session between the client and server and acquires a
    // unique session ID
    rpc StartSession(SessionArgs) returns(SessionReply) {};

    // Requests graceful termination of a session
    rpc CloseSession(CloseSessionArgs) returns (CloseSessionReply) {};

    // Forces the termination of a session
    rpc KillSession(KillArgs) returns(KillReply) {};

// Unsupported; reserved for future
    rpc DeleteConfig(DeleteConfigArgs) returns(DeleteConfigReply) {};

    // Unsupported; reserved for future
    rpc CopyConfig(CopyConfigArgs) returns(CopyConfigReply) {};

    // Unsupported; reserved for future
    rpc Lock(LockArgs) returns(LockReply) {};

    // Unsupported; reserved for future
    rpc UnLock(UnLockArgs) returns(UnLockReply) {};

    // Unsupported; reserved for future
    rpc Commit(CommitArgs) returns(CommitReply) {};

    // Unsupported; reserved for future
    rpc Validate(ValidateArgs) returns(ValidateReply) {};

    // Unsupported; reserved for future
    rpc Abort(AbortArgs) returns(AbortReply) {};

}

message GetConfigArgs
{
    // JSON-encoded YANG data to be retrieved
    string YangPath = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;

    // (Optional) Specifies the source datastore; only "running" is supported.
    // Default is "running".
    string Source = 3;
}

message GetConfigReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // JSON-encoded YANG data that was retrieved
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message GetOperArgs
{
    // JSON-encoded YANG data to be retrieved
    string YangPath = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;
}

message GetOperReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // JSON-encoded YANG data that was retrieved
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message GetArgs
{
    // JSON-encoded YANG data to be retrieved
    string YangPath=1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;
}

message GetReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // JSON-encoded YANG data that was retrieved
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message EditConfigArgs
{
    // JSON-encoded YANG data to be edited
    string YangPath = 1;

    // Specifies the operation to perform on teh configuration datastore with
    // the YangPath data.  Possible values are:
    //   create
    //   merge
    //   replace
    //   delete
    //   remove
    // If not specified, default value is "merge".
    string Operation = 2;

    // A unique session ID acquired from a call to StartSession().
    // For stateless operation, this value should be set to 0.
    int64 SessionID = 3;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 4;

    // (Optional) Specifies the target datastore; only "running" is supported.
    // Default is "running".
    string Target = 5;

    // Specifies the default operation on the given object while traversing
    // the configuration tree.
    // The following operations are possible:
    //   merge:     merges the configuration data with the target datastore;
    //              this is the default.
    //   replace:   replaces the configuration data with the target datastore.
    //   none:      target datastore is unaffected during the traversal until
    //              the specified object is reached.
    string DefOp = 6;

    // Specifies the action to be performed in the event of an error during
    // configuration.  Possible values are:
    //   stop
    //   roll-back
    //   continue
    // Default is "roll-back".
    string ErrorOp = 7;
}

message EditConfigReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If EditConfig is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message DeleteConfigArgs
{
    // A unique session ID acquired from a call to StartSession().
    // For stateless operation, this value should be set to 0.
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;

    // (Optional) Specifies the target datastore; only "running" is supported.
    // Default is "running".
    string Target = 3;
}

message DeleteConfigReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If DeleteConfig is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message CopyConfigArgs
{
    // A unique session ID acquired from a call to StartSession().
    // For stateless operation, this value should be set to 0.
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;

    // (Optional) Specifies the source datastore; only "running" is supported.
    // Default is "running".
    string Source = 3;

    // (Optional) Specifies the target datastore; only "running" is supported.
    // Default is "running".
    string Target = 4;
}

message CopyConfigReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If CopyConfig is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message LockArgs
{
    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID=2;

    // (Optional) Specifies the target datastore; only "running" is supported.
    // Default is "running".
    string Target = 3;
}

message LockReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If Lock is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message UnLockArgs
{
    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;

    // (Optional) Specifies the target datastore; only "running" is supported.
    // Default is "running".
    string Target = 3;
}

message UnLockReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If UnLock is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message SessionArgs
{
    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 1;
}

message SessionReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;
    int64 SessionID = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message CloseSessionArgs
{
    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 1;

    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 2;
}

message CloseSessionReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If CloseSession is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message KillArgs
{
    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 1;

    int64 SessionIDToKill = 2;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 3;
}

message KillReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If Kill is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message ValidateArgs
{
    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;
}

message ValidateReply
{
    // The request ID specified in the request.
    int64 ReqID = 1;

    // If Validate is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message CommitArgs
{
    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;
}

message CommitReply
{
    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 1;

    // If Commit is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

message AbortArgs
{
    // A unique session ID acquired from a call to StartSession().
    int64 SessionID = 1;

    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 2;
}

message AbortReply
{
    // (Optional) Specifies the request ID.  Default value is 0.
    int64 ReqID = 1;

    // If Abort is successful, YangData contains a JSON-encoded "ok" response.
    string YangData = 2;

    // JSON-encoded error information when request fails
    string Errors = 3;
}

エフェメラル データ

gRPC のエフェメラル データについて

Cisco NX-OS リリース 9.3(3) 以降、この機能はエフェメラル データへのアクセスを提供します。エフェメラル データは、大量のデータです。DME は、各バッチがメモリ使用量の観点から管理可能なサイズになるように、データを取得するバッチ メカニズムを提供します。バッチのサイズは、取得する MO の数です。

バッチ処理メカニズムは gRPC を介して公開されません。バッチ処理は内部的に処理されます。gRPC バッチ処理は明示的に使用しません。REST API を介して DME から直接アクセスしようとするときには、バッチ処理を使用できます。

パブリッシュされた YANG ファイルの「Ephemeral data」というコメントで、どのデータがエフェメラルであるかに関する情報を確認できます。

エフェメラル データからの出力は、要求のフィルタが以下を指している場合にのみ返されます。

  • エフェメラル データのリーフ

  • エフェメラル データの子を持つコンテナまたはリスト

  • 直接のエフェメラル データの子を持っていたリストをラップするために使用される空のコンテナ

システム レベルの GET クエリは、エフェメラル データを返しません。

gRPC のエフェメラル データの例

これは、gRPC のエフェメラル データを取得する例です。

ayyim-lnx.cisco.com:200> cat urib.mgmt.json 
{"namespace":"http://cisco.com/ns/yang/cisco-nx-os-device", 
    "System": {
        "urib-items":{
            "table4-items":{
                    "Table4-list":{
         "vrfName":"management",
         "route4-items":{
            "Route4-list":{
            }
         }        
                    }
            }
        }
    }
}

ayyim-lnx.cisco.com:395> ./grpc_client -username=admin -password=C\!sco123 -operation=Get -reqid=1 -serverAdd=172.23.167.216 -lport=50051 -tls=true -infile=payloads/urib.mgmt.json -cafile=grpc.pem.n9kv-blade2

######################################################
Starting the client service
######################################################
TLS set true for client requests1ems.cisco.com
TLS FLAG:1
172.23.167.216:50051
All the client connections are secured
Sending Get request to the server
sending get request
Got the response from the server
#########################################
Yang Json is:
#########################################
{ 
   "rpc-reply" : {
      "data" : {
         "System" : {
            "xmlns" : "http://cisco.com/ns/yang/cisco-nx-os-device",
            "urib-items" : {
               "table4-items" : {
                  "Table4-list" : [
                     {
                        "vrfName" : "management",
                        "route4-items" : {
                           "Route4-list" : [
                              {
                                 "prefix" : "172.23.167.255/32",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.255",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "mgmt0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "broadcast",
                                          "preference" : "0",
                                          "routeType" : "unknown",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:18:18",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "172.23.167.216/32",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.216",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "mgmt0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "local",
                                          "preference" : "0",
                                          "routeType" : "unknown",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:18:18",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "172.23.167.20/32",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.20",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "mgmt0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "am",
                                          "preference" : "250",
                                          "routeType" : "unknown",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:03:06",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "172.23.167.8/32",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.8",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "mgmt0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "am",
                                          "preference" : "250",
                                          "routeType" : "unknown",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:02:23",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "0.0.0.0/0",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.1",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "N/A",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "static",
                                          "preference" : "1",
                                          "routeType" : "",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:18:18",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "172.23.167.0/24",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.216",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "mgmt0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "direct",
                                          "preference" : "0",
                                          "routeType" : "",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:18:18",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "172.23.167.1/32",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.1",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "mgmt0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "am",
                                          "preference" : "250",
                                          "routeType" : "unknown",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:04:07",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              },
                              {
                                 "prefix" : "172.23.167.0/32",
                                 "flags" : "0",
                                 "mBestNextHopCount" : "0",
                                 "nh4-items" : {
                                    "NextHop4-list" : [
                                       {
                                          "id" : "0",
                                          "address" : "172.23.167.0",
                                          "bindinglabel" : "0",
                                          "encapType" : "none",
                                          "interfaceName" : "Null0",
                                          "isBest" : "true",
                                          "metric" : "0",
                                          "owner" : "broadcast",
                                          "preference" : "0",
                                          "routeType" : "unknown",
                                          "segidType" : "null",
                                          "segmentId" : "0",
                                          "tag" : "0",
                                          "tunnelId" : "0",
                                          "uptime" : "00:18:18",
                                          "vrf" : "management"
                                       }
                                    ]
                                 },
                                 "pendingHw" : "false",
                                 "pendingUfdm" : "false",
                                 "sortKey" : "0",
                                 "uBestNextHopCount" : "1"
                              }
                           ]
                        }
                     }
                  ]
               }
            }
         }
      }
   }
}