[docs]classVyOSConfigurationEquuleus(VyOSConfiguration):""" Create configuration files for Equuleus-based VyOS routers (1.3.X). """config={}
[docs]defcreate_bgp_neighbors(self,neighbor_info):""" Loop the BGP peer information and create config item objects for each. Arguments: neighbor_info (dict): BGP peer information. Structure defined in comments in set_router_bgp() Returns: list: The list of all neighbors that were created. """neighbors=super().create_bgp_neighbors(neighbor_info)# Loop through all the neighborsforneighborinneighbors:address=VyOSConfigItem("address-family","ipv4-unicast")neighbor.add_children(address)# Create the next-hop parameternext_hop=VyOSConfigItem("nexthop-self")address.add_children(next_hop)# return all the neighbors just createdreturnneighbors
[docs]defcreate_protocols_bgp_redistribute_ospf(self,bgp_config):""" Create the 'redistribution' block that is nested inside of the 'protocols' block. Specifies which BGP links redistribute OSPF information. Arguments: bgp_config (dict): Specifies which BGP links will be redistributing OSPF information. Structure defined in comments of set_router_ospf() Returns: VyOSConfigItem: The "redistribute" configuration item. Raises: IncorrectDefinitionOrderError: Must specify BGP information before specifying redistribution of OSPF on BGP links. """if"redistribution"notinbgp_config:# no redistribution happening, nothing to doreturnprotocols=self.root.find("protocols")ifnotprotocols:raiseIncorrectDefinitionOrderError("Must specify BGP information "+"before specifying redistribution "+"of OSPF on BGP links")bgp=protocols.find("bgp")ifnotbgp:raiseIncorrectDefinitionOrderError("Must specify BGP information "+"before specifying redistribution "+"of OSPF on BGP links")address=VyOSConfigItem("address-family","ipv4-unicast")bgp.add_children(address)redistribute=VyOSConfigItem("redistribute")address.add_children(redistribute)returnredistribute
[docs]@require_class(VyOSRouter)classEquuleus:""" This object provides the VyOS Equuleus 1.3.x image to a VM. """def__init__(self,name=None):""" Initializes the Equuleus object and configures the VM parameters. Arguments: name (str): The name for the router VM. Raises: RuntimeError: If the vertex doesn't have a name. """self.name=getattr(self,"name",name)ifnotnameandnotself.name:raiseRuntimeError("Name must be specified for Equuleus 1.3.x router!")ifname:self.name=nameself.vm=getattr(self,"vm",{})if"architecture"notinself.vm:self.vm["architecture"]="x86_64"if"vcpu"notinself.vm:self.vm["vcpu"]={"model":"qemu64","sockets":1,"cores":1,"threads":1,}if"mem"notinself.vm:self.vm["mem"]=256if"drives"notinself.vm:self.vm["drives"]=[{"db_path":"vyos-equuleus.qc2.xz","file":"vyos-equuleus.qc2"}]if"vga"notinself.vm:self.vm["vga"]="std"self.set_image("vyos-equuleus")self.vyos_config_class=VyOSConfigurationEquuleus()