キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 
cancel
330
閲覧回数
0
いいね!
0
コメント
Akira Iwamoto
Cisco Employee
Cisco Employee

 

はじめに

NSO には種々の Northboundインターフェースが備わっており、それらに関わらずアクセスしたいデータ自体は CDB 上の XML データベースにありますが、アクセス方法はそれぞれについて独自の方法があります。

これまではアクセス方法について、その度に構築する必要がありました。またノードが変わればPrefixやネームスペースも変わり、都度そのモデルを確認する必要がありました。

 

NSO 5.6 では開発時用の機能として、それら生成が動的に行えるようになりましたので、以下紹介致します。

事前準備

開発用機能となり、作業前には以下のように devtools を true へ変更する必要があります。これは当該 CLI セッションにおいてのみ有効です。Configではないため、CLI接続を終了した後再度使用する場合は、このコマンドも再度入力が必要です。

 

admin@ncs# devtool?
Possible completions:
devtools Enable/disable development tools
admin@ncs# devtools true
admin@ncs# 

パイプ機能

devtools が無効状態においても、これまでの NSO にも数々の機能がありました。devtools を true にした場合、以下のものが使用可能となります。

 

admin@ncs# show running-config devices | ?
Possible completions:
  annotation      Show only statements whose annotation matches a pattern
  append          Append output text to a file
  begin           Begin with the line that matches
  best-effort     Display data even if data provider is unavailable or continue loading from file in presence of
                  failures
  context-match   Context match
  count           Count the number of lines in the output
  csv             Show table output in CSV format
  de-select       De-select columns
  details         Display details
  display         Display options
  exclude         Exclude lines that match
  extended        Display referring entries
  hide            Hide display options
  icount          Count the number of matching instances
  include         Include lines that match
  linnum          Enumerate lines in the output
  match-all       All selected filters must match
  match-any       At least one filter must match
  more            Paginate output
  nomore          Suppress pagination
  repeat          Repeat show command with a given interval
  save            Save output text to a file
  select          Select additional columns
  sort-by         Select sorting indices
  tab             Enforce table output
  tags            Show only statements whose tags matches a pattern
  until           End with the line that matches
admin@ncs#

  

中でも、display はConfigの保存などを行う場合にも特に使用されるものでした。

devtools を true へと変更した場合、以下の赤字機能が追加されていることが確認出来ます。

 

admin@ncs# show running-config devices | display ?
Possible completions:
  annotations         Display annotations
  curly-braces        Display output as curly braces
  json                Display output as json
  keypath             Display output as keypath
  maagic              Display output as Python Maagic
  netconf             Display output as a NETCONF request
  prefixes            Display namespace prefixes
  restconf            Display output as restconf path
  service-meta-data   Display service meta information
  tags                Display tags
  xml                 Display output as XML
  xpath               Display output as xpath
admin@ncs#

maagic オプション

maagic オプションを使用すると、以下のような出力となります。通常の show running-config と同様、各leaf 名とその値が表示されますが、leaf 名が python maagic コードで参照するための表記となります。

root 変数は CDB の root ノードを示しており、別の変数を使用する場合などは、適宜変更が必要です。

 

/devices の取得

 

admin@ncs# show running-config devices | display maagic
root.ncs__devices.global-settings.trace-dir ./logs
root.ncs__devices.authgroups.group['default'].umap['admin'].remote-name admin
root.ncs__devices.authgroups.group['default'].umap['admin'].remote-password $9$xKrirS8FHEx495MNpyGDz05cP6hXMhSb8Jw1NZ3lUKU=
root.ncs__devices.authgroups.group['default'].umap['oper'].remote-name oper
root.ncs__devices.authgroups.group['default'].umap['oper'].remote-password $9$2d+P/rCp3sCJ71oCknyX40soO26Fkdr+RxVfa9515k8=
root.ncs__devices.authgroups.snmp-group['default'].default-map
root.ncs__devices.authgroups.snmp-group['default'].default-map.community-name public
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm.remote-name admin
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm.security-level auth-priv
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm.auth
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm.auth.sha.remote-password $9$mfrnZcb2gts2HoPXoUKMSK/umTwz8oK4MZO6HQ1CQso=
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm.priv
root.ncs__devices.authgroups.snmp-group['default'].umap['admin'].usm.priv.aes.remote-password $9$6z1DwC47k6hax0cVLRrAGlLAoCg/fYxOR4GHlyML4Lg=
root.ncs__devices.mib-group['snmp'].mib-module [ SNMP* ]
admin@ncs#

/devices/global-settings/trace への書き込み

admin@ncs(config)# show configuration | display maagic
root = ncs.maagic.get_root(t)
root.ncs__devices.global-settings.trace = 'raw'
admin@ncs(config)#

netconf オプション

netconf オプションを使用した場合は、Leafに設定された値が表示されるのではなく、Netconfでその値を取得するために必要な、Netconf メッセージが表示されます。

/devices の取得

admin@ncs# show running-config devices | display netconf
<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <get-config>
    <source>
      <running/>
    </source>
    <filter>
      <devices xmlns="http://tail-f.com/ns/ncs"/>
    </filter>
  </get-config>
</rpc>
admin@ncs#

xml でそのleaf の値が取得したい場合は、xml オプションを使用します。

admin@ncs# show running-config devices | display xml
<config xmlns="http://tail-f.com/ns/config/1.0">
  <devices xmlns="http://tail-f.com/ns/ncs">
    <global-settings>
      <trace-dir>./logs</trace-dir>
    </global-settings>
    <authgroups>
      <group>
        <name>default</name>
        <umap>
          <local-user>admin</local-user>
          <remote-name>admin</remote-name>
          <remote-password>$9$xKrirS8FHEx495MNpyGDz05cP6hXMhSb8Jw1NZ3lUKU=</remote-password>
        </umap>

/devices/global-settings/trace への書き込み

admin@ncs(config)# show configuration | display netconf
<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <devices xmlns="http://tail-f.com/ns/ncs">
        <global-settings>
          <trace>raw</trace>
        </global-settings>
      </devices>
    </config>
  </edit-config>
</rpc>
admin@ncs(config)#

restconf オプション

restconf オプションを使用すると、それぞれの leaf ノードへの URI と値が表示されます。GET/DELETE で使用する場合は、そのまま使用することも可能です。POST や PATCH を行う場合は、値としてJSONやXML でエンコードする必要があります。

/devices の取得

admin@ncs# show running-config devices | display restconf
/restconf/data/tailf-ncs:devices/global-settings/trace-dir ./logs
/restconf/data/tailf-ncs:devices/authgroups/group=default/umap=admin/remote-name admin
/restconf/data/tailf-ncs:devices/authgroups/group=default/umap=admin/remote-password $9$xKrirS8FHEx495MNpyGDz05cP6hXMhSb8Jw1NZ3lUKU=
/restconf/data/tailf-ncs:devices/authgroups/group=default/umap=oper/remote-name oper
/restconf/data/tailf-ncs:devices/authgroups/group=default/umap=oper/remote-password $9$2d+P/rCp3sCJ71oCknyX40soO26Fkdr+RxVfa9515k8=
set /restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/default-map
/restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/default-map/community-name public
set /restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm
/restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm/remote-name admin
/restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm/security-level auth-priv
set /restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm/auth
/restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm/auth/sha/remote-password $9$mfrnZcb2gts2HoPXoUKMSK/umTwz8oK4MZO6HQ1CQso=
set /restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm/priv
/restconf/data/tailf-ncs:devices/authgroups/snmp-group=default/umap=admin/usm/priv/aes/remote-password $9$6z1DwC47k6hax0cVLRrAGlLAoCg/fYxOR4GHlyML4Lg=
/restconf/data/tailf-ncs:devices/mib-group=snmp/mib-module [ SNMP* ]
admin@ncs#

/devices/global-settings/trace への書き込み

NSO 5.6 では実装されておりません。今後実装される見込みです。

Getting Started

検索バーにキーワード、フレーズ、または質問を入力し、お探しのものを見つけましょう

シスコ コミュニティをいち早く使いこなしていただけるよう役立つリンクをまとめました。みなさんのジャーニーがより良いものとなるようお手伝いします