AutoNetOps

Cover Image for Sequence Diagram and PlantUML

Sequence Diagram and PlantUML

·

2 min read

What Sequence Diagram is

A visualization of how the system actors interact within the system application.

sequence diagram example

I’ve been looking for a while for a nice and fast way to build some diagrams. After some time looking around I have found this gem that is being very helpful for my usecases. PLANTUML

The best about it, you can build from JSON, YAML, and also ask AI to create a sketch for you so that you don’t need to start from scratch. Also, possible to export to PNG, SVG, PDF.

Whenever I need it, I just pop into the documentation and I will find my way around it.

PlantUML Documentation

To run it, you can the online server but I’ll be leveraging Docker.

docker pull plantuml/plantuml-server

#You can run Plantuml with jetty or tomcat container
docker run -d -p 8080:8080 plantuml/plantuml-server

Some Examples I have quickly generated

A diagram for my classes on building a network device

@startuml

database "DB" #lightblue{

}

class Platform #lightblue{
  - name: str
}

class Layer3Interface {
  - name: str
  - ipv4: ipaddress.IPv4Interface
  - ipv6: ipaddress.IPv6Interface
  - description: str
  - template: str
  + enforce_ipv4(ipv4): cls
}

class Layer2Interface {
  - name: str
  - vlan: List[int]
  - template: str
}

class Communities {
  - name: str
  - template: str
}

class NetDevice {
  - name: str
  - project: str
  - serial: str
  - model: str
  - platform: Platform <<class type>>
  - mgmt: ipaddress.IPv4Interface
  - role: str
  - l2interfaces: List['Layer2Interface'] <<class type>>
  - l3interfaces: List['Layer3Interface'] <<class type>>
  - communities: Communities
  - secrets: dict
}

class Passwords {
  - username
  - password
  - secrets_from_file
  + load_secrets()
}

class NetDeviceBuilder {
  - net_device: Set[NetDevice] <<class type>>
  - load_template: Set[template_names]
  - template
  + get_dev_info_db()
  + load_template_names()
  + build_template()
}

NetDeviceBuilder::build_template "1" -down-> "1" NetDevice : builds
NetDevice::platform "1" --> "1"  Platform: contains
NetDevice::l3interfaces "1" -down- "n" Layer3Interface : contains
NetDevice::l2interfaces "1" -right- "n" Layer2Interface : contains
NetDevice::communities "1" -- "1" Communities : owns
NetDevice::secrets "1" -- "n" Passwords
DB .right. NetDevice::project : loads


@enduml

Jinja2 file diagram

@startuml
package "base" {
    [base.j2]

    package "cisco" {
      package "bgp" {
        [bgp.j2]
        [bgp_ios.j2]
        [bgp_ios_xr.j2]
        [bgp_nxos.j2]
      }
      package "eigrp" {
        [eigrp.j2]
        [eigrp_ios.j2]
        [eigrp_ios_xr.j2]
        [eigrp_nxos.j2]
      }
      package "snmp" {
        [snmp.j2]
        [snmp_ios.j2]
        [snmp_ios_xr.j2]
        [snmp_nxos.j2]
      }
      package "lldp" {
        [lldp.j2]
        [lldp_ios.j2]
        [lldp_ios_xr.j2]
        [lldp_nxos.j2]
      }
    }

    package "juniper" {
      package "bgp" {
        [bgp.j2]
      }
      package "eigrp" {
        [eigrp.j2]
      }
      package "snmp" {
        [snmp.j2]
      }
      package "lldp" {
        [lldp.j2]
      }
    }

    package "arista" {
      package "bgp" {
        [bgp.j2]
      }
      package "eigrp" {
        [eigrp.j2]
      }
      package "snmp" {
        [snmp.j2]
      }
      package "lldp" {
        [lldp.j2]
      }
    }
  }
@enduml