Skip to content

Commit

Permalink
+ pyvyos python sdk improved titles
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoberto committed Dec 15, 2023
1 parent b2c1c8a commit ddc9c32
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/automation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ VyOS Automation
vyos-api
vyos-ansible
vyos-napalm
vyos-pyvyos
vyos-netmiko
vyos-salt
command-scripting
cloud-init
vyos-pyvyos

40 changes: 27 additions & 13 deletions docs/automation/vyos-pyvyos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ You can install PyVyOS using pip:
Getting Started
---------------

### Importing and Disabling Warnings for verify=False
Importing and Disabling Warnings for verify=False
-------------------------------------------------

.. code-block:: none
import urllib3
urllib3.disable_warnings()
### Using API Response Class
Using API Response Class
------------------------

.. code-block:: none
Expand All @@ -41,7 +43,8 @@ Getting Started
result: dict
error: str
### Initializing a VyDevice Object
Initializing a VyDevice Object
------------------------------

.. code-block:: none
Expand All @@ -61,74 +64,85 @@ Getting Started
Using PyVyOS
------------

### Configure, then Set
Configure, then Set
^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none
response = device.configure_set(path=["interfaces", "ethernet", "eth0", "address", "192.168.1.1/24"])
if not response.error:
print(response.result)
### Configure, then Show a Single Object Value
Configure, then Show a Single Object Value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none
response = device.retrieve_return_values(path=["interfaces", "dummy", "dum1", "address"])
print(response.result)
### Configure, then Show Object
Configure, then Show Object
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none
response = device.retrieve_show_config(path=[])
if not response.error:
print(response.result)
### Configure, then Delete Object
Configure, then Delete Object
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none
response = device.configure_delete(path=["interfaces", "dummy", "dum1"])
### Configure, then Save
Configure, then Save
^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none
response = device.config_file_save()
### Configure, then Save File
Configure, then Save File
-------------------------

.. code-block:: none
response = device.config_file_save(file="/config/test300.config")
### Show Object
Show Object
^^^^^^^^^^^^^^

.. code-block:: none
response = device.show(path=["system", "image"])
print(response.result)
### Generate Object
Generate Object
^^^^^^^^^^^^^^^^

.. code-block:: none
randstring = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
keyrand = f'/tmp/key_{randstring}'
response = device.generate(path=["ssh", "client-key", keyrand])
### Reset Object
Reset Object
^^^^^^^^^^^^^^

.. code-block:: none
response = device.reset(path=["conntrack-sync", "internal-cache"])
if not response.error:
print(response.result)
### Configure, then Load File
Configure, then Load File
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: none
response = device.config_file_load(file="/config/test300.config")
. _pyvyos: https://github.com/robertoberto/pyvyos

0 comments on commit ddc9c32

Please sign in to comment.