Example #1
0
def headnode_create(headnode, project, base_img):
    """Create headnode.

    If a node with the same name already exists, a DuplicateError will be
    raised.

    If the project already has a headnode, a DuplicateError will be raised.

    If the project does not exist, a NotFoundError will be raised.

    """

    valid_imgs = cfg.get('headnode', 'base_imgs')
    valid_imgs = [img.strip() for img in valid_imgs.split(',')]

    if base_img not in valid_imgs:
        raise BadArgumentError('Provided image is not a valid image.')
    db = model.Session()

    _assert_absent(db, model.Headnode, headnode)
    project = _must_find(db, model.Project, project)

    headnode = model.Headnode(project, headnode, base_img)

    db.add(headnode)
    db.commit()
Example #2
0
def headnode_create(headnode, project, base_img):
    """Create headnode.

    If a headnode with the same name already exists, a DuplicateError will be
    raised.

    If the project does not exist, a NotFoundError will be raised.

    If the base image does not exist (is not specified in haas.cfg) a
    BadArgumentError will be raised.
    """

    valid_imgs = cfg.get('headnode', 'base_imgs')
    valid_imgs = [img.strip() for img in valid_imgs.split(',')]

    if base_img not in valid_imgs:
        raise BadArgumentError('Provided image is not a valid image.')

    _assert_absent(model.Headnode, headnode)
    project = _must_find(model.Project, project)
    get_auth_backend().require_project_access(project)

    headnode = model.Headnode(project, headnode, base_img)

    db.session.add(headnode)
    db.session.commit()
Example #3
0
def headnode_create(headnode, project, base_img):
    """Create headnode.

    If a node with the same name already exists, a DuplicateError will be
    raised.

    If the project already has a headnode, a DuplicateError will be raised.

    If the project does not exist, a NotFoundError will be raised.

    """
    if not cfg.getboolean('recursive', 'rHaaS'):
        valid_imgs = cfg.get('headnode', 'base_imgs')
        valid_imgs = [img.strip() for img in valid_imgs.split(',')]

        if base_img not in valid_imgs:
            raise BadArgumentError('Provided image is not a valid image.')

    # first check the local database to make sure the headnode doesn't already exist
    # and the project is valid

    db = model.Session()
    _assert_absent(db, model.Headnode, headnode)

    project = _must_find(db, model.Project, project)

    #check for recursive HaaS instance, pass down to base HaaS and check for success/failure
    if cfg.getboolean('recursive', 'rHaaS'):
        b_project = cfg.get('recursive', 'project')
        bHaaS_out = check_output([
            'haas', 'headnode_create', headnode + '_' + project.label,
            b_project, base_img
        ],
                                 stderr=STDOUT,
                                 shell=False)

        error_checker(bHaaS_out)

    #else if not recursive, do anything that should only happen @ bHaaS
    else:
        valid_imgs = cfg.get('headnode', 'base_imgs')
        valid_imgs = [img.strip() for img in valid_imgs.split(',')]

        if base_img not in valid_imgs:
            raise BadArgumentError('Provided image is not a valid image.')

    headnode = model.Headnode(project, headnode, base_img)
    db.add(headnode)
    db.commit()