This function executes the RPC provided as arguments on the junos device. The returned data can be stored in a file. cmd The RPC to be executed dest Destination file where the RPC output is stored. Note that the file will be stored on the proxy minion. To p
(cmd=None, dest=None, **kwargs)
| 295 | |
| 296 | @_timeout_decorator |
| 297 | def rpc(cmd=None, dest=None, **kwargs): |
| 298 | """ |
| 299 | This function executes the RPC provided as arguments on the junos device. |
| 300 | The returned data can be stored in a file. |
| 301 | |
| 302 | cmd |
| 303 | The RPC to be executed |
| 304 | |
| 305 | dest |
| 306 | Destination file where the RPC output is stored. Note that the file |
| 307 | will be stored on the proxy minion. To push the files to the master use |
| 308 | :py:func:`cp.push <salt.modules.cp.push>`. |
| 309 | |
| 310 | format : xml |
| 311 | The format in which the RPC reply is received from the device |
| 312 | |
| 313 | dev_timeout : 30 |
| 314 | The NETCONF RPC timeout (in seconds) |
| 315 | |
| 316 | filter |
| 317 | Used with the ``get-config`` RPC to get specific configuration |
| 318 | |
| 319 | terse : False |
| 320 | Amount of information you want |
| 321 | |
| 322 | interface_name |
| 323 | Name of the interface to query |
| 324 | |
| 325 | CLI Example: |
| 326 | |
| 327 | .. code-block:: bash |
| 328 | |
| 329 | salt 'device' junos.rpc get_config dest=/var/log/config.txt format=text filter='<configuration><system/></configuration>' |
| 330 | salt 'device' junos.rpc get-interface-information dest=/home/user/interface.xml interface_name='lo0' terse=True |
| 331 | salt 'device' junos.rpc get-chassis-inventory |
| 332 | """ |
| 333 | conn = __proxy__["junos.conn"]() |
| 334 | ret = {} |
| 335 | ret["out"] = True |
| 336 | |
| 337 | op = dict() |
| 338 | if "__pub_arg" in kwargs: |
| 339 | if kwargs["__pub_arg"]: |
| 340 | if isinstance(kwargs["__pub_arg"][-1], dict): |
| 341 | op.update(kwargs["__pub_arg"][-1]) |
| 342 | elif "__pub_schedule" in kwargs: |
| 343 | for key, value in kwargs.items(): |
| 344 | if not key.startswith("__pub_"): |
| 345 | op[key] = value |
| 346 | else: |
| 347 | op.update(kwargs) |
| 348 | |
| 349 | if cmd is None: |
| 350 | ret["message"] = "Please provide the rpc to execute." |
| 351 | ret["out"] = False |
| 352 | return ret |
| 353 | |
| 354 | format_ = op.pop("format", "xml") |