Esempio n. 1
0
 def get_jira_system_creds(datafile, system_name, list_my_info):
     """Returns a python dictionary containing key value pairs of
     requested info and their values for the provided system name from the datafile """
     if system_name is not None:
         element = xml_Utils.getElementWithTagAttribValueMatch(datafile,
                                                               'system',
                                                               'name',
                                                               system_name)
     else:
         element = xml_Utils.getElementWithTagAttribValueMatch(datafile, 'system',
                                                               'default', "true")
         if element is None:
             node_value = xml_Utils.getNodeValuebyAttribute(datafile, 'system', 'name')
             element = xml_Utils.getElementWithTagAttribValueMatch(datafile, 'system',
                                                                   'name',
                                                                   node_value)
     if element is not None and element is not False:
         output_dict = {}
         for item in list_my_info:
             output_dict[item] = xml_Utils.get_text_from_direct_child(element, item)
         return output_dict
     else:
         msg = ("There is no project with name: '{0}' in the jira config "
                "file: '{1}'".format(system_name, "Tools/jira/jira_config.xml"))
         print_warning(msg)
         return False
Esempio n. 2
0
def get_database_details(config_file, server_type, system_name, info_list):
    """ To get the database system details from database config file """

    system = server_type + "/system"
    if system_name is not None:
        element = xml_Utils.getElementWithTagAttribValueMatch(
            config_file, system, 'name', system_name)
    else:
        element = xml_Utils.getElementWithTagAttribValueMatch(
            config_file, system, 'default', "true")
        if element is None:
            node_value = xml_Utils.getNodeValuebyAttribute(
                config_file, system, 'name')
            element = xml_Utils.getElementWithTagAttribValueMatch(
                config_file, system, 'name', node_value)

    if element is not None and element is not False:
        output_dict = {}
        for item in info_list:
            output_dict[item] = xml_Utils.get_text_from_direct_child(
                element, item)
        return output_dict
    else:
        if system_name is not None:
            msg = "There is no system with name: '{0}' under '{1}' in " \
                  "the database config file: '{2}'".format(system_name,
                                                           server_type,
                                                           config_file)
            print_warning(msg)
        elif server_type == "dataservers":
            msg = "Value for td_system/var_system tag is not provided in " \
                  "the datafile and there is no system listed in database " \
                  "config file under dataservers block to be used as default"
            print_warning(msg)

        return False