Exemplo n.º 1
0
def validate_slug_to_path_unique(v, slug):
    pc = commands.get_pilot_client()
    tc = pc.get_transfer_client()
    try:
        ctx = pc.context.get_context()
        ep, path = ctx.get('projects_endpoint'), ctx.get('projects_base_path')
        log.debug('Checking ep: {} path: {}'.format(ep, path))
        response = tc.operation_ls(ep, path=path)
        existing = [f['name'] for f in response.data['DATA']]
        if slug in existing:
            raise exc.PilotValidator('"{}" is not available, please choose '
                                     'another'.format(slug))
    except globus_sdk.exc.TransferAPIError as tapie:
        log.exception(tapie.message)
        raise exc.PilotValidator('An error occurred, please try a different '
                                 'value or notify a system administrator.')
Exemplo n.º 2
0
def validate_is_valid_globus_group(v, entity):
    if entity == 'public':
        return
    try:
        uuid.UUID(entity)
    except ValueError:
        raise exc.PilotValidator('Value is not a UUID.') from None
Exemplo n.º 3
0
def validate_is_globus_endpoint(v, entity):
    pc = commands.get_pilot_client()
    tc = pc.get_transfer_client()
    log.debug(f'Checking ep: {entity}')
    try:
        tc.get_endpoint(entity)
    except globus_sdk.exc.TransferAPIError:
        log.debug(f'Failed to fetch endpoint {entity}', exc_info=True)
        raise exc.PilotValidator(
            f'Failed to get endpoint {entity}, please choose '
            'a valid Globus Endpoint') from None
Exemplo n.º 4
0
def validate_project_slug_unique(v, slug):
    pc = commands.get_pilot_client()
    slugs = pc.project.load_all().keys()
    if slug in slugs:
        raise exc.PilotValidator(f'Slug must be unique from {", ".join(slug)}')
Exemplo n.º 5
0
def validate_project_title_unique(v, title):
    titles = v.queries['title']['current']
    if title in titles:
        raise exc.PilotValidator('Title must be unique from '
                                 f'{", ".join(titles)}')
Exemplo n.º 6
0
def validate_no_tilde(v, string):
    if '~' in string:
        raise exc.PilotValidator('No "~" allowed in path')
Exemplo n.º 7
0
def validate_absolute_path(v, string):
    if not os.path.isabs(string):
        raise exc.PilotValidator('Path must be absolute')
Exemplo n.º 8
0
def validate_no_spaces(v, string):
    if ' ' in string:
        raise exc.PilotValidator(f'"{string}" cannot contain spaces')
Exemplo n.º 9
0
def validate_project_path_unique(v, path):
    pc = commands.get_pilot_client()
    paths = [p['base_path'] for p in pc.project.load_all().values()]
    if path in paths:
        raise exc.PilotValidator('Path must be unique. (Other paths include '
                                 f'{", ".join(paths)})')
Exemplo n.º 10
0
def validate_project_group(v, group):
    groups = v.queries['group']['groups']
    if group not in groups:
        raise exc.PilotValidator('Group must be one of: '
                                 '{}'.format(', '.join(groups)))
Exemplo n.º 11
0
def validate_project_endpoint(v, ep):
    pc = commands.get_pilot_client()
    if ep not in pc.project.ENDPOINTS.keys():
        raise exc.PilotValidator('Endpoint must be one of: "{}"'.format(
            ', '.join(pc.project.ENDPOINTS.keys())))
Exemplo n.º 12
0
def validate_is_uuid(v, entity):
    try:
        uuid.UUID(entity)
    except ValueError:
        raise exc.PilotValidator('Value is not a UUID.') from None