@@ -31,36 +31,14 @@ def call_subprocess(self, command_array):
31
31
raise Exception ("bgpq4 could not be called successfully, this may be an programming error or a bad internet connection." )
32
32
33
33
def call_bgpq4_aspath_access_list (self , asn , irr_name ):
34
- command_array = ["bgpq4" , * self .host_params , "-f " , str (asn ), "-W 100" , "-J" , "-l" , f"AS{ asn } " , irr_name ]
34
+ command_array = ["bgpq4" , * self .host_params , "-H " , str (asn ), "-W 100" , "-J" , "-l" , f"AS{ asn } _ORIGINS " , irr_name ]
35
35
return self .call_subprocess (command_array )
36
36
37
37
def generate_input_aspath_access_list (self , asn , irr_name ):
38
38
# bgpq4 AS-TELIANET-V6 -f 1299 -W 100 -J -l AS1299
39
39
result_str = self .call_bgpq4_aspath_access_list (asn , irr_name )
40
- m = re .search (r'.*as-path-group.*{(.|\n)*?}' , result_str )
41
-
42
- if m :
43
- # Technically, returning m[0] would work, but we do some cleaning for better quality of the generated configuration
44
-
45
- lines = m [0 ].split ("\n " )
46
- new_lines = list ()
47
- indent_count = 0
48
-
49
- for line in lines :
50
- line_without_prefixed_spaces = line .lstrip ()
51
-
52
- if '}' in line_without_prefixed_spaces :
53
- indent_count -= 1
54
-
55
- spaces = [" " for _ in range (indent_count * 4 )]
56
- new_lines .append ("" .join (spaces ) + line_without_prefixed_spaces )
57
-
58
- if '{' in line_without_prefixed_spaces :
59
- indent_count += 1
60
-
61
- return "\n " .join (new_lines )
62
-
63
- return None
40
+ m = re .search (r'.*as-list-group.*{(.|\n)*?}' , result_str )
41
+ return f"as-list AS{ asn } _NEIGHBOR members { asn } ;\n " + m [0 ]
64
42
65
43
def call_bgpq4_prefix_lists (self , irr_name , ip_version ):
66
44
command_array = ["bgpq4" , * self .host_params , f"-{ ip_version } " , "-F" , "%n/%l\n " , irr_name ]
0 commit comments