Example #1
0
def update_war(
    result_folder, war_name
):  #FIXME: replace with python's  zipfile, excluding war files from the archive
    os.chdir(result_folder)
    zipResult = subprocess.call(['zip', '-r', war_name, '.'])
    if zipResult == 0:
        logger.info('War updated. Status: %s.' % zipResult)
    else:
        logger.error('zip not updated. Status: %s.' % zipResult)
        exit(1)
Example #2
0
def get_service(connection, service_name):
    logger.info('Retrieving service %s' % service_name)
    cursor = connection.cursor()
    cursor.prepare('select * from Service where name = :service_name')
    cursor.execute(None, {'service_name': service_name})
    res = cursor.fetchone()
    resultDict = dict(
        zip(tuple(cd[0].lower() for cd in cursor.description), res))
    cursor.close()
    logger.info('Service retrieved')
    return resultDict
Example #3
0
def check_artifacts_directory(service):
    if os.path.isfile(service['path']):
        return '%s is a regular file.' % service['path']
    logger.info('Creating %s' % service['path'])
    try:
        os.makedirs(service['path'])
    except OSError as e:
        if e.errno == 13:  # 13 -> Permission denied.
            return 'Permission denied: You cannot create %s' % service['path']
    if not os.access(service['path'], os.W_OK):
        return 'Permission denied: You cannot write inside %s' % service['path']
    logger.info('%s created.' % service['path'])
Example #4
0
def get_parameters_esthetic_relations(connection):
    logger.info(
        'Retrieving information in Relation_between_column_names table.')
    cur = connection.cursor()
    cur.execute(
        'select internal_name, esthetic_name from Relation_between_column_names order by internal_name'
    )
    res = cur.fetchall()
    cur.close()
    logger.info(
        'Information in Relation_between_column_names table retrieved.')
    return dict(
        res)  # since there are only 2 values, this dirty trick can be used
Example #5
0
def check_templates(service):
    logger.info(
        'Checking if \'templates\' fields are not null and if \'templates\' files exist.'
    )
    for template in [
            'tpl_default', 'tpl_mapping', 'tpl_plain', 'tpl_pu', 'tpl_al',
            'tpl_rt'
    ]:
        if template not in service:
            return 'Template field: %s is not defined.' % template
        if not os.path.isfile(dadEdit3_config.templates_directory +
                              service[template]):
            return 'Template file: %s%s does not exist for %s' % (
                dadEdit3_config.templates_directory, service[template],
                template)
    logger.info('Template file are defined and exist.')
Example #6
0
def create_conf_dir(path):
    os.chdir(path)
    if not os.path.exists('./conf'):
        logger.info('Creating \'conf\' folder.')
        os.makedirs('conf')
        logger.info('\'conf\' folder created.')
    os.chdir('./conf')
    logger.info('The conf directory is %s' % os.getcwd())
Example #7
0
def get_dads(connection, service_name, active=True):
    logger.info('Retrieving all DADs of the service %s with state active==%s' %
                (service_name, active))
    service = get_service(connection, service_name)
    if not service:
        logger.error("A service called %s could not be retrieved." %
                     service_name)
        return []
    cur = connection.cursor()
    cur.prepare(
        'select * from Dad where service_id = :s_id and active = :active order by id'
    )
    cur.execute(None, {
        's_id': service['id'],
        'active': 'Y' if active else 'N'
    })
    res = cur.fetchall()
    dads = []
    for r in res:
        dads.append(
            dict(zip(tuple(cd[0].lower() for cd in cur.description), r)))
    cur.close()
    logger.info('DADs retrieved')
    return dads
Example #8
0
def check_service(service, args):
    logger.info('Checking service')
    logger.debug('\tforceClean: %s' % args.forceClean)
    logger.debug('\tforceFrozen: %s' % args.forceFrozen)
    if not service:
        return 'Service passed by parameter does not exist.'
    if (service['clean'] == 'Y'
            and not args.forceClean) or (service['frozen'] == 'Y'
                                         and not args.forceFrozen):
        return 'Service passed by parameter is frozen or clean and forceClean/forceFrozen flags are disabled'
    if service['context_root'] is None:
        return 'Context_root is null.'
    logger.info('Checking if all mandatory parameters exist.')
    logger.info(
        'Mandatory parameters: ords_version, context_root, application_name, type and path'
    )
    for parameter_name in [
            'ords_version', 'context_root', 'application_name', 'type', 'path'
    ]:
        if service[parameter_name] is None:
            return 'Parameter %s is not defined' % service[parameter_name]
    logger.info('All mandatory parameters exist.')

    logger.info('The service check finished successfully')
Example #9
0
def replace_configdir(configdir, web_template_dir):
    os.chdir(web_template_dir)
    logger.info('Reading content of web.xml.')
    web_xml_content = ET.parse('web.xml')
    root = web_xml_content.getroot()
    logger.info('Replacing content of web.xml.')
    ns = 'http://java.sun.com/xml/ns/j2ee'
    ET.register_namespace('', ns)
    for param in root.findall('{%s}context-param' % ns):
        param_name = param.find('{%s}param-name' % ns)
        param_value = param.find('{%s}param-value' % ns)
        if param_name.text == 'config.dir':
            param_value.text = configdir
    web_xml_content.write('web.xml')
    logger.info('configdir of web.xml replaced.')