Module: Netconf::Format
- Defined in:
- lib/util/client/netconf/netconf_client.rb
Overview
Module that contains frequently used Netconf XML format strings, and helper functions for building up properly formatted Netconf frames
Constant Summary collapse
- DEFAULT_NAMESPACE =
"\"urn:ietf:params:xml:ns:netconf:base:1.0\""
- HELLO =
"<hello xmlns=#{DEFAULT_NAMESPACE}>" \ " <capabilities>\n" \ " <capability>urn:ietf:params:netconf:base:1.1</capability>\n" \ " </capabilities>\n" \ "</hello>\n" \ "]]>]]>\n"
Class Method Summary collapse
- .format_close_session(message_id) ⇒ Object
- .format_commit_msg(message_id) ⇒ Object
- .format_edit_config_msg(message_id, default_operation, target, config) ⇒ Object
- .format_edit_config_msg_with_config_tag(message_id, default_operation, target, config) ⇒ Object
- .format_get_config_all_msg(message_id) ⇒ Object
- .format_get_config_msg(message_id, nc_filter) ⇒ Object
- .format_get_msg(message_id, nc_filter) ⇒ Object
- .format_msg(body) ⇒ Object
Class Method Details
.format_close_session(message_id) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/util/client/netconf/netconf_client.rb', line 105 def self.format_close_session() body = "<rpc message-id=\"#{}\" xmlns=#{DEFAULT_NAMESPACE}>\n" \ " <close-session/>\n" \ " </rpc>\n" format_msg(body) end |
.format_commit_msg(message_id) ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/util/client/netconf/netconf_client.rb', line 113 def self.format_commit_msg() body = "<rpc message-id=\"#{}\" xmlns=#{DEFAULT_NAMESPACE}>\n" \ " <commit/>\n" \ "</rpc>\n" format_msg(body) end |
.format_edit_config_msg(message_id, default_operation, target, config) ⇒ Object
168 169 170 171 |
# File 'lib/util/client/netconf/netconf_client.rb', line 168 def self.format_edit_config_msg(, default_operation, target, config) format_edit_config_msg_with_config_tag(, default_operation, target, "<config xmlns=#{DEFAULT_NAMESPACE}>#{config}</config>") end |
.format_edit_config_msg_with_config_tag(message_id, default_operation, target, config) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/util/client/netconf/netconf_client.rb', line 156 def self.format_edit_config_msg_with_config_tag(, default_operation, target, config) body = "<rpc message-id=\"#{}\" xmlns=#{DEFAULT_NAMESPACE}>\n" \ " <edit-config>\n" \ " <target><#{target}/></target>\n" \ " <default-operation>#{default_operation}</default-operation>\n" \ " #{config}\n" \ " </edit-config>\n" \ "</rpc>\n" format_msg(body) end |
.format_get_config_all_msg(message_id) ⇒ Object
146 147 148 149 150 151 152 153 154 |
# File 'lib/util/client/netconf/netconf_client.rb', line 146 def self.format_get_config_all_msg() body = "<rpc message-id=\"#{}\" xmlns=#{DEFAULT_NAMESPACE}>\n" \ " <get-config>\n" \ " <source><running/></source>\n" \ " </get-config>\n" \ "</rpc>\n" format_msg(body) end |
.format_get_config_msg(message_id, nc_filter) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/util/client/netconf/netconf_client.rb', line 133 def self.format_get_config_msg(, nc_filter) body = "<rpc message-id=\"#{}\" xmlns=#{DEFAULT_NAMESPACE}>\n" \ " <get-config>\n" \ " <source><running/></source>\n" \ " <filter>\n" \ " #{nc_filter}\n" \ " </filter>\n" \ " </get-config>\n" \ "</rpc>\n" format_msg(body) end |
.format_get_msg(message_id, nc_filter) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/util/client/netconf/netconf_client.rb', line 121 def self.format_get_msg(, nc_filter) body = "<rpc message-id=\"#{}\" xmlns=#{DEFAULT_NAMESPACE}>\n" \ " <get>\n" \ " <filter>\n" \ " #{nc_filter}\n" \ " </filter>\n" \ " </get>\n" \ "</rpc>\n" format_msg(body) end |
.format_msg(body) ⇒ Object
101 102 103 |
# File 'lib/util/client/netconf/netconf_client.rb', line 101 def self.format_msg(body) "##{body.length}\n#{body}\n##\n\n" end |