Beispiel #1
0
            raise LabSpecInvalid("Lab spec file not found")
        try:
            return json.loads(open(repo_path).read())
        except Exception, e:
            raise LabSpecInvalid("Lab spec JSON invalid: " + str(e))

    repo_name = construct_repo_name()
    if repo_exists(repo_name):
        pull_repo(repo_name)
    else:
        clone_repo(repo_name)
    checkout_version(repo_name)

    lab_spec = get_lab_spec(repo_name)
    try:
        lar = LabActionRunner(get_installer_steps_spec(lab_spec), "")
        lar.run_install_source()

        lar = LabActionRunner(get_build_steps_spec(lab_spec), "")
        lar.run_build_steps()

        return "Success"
    except Exception, e:
        VMM_LOGGER.error("VMManager.test_lab failed: " + str(e))
        return "Test lab failed"
    

def setup_logging():
    VMM_LOGGER.setLevel(logging.DEBUG)   # make log level a setting
    # Add the log message handler to the logger
    myhandler = TimedRotatingFileHandler(
Beispiel #2
0
def test_lab(lab_src_url, version=None):
    # check out the source with version provided
    # is repo already exists? if yes, then do a git pull
    # else clone the repo
    # get the labspec from /scripts/lab_spec.json
    # get the appropriate the actions from lab_spec.json
    # run LabAction Runner
    # instantiate the object

    def get_build_steps_spec(lab_spec):
        return {
            "build_steps":
            lab_spec['lab']['build_requirements']['platform']['build_steps']
        }

    def get_build_installer_steps_spec(lab_spec):
        return {
            "installer":
            lab_spec['lab']['build_requirements']['platform']['installer']
        }

    def get_runtime_installer_steps(lab_spec):
        return {
            "installer":
            lab_spec['lab']['runtime_requirements']['platform']['installer']
        }

    def get_runtime_actions_steps(lab_spec):
        return lab_spec['lab']['runtime_requirements']['platform'][
            'lab_actions']

    def construct_repo_name():
        repo = lab_src_url.split('/')[-1]
        repo_name = repo[:-4] if repo[-4:] == ".git" else repo
        return repo_name

    Logging.LOGGER.info("Starting test_lab")
    repo_name = construct_repo_name()
    if GitCommands.repo_exists(repo_name, GIT_CLONE_LOC, lab_src_url,
                               LAB_SPEC_LOC, 'VMManager'):
        GitCommands.pull_repo(repo_name, GIT_CLONE_LOC, lab_src_url,
                              LAB_SPEC_LOC, 'VMManager')
    else:
        GitCommands.clone_repo(repo_name, GIT_CLONE_LOC, lab_src_url,
                               LAB_SPEC_LOC, 'VMManager')
    GitCommands.checkout_version(repo_name, GIT_CLONE_LOC, lab_src_url,
                                 LAB_SPEC_LOC, 'VMManager', version)

    lab_spec = GitCommands.get_lab_spec(repo_name, GIT_CLONE_LOC, lab_src_url,
                                        LAB_SPEC_LOC, 'VMManager')
    try:
        os.chdir(GIT_CLONE_LOC + repo_name + "/scripts")
        lar = LabActionRunner(get_build_installer_steps_spec(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_build_steps_spec(lab_spec))
        lar.run_build_steps()

        lar = LabActionRunner(get_runtime_installer_steps(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_runtime_actions_steps(lab_spec))
        lar.run_init_lab()
        lar.run_start_lab()
        Logging.LOGGER.info("Finishing test_lab: Success")
        return "Success"
    except Exception, e:
        Logging.LOGGER.error("VMManager.test_lab failed: " + str(e))
        return "Test lab failed"
Beispiel #3
0
def test_lab(lab_src_url, version=None):
    # check out the source with version provided
        # is repo already exists? if yes, then do a git pull
        # else clone the repo
    # get the labspec from /scripts/lab_spec.json
    # get the appropriate the actions from lab_spec.json
    # run LabAction Runner
        # instantiate the object

    def get_build_steps_spec(lab_spec):
        return {"build_steps": lab_spec['lab']['build_requirements']['platform']['build_steps']}

    def get_build_installer_steps_spec(lab_spec):
        return {"installer": lab_spec['lab']['build_requirements']['platform']['installer']}

    def get_runtime_installer_steps(lab_spec):
        return {"installer": lab_spec['lab']['runtime_requirements']['platform']['installer']}

    def get_runtime_actions_steps(lab_spec):
        return lab_spec['lab']['runtime_requirements']['platform']['lab_actions']

    def construct_repo_name():
        repo = lab_src_url.split('/')[-1]
        repo_name = repo[:-4] if repo[-4:] == ".git" else repo
        return repo_name

    
    Logging.LOGGER.info("Starting test_lab")
    repo_name = construct_repo_name()
    if GitCommands.repo_exists(repo_name,GIT_CLONE_LOC,lab_src_url,LAB_SPEC_LOC,'VMManager'):
        GitCommands.pull_repo(repo_name,GIT_CLONE_LOC,lab_src_url,LAB_SPEC_LOC,'VMManager')
    else:
        GitCommands.clone_repo(repo_name,GIT_CLONE_LOC,lab_src_url,LAB_SPEC_LOC,'VMManager')
    GitCommands.checkout_version(repo_name,GIT_CLONE_LOC,lab_src_url,LAB_SPEC_LOC,'VMManager',version)

    lab_spec = GitCommands.get_lab_spec(repo_name,GIT_CLONE_LOC,lab_src_url,LAB_SPEC_LOC,'VMManager')
    try:
        os.chdir(GIT_CLONE_LOC+repo_name+"/scripts")
        lar = LabActionRunner(get_build_installer_steps_spec(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_build_steps_spec(lab_spec))
        lar.run_build_steps()

        lar = LabActionRunner(get_runtime_installer_steps(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_runtime_actions_steps(lab_spec))
        lar.run_init_lab()
        lar.run_start_lab()
        Logging.LOGGER.info("Finishing test_lab: Success")
        return "Success"
    except Exception, e:
        Logging.LOGGER.error("VMManager.test_lab failed: " + str(e))
        return "Test lab failed"
Beispiel #4
0
            Logging.LOGGER.error("Lab spec JSON invalid: " + str(e))
            raise LabSpecInvalid("Lab spec JSON invalid: " + str(e))

    Logging.LOGGER.info("Starting test_lab")
    fill_aptconf()
    repo_name = construct_repo_name()
    if repo_exists(repo_name):
        pull_repo(repo_name)
    else:
        clone_repo(repo_name)
    checkout_version(repo_name)

    lab_spec = get_lab_spec(repo_name)
    try:
        os.chdir(GIT_CLONE_LOC + repo_name + "/scripts")
        lar = LabActionRunner(get_build_installer_steps_spec(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_build_steps_spec(lab_spec))
        lar.run_build_steps()

        lar = LabActionRunner(get_runtime_installer_steps(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_runtime_actions_steps(lab_spec))
        lar.run_init_lab()
        lar.run_start_lab()
        Logging.LOGGER.info("Finishing test_lab: Success")
        return "Success"
    except Exception, e:
        Logging.LOGGER.error("VMManager.test_lab failed: " + str(e))
Beispiel #5
0
        except Exception, e:
            Logging.LOGGER.error("Lab spec JSON invalid: " + str(e))
            raise LabSpecInvalid("Lab spec JSON invalid: " + str(e))

    Logging.LOGGER.info("Starting test_lab")
    repo_name = construct_repo_name()
    if repo_exists(repo_name):
        pull_repo(repo_name)
    else:
        clone_repo(repo_name)
    checkout_version(repo_name)

    lab_spec = get_lab_spec(repo_name)
    try:
        os.chdir(GIT_CLONE_LOC+repo_name+"/scripts")
        lar = LabActionRunner(get_build_installer_steps_spec(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_build_steps_spec(lab_spec))
        lar.run_build_steps()

        lar = LabActionRunner(get_runtime_installer_steps(lab_spec))
        lar.run_install_source()

        lar = LabActionRunner(get_runtime_actions_steps(lab_spec))
        lar.run_init_lab()
        lar.run_start_lab()
        Logging.LOGGER.info("Finishing test_lab: Success")
        return "Success"
    except Exception, e:
        Logging.LOGGER.error("VMManager.test_lab failed: " + str(e))