Exemple #1
0
    def return_site_group_configuration(self, group_id, testcase=None):
        """ Return current configuration for given site group ID.
        INPUT
            group id: id of site group for which to return the configuration.
            testcase: a testcase object supplied when executing function as part of a testcase step.
        OUPUT
            successful: whether the function executed successfully or not.
            settings: the configuration of the site group returned.
        NOTE: settings are returned with fields already translated into server format.
        """

        self.log.debug("Returning current configuration for site group %s ..." % group_id)
        result = {'successful': False, 'settings':[]}

        try:
            # query server for site group settings
            response = self.query_page('Site Groups')['query response']

            # find settings for given site group
            siteGroup = None
            for entry in response:
                if str(entry['id']) == str(group_id):
                    self.log.trace("Site Group %s found." % group_id)
                    siteGroup = entry
            if siteGroup is not None:
                result['settings'] = translate_dict_to_list_parameters(self.log, siteGroup, None,
                    SITEGROUPCON_FIELDS)['parameters']
                self.log.trace("Returned current configuration for site group %s." % group_id)
            else:
                self.log.error("Site Group %s not found." % group_id)

            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, operation="return current configuration for site group %s"
                                               % group_id)
Exemple #2
0
    def return_site_configuration(self, siteID, testcase=None):
        """ Return current site configuration settings.
        INPUT
            site id: the ID of the site for which to return the configuration.
            testcase: a testcase object supplied when executing function as part of a testcase step.
        OUPUT
            successful: whether the function executed successfully or not.
            verified: whether the operation was verified or not.
        """

        self.log.debug("Returning current configuration for site %s ..." % siteID)
        result = {'settings':{}, 'parameters':[]}

        try:
            # determine site configuration map (per version)
            if float(self.release_version) <= 3.3:
                SERVER_FIELD_NAMES = SITECON_3_3_COLUMNS
            else: SERVER_FIELD_NAMES = SITECON_COLUMNS
            # query server for site settings
            url = self.server_url + SITECON_QUERY_PATH
            response = self.query_server_table(url, SERVER_FIELD_NAMES)['response']

            if response != [] and len(response) > 1:
                # find correct entry by site id
                for entry in response[1:]:
                    if str(entry['id']) == str(siteID): configuration = entry

                # translate configuration
                result['parameters'] =\
                translate_dict_to_list_parameters(self.log, configuration,
                    translation=SITECON_FIELDS)['parameters']
                result['settings'] = translate_list_parameters_to_dict(self.log,
                    result['parameters'])['dict']
                self.log.trace("Current site configuration:\t%s" % str(result['settings']))
            else:
                self.log.warn("No site configuration returned for site %s." % siteID)

            self.log.trace("Returned current configuration for site %s." % siteID)
            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, operation="return current configuration for site %s" % siteID)