]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
location-query: Implement searching for an AS that matches a string
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 14:18:15 +0000 (14:18 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Feb 2018 14:18:15 +0000 (14:18 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/python/location-query.in

index 933024eb1c030adf822238f60571d4bf7c8d7f67..1f1d42ab6df6d5628d446337bd881d9d398ea719 100644 (file)
@@ -65,6 +65,13 @@ class CLI(object):
                get_as.add_argument("asn", nargs="+")
                get_as.set_defaults(func=self.handle_get_as)
 
                get_as.add_argument("asn", nargs="+")
                get_as.set_defaults(func=self.handle_get_as)
 
+               # Search for AS
+               search_as = subparsers.add_parser("search-as",
+                       help=_("Search for Autonomous Systems that match the string"),
+               )
+               search_as.add_argument("query", nargs=1)
+               search_as.set_defaults(func=self.handle_search_as)
+
                return parser.parse_args()
 
        def run(self):
                return parser.parse_args()
 
        def run(self):
@@ -148,6 +155,12 @@ class CLI(object):
 
                return ret
 
 
                return ret
 
+       def handle_search_as(self, ns):
+               for query in ns.query:
+                       # Print all matches ASes
+                       for a in self.db.search_as(query):
+                               print(a)
+
 def main():
        # Run the command line interface
        c = CLI()
 def main():
        # Run the command line interface
        c = CLI()