Ejemplo n.º 1
0
def clone_qcow2_drive(origin_name, clone_name):
    clone_path = os.path.join(config.CLONES_DIR, "%s.qcow2" % clone_name)
    origin_path = os.path.join(config.ORIGINS_DIR, origin_name, "drive.qcow2")

    command = commands.clone_qcow2_drive(origin_path, clone_path)
    system_utils.run_command(command)
    return clone_path
Ejemplo n.º 2
0
def convert_img_to_qcow2_origin(img_file, qcow2_origin_name):
    command = commands.convert_img_to_qcow2(
        img_file, "{origins_dir}/{qcow2_origin_name}.qcow2".format(
            origins_dir=config.ORIGINS_DIR,
            qcow2_origin_name=qcow2_origin_name,
        ))
    system_utils.run_command(command)
Ejemplo n.º 3
0
def copy_files_to_home(home):
    copy = ["/bin/cp", "-r", package_dir() + "home" + os.sep + ".", home]
    return_code, output = run_command(copy)
    if return_code != 0:
        cout("\nFailed to copy files to home dir: %s\n" % home_dir(),
             color=FAIL)
        exit(output)
    chown = ["/bin/chown", "-R", "vmmaster:vmmaster", home]
    return_code, output = run_command(chown)
    if return_code != 0:
        cout("\nFailed to change owner for: %s\n" % home_dir(), color=FAIL)
        exit(output)
    change_user_vmmaster()
Ejemplo n.º 4
0
    def test_file_deletion(self):
        from core.db.models import Session
        session = Session('some_platform')
        session.status = 'unknown'
        session.name = '__test_file_deletion'
        session.save()

        session_dir = os.path.join(config.SCREENSHOTS_DIR, str(session.id))
        system_utils.run_command(["mkdir", config.SCREENSHOTS_DIR],
                                 silent=True)
        system_utils.run_command(["mkdir", session_dir], silent=True)
        system_utils.run_command(
            ["touch", os.path.join(session_dir, "file_for_deletion")],
            silent=True)
        self.cleanup.delete_session_data([session])
        self.assertEqual(os.path.isdir(session_dir), 0)
        system_utils.run_command(["rm", "-rf", config.SCREENSHOTS_DIR],
                                 silent=True)
Ejemplo n.º 5
0
    def test_file_deletion(self):
        self.session.name = '__test_file_deletion'
        self.session.save()

        session_dir = os.path.join(
            config.SCREENSHOTS_DIR, str(self.session.id)
        )
        system_utils.run_command(
            ["mkdir", config.SCREENSHOTS_DIR],
            silent=True)
        system_utils.run_command(
            ["mkdir", session_dir],
            silent=True)
        system_utils.run_command(
            ["touch", os.path.join(session_dir, "file_for_deletion")],
            silent=True)

        self.cleanup.delete_session_data([self.session])
        self.assertEqual(os.path.isdir(session_dir), 0)
        system_utils.run_command(
            ["rm", "-rf", config.SCREENSHOTS_DIR], silent=True)
Ejemplo n.º 6
0
def rm(files):
    command = ["rm", "-f"]
    command += files
    code, text = system_utils.run_command(command)
    if code:
        raise Exception(text)