Пример #1
0
    def LoadProfiles(self):
        """
        Load list of profiles sets
        Return None if OK
        """

        if (self.__engine.version_ge('6.0.0')):
            from masking_api_60.api.profile_set_api import ProfileSetApi
            from masking_api_60.rest import ApiException
        else:
            from masking_api_53.api.profile_set_api import ProfileSetApi
            from masking_api_53.rest import ApiException

        self.__api = ProfileSetApi
        self.__apiexc = ApiException

        try:

            api_instance = self.__api(self.__engine.api_client)

            # execapi = ExecutionApi(self.__engine.api_client)
            # execList = paginator(
            #             execapi,
            #             "get_all_executions")
            #
            # if execList.response_list:
            #     for e in execList.response_list:
            #         self.__executionList[e.job_id] = e

            profileset = paginator(
                            api_instance,
                            "get_all_profile_sets",
                            _request_timeout=self.__engine.get_timeout())

            if profileset.response_list:
                for ps in profileset.response_list:
                    profile = DxProfile()
                    profile.from_profileset(ps)
                    self.__profileset_list[ps.profile_set_id] = profile
            else:
                print_error("No Profile sets found")
                self.__logger.error("No Profile sets found")

            self.__logger.debug("All Profile sets loaded")

        except self.__apiexc as e:
            print_error("Can't load Profile sets list %s" % e.body)
            return 1
Пример #2
0
def profile_add(p_engine, p_username,  profilename, expname, description):
    """
    Add profile to engine
    param1: p_engine: engine name from configuration
    param2: profilename: profile name
    param3: expname: expression list names
    param4: description: profile description
    return 0 if profile was added
    """

    ret = 0
    logger = logging.getLogger()
    enginelist = get_list_of_engines(p_engine, p_username)

    if enginelist is None:
        return 1

    for engine_tuple in enginelist:
        engine_obj = DxMaskingEngine(engine_tuple)
        if engine_obj.get_session():
            continue

        # load all objects
        profilelist = DxProfilesList()
        probj = DxProfile()

        explist = probj.set_expressions_using_names(expname)

        if explist:
            probj.create_profile(
                profile_set_name = profilename,
                created_by = engine_obj.get_username(),
                description = description,
                profile_expression_ids=explist
            )
            if profilelist.add(probj):
                ret = ret + 1
        else:
            ret = ret + 1



    return ret