[docs]classVyOSConfigurationHelium(VyOSConfiguration):""" Create configuration files for Helium-based VyOS routers (1.1.X). """config={"system_login_level":"admin",}
[docs]defcreate_system_login(self):""" Creates the 'login' block which is nested inside the 'system' block Raises: IncorrectDefinitionOrderError: Must set system hostname before setting the system login. """super().create_system_login()# find the 'user' blockuser=self.root.recursive_find("user")ifnotuser:# 'user' block has not been created and needs to be before moving# forward.raiseIncorrectDefinitionOrderError("Must set user before updating the system login.")# create the 'level' blocklevel=VyOSConfigItem("level",self.config["system_login_level"])user.add_children(level)
[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:# Create the next-hop parameternext_hop=VyOSConfigItem("nexthop-self")neighbor.add_children(next_hop)# return all the neighbors just createdreturnneighbors
[docs]defcreate_ssh_service(self):""" Create 'ssh' block which is nested in the 'service' block Raises: IncorrectDefinitionOrderError: Must set ssh service through the :py:meth:`vyos.VyOSConfiguration.set_service` method. """super().create_ssh_service()ssh=self.root.recursive_find("ssh")ifnotssh:# 'ssh' block has not been created and needs to be before moving# forward.raiseIncorrectDefinitionOrderError("Must create ssh.")allowroot=VyOSConfigItem("allow-root")ssh.add_children(allowroot)
[docs]@require_class(VyOSRouter)classHelium118:""" This object provides the VyOS Helium 1.1.8 image to a VM. """def__init__(self,name=None):""" Initializes the Heium118 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)ifnotself.name:raiseRuntimeError("Name must be specified for Helium 1.1.8 router!")self.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-1.1.8.qc2.xz","file":"vyos-1.1.8.qc2"}]if"vga"notinself.vm:self.vm["vga"]="std"self.set_image("vyos-1.1.8")self.vyos_config_class=VyOSConfigurationHelium()