Esempio n. 1
0
def find_dbrepo(engine, install_type, f_environment_ref, f_install_path):
    """
    Function to find database repository objects by environment reference and
    install path, and return the object's reference as a string
    You might use this function to find Oracle and PostGreSQL database repos.
    engine: Virtualization Engine Session object
    install_type: Type of install - Oracle, ASE, SQL
    f_environment_ref: Reference of the environment for the repository
    f_install_path: Path to the installation directory.
    return: delphixpy.web.vo.SourceRepository object
    """

    print_debug('Searching objects in the %s class for one with the '
                'environment reference of %s and an install path of %s' %
                (install_type, f_environment_ref, f_install_path))
    #import pdb;pdb.set_trace()
    all_objs = repository.get_all(engine, environment=f_environment_ref)
    for obj in all_objs:
        if 'OracleInstall' == install_type:
            if (obj.type == install_type and
                obj.installation_home == f_install_path):

                print_debug('Found a match %s'.format(obj.reference))
                return obj

        elif 'MSSqlInstance' == install_type:
            if (obj.type == install_type and
                obj.instance_name == f_install_path):

                print_debug('Found a match {}'.format(obj.reference))
                return obj

        else:
            raise DlpxException('No Repo match found for type {}.\n'.format(
                install_type))
Esempio n. 2
0
def find_repo_by_environment_ref(
    engine, repo_type, f_environment_ref, f_install_path=None
):
    """
    Function to find unstructured file repository objects by environment
    reference and name, and return the object's reference as a string
    You might use this function to find Unstructured File repos.
    """

    print_debug(
        "\n%s: Searching objects in the %s class for one with the"
        "environment reference of %s\n"
        % (engine["hostname"], repo_type, f_environment_ref),
        debug,
    )

    obj_ref = ""
    all_objs = repository.get_all(
        dx_session_obj.server_session, environment=f_environment_ref
    )

    for obj in all_objs:
        if obj.name == repo_type:
            print_debug(engine["hostname"] + ": Found a match " + str(obj.reference))
            return obj

        elif obj.type == repo_type:
            print_debug(
                "%s Found a match %s" % (engine["hostname"], str(obj.reference)), debug
            )
            return obj

    raise DlpxException(
        "%s: No Repo match found for type %s\n" % (engine["hostname"], repo_type)
    )
Esempio n. 3
0
def find_dbrepo_by_environment_ref_and_name(engine, repo_type,
                                            f_environment_ref, f_name):
    '''
    Function to find database repository objects by environment reference and 
    name, and return the object's reference as a string
    You might use this function to find MSSQL database repos.
    '''

    print_debug(
        '%s: Searching objects in the %s class for one with the '
        'environment reference of %s and a name of %s.' %
        (engine['hostname'], repo_type, f_environment_ref, f_name), debug)

    obj_ref = ''
    all_objs = repository.get_all(server, environment=f_environment_ref)

    for obj in all_objs:
        if (repo_type == 'MSSqlInstance' or repo_type == 'ASEInstance'):
            if (obj.type == repo_type and obj.name == f_name):
                print_debug(
                    '%s: Found a match %s' %
                    (engine['hostname'], str(obj.reference)), debug)
                return obj

        elif repo_type == 'Unstructured Files':
            if obj.value == install_type:
                print_debug(
                    '%s: Found a match %s' %
                    (engine['hostname'], str(obj.reference)), debug)
                return obj

    raise DlpxException('%s: No Repo match found for type %s\n' %
                        (engine['hostname'], repo_type))
Esempio n. 4
0
def find_dbrepo_by_environment_ref_and_install_path(engine, server,
                                                    install_type,
                                                    f_environment_ref,
                                                    f_install_path):
    '''
    Function to find database repository objects by environment reference and 
    install path, and return the object's reference as a string
    You might use this function to find Oracle and PostGreSQL database repos.
    '''
    print_debug(
        '%s: Searching objects in the %s class for one with the '
        'environment reference of %s and an install path of %s' %
        (engine['hostname'], install_type, f_environment_ref, f_install_path),
        debug)

    for obj in repository.get_all(server, environment=f_environment_ref):
        if install_type == 'PgSQLInstall':
            if (obj.type == install_type
                    and obj.installation_path == f_install_path):
                print_debug(
                    '%s: Found a match %s' %
                    (engine['hostname'], str(obj.reference)), debug)
                return obj

        elif install_type == 'OracleInstall':
            if (obj.type == install_type
                    and obj.installation_home == f_install_path):

                print_debug(
                    '%s: Fount a match %s' %
                    (engine['hostname'], str(obj.reference)), debug)
                return obj
        else:
            raise DlpxException('%s: No Repo match found for type %s.\n' %
                                (engine["hostname"], install_type))
def find_dbrepo_by_environment_ref_and_name(engine, repo_type, 
                                            f_environment_ref, f_name):
    '''
    Function to find database repository objects by environment reference and 
    name, and return the object's reference as a string
    You might use this function to find MSSQL database repos.
    '''

    print_debug('%s: Searching objects in the %s class for one with the '
                'environment reference of %s and a name of %s.' %
                (engine['hostname'], repo_type, f_environment_ref, f_name),
                debug)

    obj_ref = ''
    all_objs = repository.get_all(server, environment=f_environment_ref)

    for obj in all_objs:
        if (repo_type == 'MSSqlInstance' or repo_type == 'ASEInstance'):
            if (obj.type == repo_type and obj.name == f_name):
                print_debug('%s: Found a match %s' % (engine['hostname'],
                            str(obj.reference)), debug)
                return obj

        elif repo_type == 'Unstructured Files':
            if obj.value == install_type:
                print_debug('%s: Found a match %s' % (engine['hostname'],
                            str(obj.reference)), debug)
                return obj

    raise DlpxException('%s: No Repo match found for type %s\n' %
                        (engine['hostname'], repo_type))
def find_repo_by_environment_ref(engine, repo_type, f_environment_ref,
                                 f_install_path=None):
    '''
    Function to find unstructured file repository objects by environment 
    reference and name, and return the object's reference as a string
    You might use this function to find Unstructured File repos.
    '''

    print_debug('\n%s: Searching objects in the %s class for one with the'
                'environment reference of %s\n' % 
                (engine['hostname'], repo_type, f_environment_ref), debug)

    obj_ref = ''
    all_objs = repository.get_all(dx_session_obj.server_session,
                                  environment=f_environment_ref)

    for obj in all_objs:
        if obj.name == repo_type:
             print_debug(engine['hostname'] + ': Found a match ' + 
                        str(obj.reference))
             return obj

        elif obj.type == repo_type:
             print_debug('%s Found a match %s' % (engine['hostname'],
                         str(obj.reference)), debug)
             return obj

    raise DlpxException('%s: No Repo match found for type %s\n' % (
                        engine['hostname'], repo_type))
def find_dbrepo_by_environment_ref_and_install_path(engine, server, 
                                                    install_type, 
                                                    f_environment_ref, 
                                                    f_install_path):
    '''
    Function to find database repository objects by environment reference and 
    install path, and return the object's reference as a string
    You might use this function to find Oracle and PostGreSQL database repos.
    '''
    print_debug('%s: Searching objects in the %s class for one with the '
                'environment reference of %s and an install path of %s' %
                (engine['hostname'], install_type, f_environment_ref,
                f_install_path), debug)

    for obj in repository.get_all(server, environment=f_environment_ref):
        if install_type == 'PgSQLInstall':
            if (obj.type == install_type and
                obj.installation_path == f_install_path):
                print_debug('%s: Found a match %s' % (engine['hostname'],
                            str(obj.reference)), debug)
                return obj

        elif install_type == 'OracleInstall':
            if (obj.type == install_type and 
                obj.installation_home == f_install_path):

                print_debug('%s: Fount a match %s' % (engine['hostname'],
                            str(obj.reference)), debug)
                return obj
        else:
            raise DlpxException('%s: No Repo match found for type %s.\n' %
                                (engine["hostname"], install_type))
Esempio n. 8
0
def find_dbrepo_by_environment_ref_and_name(
    engine, repo_type, f_environment_ref, f_name
):
    """
    Function to find database repository objects by environment reference and
    name, and return the object's reference as a string
    You might use this function to find MSSQL database repos.
    """

    print_debug(
        "%s: Searching objects in the %s class for one with the "
        "environment reference of %s and a name of %s."
        % (engine["hostname"], repo_type, f_environment_ref, f_name),
        debug,
    )

    obj_ref = ""
    all_objs = repository.get_all(server, environment=f_environment_ref)

    for obj in all_objs:
        if repo_type == "MSSqlInstance" or repo_type == "ASEInstance":
            if obj.type == repo_type and obj.name == f_name:
                print_debug(
                    "%s: Found a match %s" % (engine["hostname"], str(obj.reference)),
                    debug,
                )
                return obj

        elif repo_type == "Unstructured Files":
            if obj.value == install_type:
                print_debug(
                    "%s: Found a match %s" % (engine["hostname"], str(obj.reference)),
                    debug,
                )
                return obj

    raise DlpxException(
        "%s: No Repo match found for type %s\n" % (engine["hostname"], repo_type)
    )