示例#1
0
    def x_synthesize(self, args):
        err = False
        overlay_meta = args.snapshot
        is_zip_contained, url_path = PackagingUtil.is_zip_contained(
            overlay_meta)
        if is_zip_contained is True:
            overlay_meta = url_path
        LOG.info("Beginning synthesis of: %s", args.snapshot)
        try:
            path = synthesis.generate_pidfile(args.title, args.ports)
            synthesis.synthesize(None,
                                 overlay_meta,
                                 disk_only=args.disk_only,
                                 handoff_url=None,
                                 zip_container=is_zip_contained,
                                 title=args.title,
                                 fwd_ports=args.ports)
        except Exception as e:
            LOG.error("Failed to synthesize: %s", str(e))
            err = True
        finally:
            if os.path.exists(path):
                os.unlink(path)

        if err:
            raise Exception(e)
    num_core = 1
    bandwidth = [5, 10, 15, 20, 25, 30, 30]
    bandwidth.reverse()
    #num_cores_list = [4,4,3,2,1]; network_bw = 10

    for (base_path, overlay_path) in workloads:
        for network_bw in bandwidth:
        #for num_core in num_cores_list:
            # confiure network using TC
            cmd = "sudo %s restart %d" % (os.path.abspath("./traffic_shaping"), network_bw)
            LOG.debug(cmd)
            LOG.debug(subprocess.check_output(cmd.split(" ")))
            #VMOverlayCreationMode.USE_STATIC_NETWORK_BANDWIDTH = network_bw

            # generate mode
            VMOverlayCreationMode.LIVE_MIGRATION_STOP = VMOverlayCreationMode.LIVE_MIGRATION_FINISH_USE_SNAPSHOT_SIZE
            overlay_mode = VMOverlayCreationMode.get_pipelined_multi_process_finite_queue(num_cores=num_core)
            overlay_mode.COMPRESSION_ALGORITHM_TYPE = Const.COMPRESSION_GZIP
            overlay_mode.COMPRESSION_ALGORITHM_SPEED = 1
            overlay_mode.MEMORY_DIFF_ALGORITHM = "none"
            overlay_mode.DISK_DIFF_ALGORITHM = "none"

            LOG.debug("network-test\t%s-%s (Mbps)" % (network_bw, num_core))
            is_url, overlay_url = PackagingUtil.is_zip_contained(overlay_path)
            #run_file(base_path, overlay_url, overlay_mode)
            run_network(base_path, overlay_url, overlay_mode)

            time.sleep(30)

        (windows_base_path, mar),
        #(windows_base_path, face),
        #(linux_base_path, moped),
        #(linux_base_path, speech),
        #(linux_base_path, random),
        #(linux_base_path, fluid),
    ]
    for (base_path, overlay_path) in workloads:
        if os.path.exists(base_path) == False:
            raise ProfilingError("Invalid path to %s" % base_path)
        if os.path.exists(overlay_path) == False:
            raise ProfilingError("Invalid path to %s" % overlay_path)

    num_core = 1
    mode_list = profiling_workload(num_core)
    VMOverlayCreationMode.LIVE_MIGRATION_STOP = VMOverlayCreationMode.LIVE_MIGRATION_FINISH_USE_SNAPSHOT_SIZE
    for (base_path, overlay_path) in workloads:
        for each_mode in mode_list:
            # start BW control
            bw_control = NetworkBWcontrol()
            bw_control.start()

            LOG.debug("network-test\tvarying-%s (Mbps)" % (num_core))
            is_url, overlay_url = PackagingUtil.is_zip_contained(overlay_path)
            run_network(base_path, overlay_url, each_mode)

            bw_control.terminate()
            bw_control.join()
            time.sleep(30)