コード例 #1
0
 def get_distant_shell(self, io_handler):
     """
     :return: ascii table with columns : peer UID, Next Hop, Metric
     """
     table = []
     for i in self.get_json_routing():
         table.append((
             i,
             self.get_json_routing()[i],
             self.get_json_next_hop()[i]
         ))
     io_handler.write_line(ShellUtils.make_table(("Peer UID", "Metric", "Next Hop"), table))
コード例 #2
0
 def get_neighbours_shell(self, io_handler):
     """
     :return: ascii table with columns : Neighbour UID, Metric, Router?
     """
     table = []
     for i in self.get_json_neighbours():
         table.append((
             i,
             self.get_json_neighbours()[i],
             i in self._hellos.get_neighbours_routers()
         ))
     io_handler.write_line(ShellUtils.make_table(("Neighbour UID", "Metric", "Router?"), table))
コード例 #3
0
 def get_bundle_detail(self, bundle_number):
     """
     Returns details about the identified instance
     """
     details = {}        
     try:
         bundle_id = int(bundle_number)            
     except ValueError as ex:
         return {"error" : str(ex)}
     else:
         # Integer ID
         try:
             bundle = self._context.get_bundle(bundle_id)
         except:
             return {}
     if bundle is None:
         return {}
     else:
         details = {
             "id": bundle.get_bundle_id(),
             "name" : bundle.get_symbolic_name(),
             "version" : bundle.get_version(),
             "state" : ShellUtils.bundlestate_to_str(
                                 bundle.get_state()),
             "location" : bundle.get_location(),
             "published-services" : [],
             "used-services" : [],
         }                   
         try:
             services = bundle.get_registered_services()
             if services:
                 details["published-services"] = [ str(svc_ref) for svc_ref in services ]                    
             else:
                 pass
         except pelix.constants.BundleException as ex:
             # Bundle in a invalid state
             pass
         try:
             services = bundle.get_services_in_use()
             if services:
                 details["used-services"] = [ str(svc_ref) for svc_ref in services ]                         
             else:
                 pass
         except pelix.constants.BundleException as ex:
             # Bundle in a invalid state
             pass
         
         return details
コード例 #4
0
 def get_bundles(self):
     """
     Returns the list of isolate bundles
     """
     bundles = self._context.get_bundles()
     bundles.insert(0, self._context.get_bundle(0))
     
     return [
         { 
           "id" : bundle.get_bundle_id(),
           "name" : bundle.get_symbolic_name(),
           "state" : ShellUtils.bundlestate_to_str(
                                 bundle.get_state()),
           "version" : bundle.get_version()
         } for bundle in bundles              
     ]