NETCONF 세션에서 운영 정보 요청에 대한 출력 형식 지정
NETCONF 세션에서 Junos 장비에 대한 정보를 요청하기 위해 클라이언트 애플리케이션은 Junos XML 요청 태그 요소를 포함하는 요소를 내보 <rpc>
내는 것입니다. NETCONF 서버가 출력을 특정 형식으로 반환하도록 요청하려면 클라이언트 애플리케이션은 오프닝 운영 요청 태그에 옵션 format
속성을 포함합니다. 이 애플리케이션은 XML(Extensible Markup Language)태그 형식, JSON(JavaScript Object Notation) 또는 형식화된 ASCII 텍스트로 출력을 요청할 수 있습니다. 구문은 다음과 같습니다.
<rpc> <operational-request format="(ascii | json | json-minified | text | xml | xml-minified)"> <!-- tag elements for options --> </operational-request> </rpc>
표 1 은 사용 가능한 형식을 설명합니다. 최소 형식으로 공간, 탭, 새라인 등 컴퓨터 처리에 필요하지 않은 문자를 제거합니다. 최소 형식은 데이터 크기를 줄이고 결과적으로 전송 비용과 데이터 전송 및 처리 시간을 줄일 수 있습니다.
format 속성 가치 |
설명 |
---|---|
ascii |
형식화된 ASCII 텍스트 |
json |
JSON(JavaScript Object Notation) |
json-minified |
불필요한 공간, 탭 및 새로운 라인이 제거된 JSON 형식 |
text |
형식화된 ASCII 텍스트 |
xml |
Junos XML 태그 형식 |
xml-minified |
불필요한 공간, 탭 및 새로운 라인이 제거된 Junos XML 태깅 형식 |
XML 형식
기본적으로 NETCONF 서버는 운영 정보를 XML 형식으로 반환합니다. 속성이 format
설정 xml
되거나 속성이 생략된 경우 format
서버는 XML로 응답을 반환합니다. 다음 예제에서는 ge-0/3/0 인터페이스에 대한 정보를 요청하고 속성을 생략합니다 format
.
<rpc> <get-interface-information> <brief/> <interface-name>ge-0/3/0</interface-name> </get-interface-information> </rpc> ]]>]]>
NETCONF 서버는 필터를 운영 모드 명령에 추가 | display xml
하면 CLI에 표시되는 출력과 동일한 XML 형식으로 정보를 반환합니다.
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/11.4R1/junos"> <interface-information xmlns="http://xml.juniper.net/junos/11.4R1/junos-interface" junos:style="brief"> <physical-interface> <name>ge-0/3/0</name> <admin-status junos:format="Enabled">up</admin-status> <oper-status>down</oper-status> <link-level-type>Ethernet</link-level-type> <mtu>1514</mtu> <source-filtering>disabled</source-filtering> <speed>1000mbps</speed> <bpdu-error>none</bpdu-error> <l2pt-error>none</l2pt-error> <loopback>disabled</loopback> <if-flow-control>enabled</if-flow-control> <if-auto-negotiation>enabled</if-auto-negotiation> <if-remote-fault>online</if-remote-fault> <if-device-flags> <ifdf-present/> <ifdf-running/> <ifdf-down/> </if-device-flags> <if-config-flags> <iff-hardware-down/> <iff-snmp-traps/> <internal-flags>0x4000</internal-flags> </if-config-flags> <if-media-flags> <ifmf-none/> </if-media-flags> </physical-interface> </interface-information> </rpc-reply> ]]>]]>
운영 명령 RPC는 또한 불필요한 공간, 탭 및 새라인을 생략하는 최소 형식으로 반환되는 XML 출력을 지원합니다. 지원되는 릴리스에서 최소 XML 출력을 요청하려면 오프닝 요청 태그에 속성을 포함 format="xml-minified"
하십시오. 예를 들어:
<rpc> <get-interface-information format="xml-minified"> <brief/> <interface-name>ge-0/3/0</interface-name> </get-interface-information> </rpc> ]]>]]>
NETCONF 서버는 정보를 최소 XML 형식으로 반환합니다.
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/21.1R1/junos"> <interface-information xmlns="http://xml.juniper.net/junos/21.1R1/junos-interface" junos:style="brief"><physical-interface><name>ge-0/3/0</name><admin-status junos:format="Enabled">up</admin-status><oper-status>down</oper-status><link-level-type>Ethernet</link-level-type><mtu>1514</mtu><source-filtering>disabled</source-filtering><speed>1000mbps</speed><bpdu-error>none</bpdu-error><l2pt-error>none</l2pt-error><loopback>disabled</loopback><if-flow-control>enabled</if-flow-control><if-auto-negotiation>enabled</if-auto-negotiation><if-remote-fault>online</if-remote-fault><if-device-flags><ifdf-present/><ifdf-running/><ifdf-down/></if-device-flags><if-config-flags><iff-hardware-down/><iff-snmp-traps/><internal-flags>0x4000</internal-flags></if-config-flags><if-media-flags><ifmf-none/></if-media-flags></physical-interface></interface-information></rpc-reply>]]>]]>
JSON 형식
Junos OS 릴리스 14.2부터 운영 및 구성 데이터를 JSON 형식으로 표시할 수 있습니다. NETCONF 서버가 운영 정보를 JSON 형식으로 반환하도록 요청하려면 클라이언트 애플리케이션은 오프닝 운영 요청 태그의 속성을 포함합니다 format="json"
.
<rpc> <get-interface-information format="json"> <brief/> <interface-name>cbp0</interface-name> </get-interface-information> </rpc> ]]>]]>
클라이언트 애플리케이션이 요청 태그에 format="json"
속성을 포함하면 NETCONF 서버는 JSON을 사용하여 응답 형식을 지정합니다.
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/16.1R1/junos"> { "interface-information" : [ { "attributes" : {"xmlns" : "http://xml.juniper.net/junos/16.1R1/junos-interface", "junos:style" : "brief" }, "physical-interface" : [ { "name" : [ { "data" : "cbp0" } ], "admin-status" : [ { "data" : "up", "attributes" : {"junos:format" : "Enabled"} } ], "oper-status" : [ { "data" : "up" } ], "if-type" : [ { "data" : "Ethernet" } ], "link-level-type" : [ { "data" : "Ethernet" } ], "mtu" : [ { "data" : "1514" } ], "speed" : [ { "data" : "Unspecified" } ], "clocking" : [ { "data" : "Unspecified" } ], "if-device-flags" : [ { "ifdf-present" : [ { "data" : [null] } ], "ifdf-running" : [ { "data" : [null] } ] } ], "ifd-specific-config-flags" : [ { "internal-flags" : [ { "data" : "0x0" } ] } ], "if-config-flags" : [ { "iff-snmp-traps" : [ { "data" : [null] } ] } ] } ] } ] } </rpc-reply> ]]>]]>
Junos OS 릴리스 17.3R1부터 Junos OS를 실행하는 디바이스는 여러 값이 있는 객체만 JSON 어레이로 방출되는 컴팩트한 JSON 형식으로 디바이스의 작동 상태를 내보입니다. 컴팩트한 JSON 형식을 내보내도록 디바이스를 구성하려면 계층 수준에서 명령문을 [edit system export-format state-data json]
구성 compact
하십시오.
운영 명령 RPC는 또한 불필요한 공간, 탭 및 새라인을 생략하는 최소 형식으로 반환되는 JSON 출력을 지원합니다. 지원되는 릴리스에서 최소 JSON 출력을 요청하려면 오프닝 요청 태그에 속성을 포함 format="json-minified"
하십시오. 예를 들어:
<rpc> <get-interface-information format="json-minified"> <brief/> <interface-name>cbp0</interface-name> </get-interface-information> </rpc> ]]>]]>
NETCONF 서버는 정보를 최소 JSON 형식으로 반환합니다.
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/21.1R1/junos"> {"interface-information":[{"physical-interface":[{"name":[{"data":"cbp0"}],"admin-status":[{"data":"up","attributes":{"junos:format":"Enabled"}}],"oper-status":[{"data":"up"}],"if-type":[{"data":"Ethernet"}],"link-level-type":[{"data":"Ethernet"}],"mtu":[{"data":"9192"}],"speed":[{"data":"Unspecified"}],"clocking":[{"data":"Unspecified"}],"if-device-flags":[{"ifdf-present":[{"data":[null]}],"ifdf-running":[{"data":[null]}]}],"ifd-specific-config-flags":[{}],"if-config-flags":[{"iff-snmp-traps":[{"data":[null]}]}]}]}]}</rpc-reply> ]]>]]>
ASCII 형식
NETCONF 서버가 Junos XML 태그 요소로 태그를 지정하는 대신 형식의 ASCII 텍스트로 운영 정보를 반환하도록 요청하려면 클라이언트 애플리케이션은 오프닝 요청 태그에 해당 또는 format="ascii"
속성을 포함합니다format="text"
.
<rpc> <get-interface-information format="(text | ascii)"> <brief/> <interface-name>ge-0/3/0</interface-name> </get-interface-information> </rpc> ]]>]]>
클라이언트 애플리케이션이 요청 태그에 속성 또는 format="ascii"
기능을 포함 format="text"
하면 NETCONF 서버는 회신을 ASCII 텍스트로 포맷하고 이를 태그 요소에 <output>
동봉합니다. 및 format="ascii"
속성은 format="text"
동일한 출력을 생성합니다.
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/11.4R1/junos"> <output> Physical interface: ge-0/3/0, Enabled, Physical link is Down Link-level type: Ethernet, MTU: 1514, Speed: 1000mbps, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online Device flags : Present Running Down Interface flags: Hardware-Down SNMP-Traps Internal: 0x4000 Link flags : None </output> </rpc-reply> ]]>]]>
다음 예제에서는 CLI에서 실행되는 동급 운영 모드 명령을 보여줍니다.
user@host> show interfaces ge-0/3/0 brief Physical interface: ge-0/3/0, Enabled, Physical link is Down Link-level type: Ethernet, MTU: 1514, Speed: 1000mbps, Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online Device flags : Present Running Down Interface flags: Hardware-Down SNMP-Traps Internal: 0x4000 Link flags : None
NETCONF 서버에서 반환된 형식의 ASCII 텍스트는 '<'(기호에 미치지 못함), '>'(기호보다 큰 것) 및 '&'(ampersand)와 같이 출력이 허용되지 않는 경우를 제외하고 CLI 출력과 동일합니다. NETCONF 서버는 이러한 문자를 각각 '<', '>', '&'의 동급 사전 정의된 엔티티 참조로 대체합니다.
Junos XML API가 클라이언트 애플리케이션에서 요청하는 출력 유형에 대한 응답 태그 요소를 정의하지 않는 경우, XML 태그 출력이 요청되더라도 NETCONF 서버는 태그 요소에 <output>
동봉된 형식의 ASCII 텍스트로 회신을 반환합니다.
태그 요소 내 <output>
의 데이터의 컨텐트와 형식은 변경될 수 있으므로 클라이언트 애플리케이션은 데이터에 의존해서는 안 됩니다.