gns3converter.converter¶
This class is the main gns3-converter class
- class gns3converter.converter.Converter(topology, debug=False)¶
Bases: builtins.object
GNS3 Topology Converter Class
Parameters: - topology (str) – Filename of the ini-style topology
- debug (bool) – enable debugging (Default: False)
- add_node_connection(link, nodes)¶
Add a connection to a node
Parameters: - link (dict) – link definition
- nodes (list) – list of nodes from generate_nodes()
- static convert_destination_to_id(destination_node, destination_port, nodes)¶
Convert a destination to device and port ID
Parameters: - destination_node (str) – Destination node name
- destination_port (str) – Destination port name
- nodes (list) – list of nodes from generate_nodes()
Returns: dict containing device ID, device name and port ID
Return type: dict
- static device_id_from_name(device_name, nodes)¶
Get the device ID when given a device name
Parameters: - device_name (str) – device name
- nodes (list) – list of nodes from generate_nodes()
Returns: device ID
Return type: int
- generate_images(pixmaps)¶
Generate the images list and store the images to copy
Parameters: pixmaps (dict) – A dict of converted pixmaps from the old topology Returns: A list of images Return type: list
- generate_links(nodes)¶
Generate a list of links
Parameters: nodes (list) – A list of nodes from generate_nodes() Returns: list of links Return type: list
- generate_nodes(topology)¶
Generate a list of nodes for the new topology
Parameters: topology (dict) – processed topology from process_topology() Returns: a list of dicts on nodes Return type: list
- static generate_notes(notes)¶
Generate the notes list
Parameters: notes (dict) – A dict of converted notes from the old topology Returns: List of notes for the the topology Return type: list
- static generate_shapes(shapes)¶
Generate the shapes for the topology
Parameters: shapes (dict) – A dict of converted shapes from the old topology Returns: dict containing two lists (ellipse, rectangle) Return type: dict
- static get_node_name_from_id(node_id, nodes)¶
Get the name of a node when given the node_id
Parameters: - node_id (int) – The ID of a node
- nodes (list) – list of nodes from generate_nodes()
Returns: node name
Return type: str
- static get_port_name_from_id(node_id, port_id, nodes)¶
Get the name of a port for a given node and port ID
Parameters: - node_id (int) – node ID
- port_id (int) – port ID
- nodes (list) – list of nodes from generate_nodes()
Returns: port name
Return type: str
- static get_sections(config)¶
Get a list of Hypervisor instances
Parameters: config (ConfigObj) – Configuration from read_topology() Returns: configuration sections Return type: list
- static port_id_from_name(port_name, device_id, nodes)¶
Get the port ID when given a port name
Parameters: - port_name (str) – port name
- device_id (str) – device ID
- nodes (list) – list of nodes from generate_nodes()
Returns: port ID
Return type: int
- process_topology(old_top)¶
Processes the sections returned by get_instances
Parameters: old_top (ConfigObj) – old topology as processed by read_topology() Returns: tuple of dicts containing hypervisors, devices and artwork Return type: tuple
- read_topology()¶
Read the ini-style topology file using ConfigObj
Return config: Topology parsed by ConfigObj Return type: ConfigObj
- topology¶
Return the topology filename the converter is working on
Returns: topology filename Return type: str