Exemplo n.º 1
0
 def test(config_name=None, is_export=False):
     if not config_name:
         config_name = 'sample_configs/config_ddflow_demo'
     cfg = Config(folderpath=config_name)
     # graph_gen.create_topo_graph(cfg, is_export)
     Gd = graph_gen.create_device_graph(cfg, is_export)
     Gt = graph_gen.create_task_graph(cfg, is_export)
     ilp_solver.place_things(Gt, Gd, is_export)
Exemplo n.º 2
0
 def update_task_map(self):
     G_map, result_mapping = ilp_solver.place_things(
         self.Gt,
         self.Gd,
         is_export=self.is_export,
         export_suffix=self.update_id)
     self.G_map = G_map
     self.result_mapping = result_mapping
     if self.update_id == 0:
         # init update
         self.init_result_mapping = result_mapping
     log.info('mapping result: {}'.format(result_mapping))
Exemplo n.º 3
0
 def update_task_map(self):
     # result_mapping returns the task to the devices
     # G_map is the updated task graph. Tasks, connectivity of tasks and their attributes (resources, how to invoke)
     G_map, result_mapping = ilp_solver.place_things(
         self.Gt,
         self.Gd,
         is_export=self.is_export,
         export_suffix=self.update_id)
     self.G_map = G_map
     self.result_mapping = result_mapping
     if self.update_id == 0:
         # init update
         self.init_result_mapping = result_mapping
     log.info('mapping result: {}'.format(result_mapping))
Exemplo n.º 4
0
def test_deploy_default(config_name=None, is_export=True):
    if not config_name:
        config_name = _DEFAULT_CONFIG
    # generate input topo, device task data
    Gt = graph_factory.gen_task_graph(config_name, is_export)
    topo_graph, topo_device_graph, Gd = _gen_topo_device_graph(
        config_name, is_export)
    G_map = ilp_solver.place_things(Gt, Gd, is_export)
    # simulate network
    control_plane = ControlPlane(topo_device_graph)
    control_plane.add_manager('HOME_ROUTER.0')
    control_plane.deploy_agent()
    # control_plane.runAgent()
    data_plane = DataPlane(topo_device_graph)
    data_plane.add_manager('HOME_ROUTER.0')
    data_plane.deploy_task(G_map, Gd)
    data_plane.start()
    time.sleep(20)
    # cleanup
    data_plane.stop()
Exemplo n.º 5
0
 def test(config_name=None, is_export=False):
     if not config_name:
         config_name = _DEFAULT_CONFIG
     # generate device graph
     dev_file = FileHelper.gen_config_filepath(config_name, 'device_data')
     nw_file = FileHelper.gen_config_filepath(config_name, 'nw_device_data')
     spec, inventory, links = device_data.import_data(dev_file)
     nw_spec, nw_inventory, nw_links = nw_device_data.import_data(nw_file)
     Gd = device_graph.create_graph(spec, inventory, links, nw_spec,
                                    nw_inventory, nw_links, is_export)
     # generate task graph
     Gt = graph_factory.gen_task_graph(config_name, is_export)
     Gt = ilp_solver.place_things(Gt, Gd, is_export)
     update_id = 0
     # update device graph
     update_id += 1
     log.info('update round {}'.format(update_id))
     suffix = '_update{}'.format(update_id)
     del links['PHONE.0 -> BB_AP.0']
     del links['BB_AP.0 -> PHONE.0']
     links['PHONE.0 -> HOME_IOTGW.0'] = {
         GnInfo.LATENCY: Unit.ms(3),
     }
     links['HOME_IOTGW.0 -> PHONE.0'] = {
         GnInfo.LATENCY: Unit.ms(3),
     }
     Gd = device_graph.create_graph(
         spec,
         inventory,
         links,
         nw_spec,
         nw_inventory,
         nw_links,
         is_export,
         export_suffix='_update{}'.format(update_id))
     Gt = ilp_solver.place_things(Gt, Gd, is_export, export_suffix=suffix)
     # update device graph
     update_id += 1
     log.info('update round {}'.format(update_id))
     suffix = '_update{}'.format(update_id)
     nw_links['BB_SWITCH.0 -> CLOUD_SWITCH.0'][GnInfo.LATENCY] = Unit.sec(5)
     nw_links['CLOUD_SWITCH.0 -> BB_SWITCH.0'][GnInfo.LATENCY] = Unit.sec(5)
     Gd = device_graph.create_graph(spec,
                                    inventory,
                                    links,
                                    nw_spec,
                                    nw_inventory,
                                    nw_links,
                                    is_export,
                                    export_suffix=suffix)
     Gt = ilp_solver.place_things(Gt, Gd, is_export, export_suffix=suffix)
     # update device graph
     update_id += 1
     log.info('update round {}'.format(update_id))
     suffix = '_update{}'.format(update_id)
     del links['PHONE.0 -> HOME_IOTGW.0']
     del links['HOME_IOTGW.0 -> PHONE.0']
     links['PHONE.0 -> BB_AP.0'] = {
         GnInfo.LATENCY: Unit.ms(3),
     }
     links['BB_AP.0 -> PHONE.0'] = {
         GnInfo.LATENCY: Unit.ms(3),
     }
     Gd = device_graph.create_graph(
         spec,
         inventory,
         links,
         nw_spec,
         nw_inventory,
         nw_links,
         is_export,
         export_suffix='_update{}'.format(update_id))
     Gt = ilp_solver.place_things(Gt, Gd, is_export, export_suffix=suffix)
     # update device graph
     update_id += 1
     log.info('update round {}'.format(update_id))
     suffix = '_update{}'.format(update_id)
     nw_links['BB_SWITCH.0 -> CLOUD_SWITCH.0'][GnInfo.LATENCY] = Unit.ms(5)
     nw_links['CLOUD_SWITCH.0 -> BB_SWITCH.0'][GnInfo.LATENCY] = Unit.ms(5)
     Gd = device_graph.create_graph(spec,
                                    inventory,
                                    links,
                                    nw_spec,
                                    nw_inventory,
                                    nw_links,
                                    is_export,
                                    export_suffix=suffix)
     Gt = ilp_solver.place_things(Gt, Gd, is_export, export_suffix=suffix)
Exemplo n.º 6
0
 def test(config_name=None, is_export=False):
     if not config_name:
         config_name = _DEFAULT_CONFIG
     Gt = graph_factory.gen_task_graph(config_name, is_export)
     Gd = graph_factory.gen_device_graph(config_name, is_export)
     ilp_solver.place_things(Gt, Gd, is_export)