File: index.rst

package info (click to toggle)
network-runner 0.3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 700 kB
  • sloc: python: 1,356; makefile: 8; sh: 2
file content (53 lines) | stat: -rw-r--r-- 1,532 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
==========
User guide
==========

Network-Runner can be called directly via python API. This section will
show an example of end users could import the network-runner API and
execute switch level network configuration.

#. In a python environment import the network-runner api module.

    .. code-block:: console

      from network_runner import api

#. Create a Host object and create an Inventory object adding the host object
   to the inventory object. Then instantiate the NetworkRunner class. 

    .. code-block:: console

      from network_runner.models.inventory import Inventory
      from network_runner.models.inventory.hosts import Host

      host = Host(name='testhost',
                  ansible_host='192.168.121.37',
                  ansible_user='root',
                  ansible_ssh_pass='password',
                  ansible_network_os='junos')

      inventory = Inventory()
      inventory.hosts.add(host)

      net_runr = api.NetworkRunner(inventory)

#. Call functions that configure the switch.

    .. code-block:: console

      hostname = 'testhost'
      vlan = 37
      port = 'xe-0/0/7'
      t_vlans = [3,7,73]
      
      # Create a vlan
      net_runr.create_vlan(hostname, vlan)
      # delete a vlan
      net_runr.delete_vlan(hostname, vlan)

      # Configure an access port
      net_runr.conf_access_port(hostname, port, vlan)
      # configure a trunk port
      net_runr.conf_trunk_port(hostname, port, vlan, t_vlans)
      # delete a port
      net_runr.delete_port(hostname, port)