import configparser


def config_parser(config_file):
    """
    Configuration file parsing.
    Returns dictionary with configuration parameters:
    'one_auth_file' - Opennebula sessions credential file path,
    'key_file' - AES key file path,
    'workers_quantity' - ZMQ workers quantity,
    'server_ip' - IP address for ZMQ routing server binding,
    'server_port' - Port number for ZMQ routing server binding,
    'pidfile' - PID file path,
    'vm_user' - VM user name,
    'password_size' - Size password for VM users,
    'password_complexity' - Complexity password for VM users(bool),
    'loggerconf_file' - Logger configuration file path. 
    """
    
    config = configparser.ConfigParser()
    config.read(config_file)
    cinfig_dict = {'one_auth_file': config.get('auth_file','one_auth_file'),
                   'key_file': config.get('auth_file','key_file'),
                   'workers_quantity': int(config.get('zmq_workers_quantity','workers_quantity')),
                   'server_ip': config.get('ip_address_port','server_ip'),
                   'server_port': config.get('ip_address_port','server_port'),
                   'pidfile': config.get('pid_file','pidfile'),
                   'vm_user': config.get('vm_user_name','vm_user'),
                   'password_size': int(config.get('password_vm_users','password_size')),
                   'password_complexity': config.getboolean('password_vm_users','password_complexity'),
                   'loggerconf_file': config.get('logger_config_file','loggerconf_file')
                  }
    
    return cinfig_dict