Exemple #1
0
    def test_pull_images(self):
        """ ################################################## TEST PULL IMAGES
        """
        options = {
            'debug': False,
            'nginx': False,
        }
        client_name = 'test_client'
        oe = OdooEnv(options)
        cmds = oe.pull_images(client_name)

        cmd = cmds[0]
        self.assertEqual(cmd.usr_msg, 'Pulling Image aeroo')
        command = 'sudo docker pull jobiols/aeroo-docs'
        self.assertEqual(cmd.command, command)

        cmd = cmds[1]
        self.assertEqual(cmd.usr_msg, 'Pulling Image odoo')
        command = 'sudo docker pull jobiols/odoo-jeo:9.0'
        self.assertEqual(cmd.command, command)

        cmd = cmds[2]
        self.assertEqual(cmd.usr_msg, 'Pulling Image postgres')
        command = 'sudo docker pull postgres:9.5'
        self.assertEqual(cmd.command, command)

        cmd = cmds[3]
        self.assertEqual(cmd.usr_msg, 'Pulling Image nginx')
        command = 'sudo docker pull nginx:latest'
        self.assertEqual(cmd.command, command)
Exemple #2
0
 def test_update(self):
     """ ################################################## TEST PULL UPDATE
     """
     options = {
         'debug': False,
         'nginx': False,
     }
     client_name = 'test_client'
     oe = OdooEnv(options)
     cmds = oe.update(client_name, 'client_prod', ['all'])
     command = \
         "sudo docker run --rm -it " \
         "-v /odoo_ar/odoo-9.0/test_client/config:/opt/odoo/etc/ " \
         "-v /odoo_ar/odoo-9.0/test_client/data_dir:/opt/odoo/data " \
         "-v /odoo_ar/odoo-9.0/test_client/log:/var/log/odoo " \
         "-v /odoo_ar/odoo-9.0/test_client/sources:" \
         "/opt/odoo/custom-addons " \
         "-v /odoo_ar/odoo-9.0/test_client/backup_dir:/var/odoo/backups/ " \
         "--link pg-test_client:db " \
         "-e ODOO_CONF=/dev/null jobiols/odoo-jeo:9.0 " \
         "-- " \
         "--stop-after-init " \
         "--logfile=false " \
         "-d client_prod " \
         "-u all "
     self.assertEqual(cmds[0].command, command)
Exemple #3
0
    def test_install2_enterprise(self):
        """ ################################### TEST INSTALLATION v2 ENTERPRISE
        """
        options = {
            'debug': True,
            'no-repos': False,
            'nginx': True,
        }

        base_dir = '/odoo_ar/'
        oe = OdooEnv(options)
        cmds = oe.install('test2e_client')
        self.assertEqual(cmds[0].args, base_dir)
        self.assertEqual(cmds[0].command, 'sudo mkdir ' + base_dir)
        self.assertEqual(cmds[0].usr_msg, 'Installing client test2e_client')

        self.assertEqual(
            cmds[2].args,
            '{}odoo-9.0e/test2e_client/postgresql'.format(base_dir))
        self.assertEqual(
            cmds[2].command,
            'mkdir -p {}odoo-9.0e/test2e_client/postgresql'.format(base_dir))
        self.assertEqual(cmds[2].usr_msg, False)

        self.assertEqual(cmds[8].args, '/odoo_ar/odoo-9.0e/dist-packages')
        self.assertEqual(cmds[8].command,
                         'mkdir -p /odoo_ar/odoo-9.0e/dist-packages')
        self.assertEqual(cmds[8].usr_msg, False)
Exemple #4
0
    def test_run_cli(self):
        """ ###################################################### TEST RUN CLI
        """
        options = {
            'debug': False,
            'nginx': False,
        }
        client_name = 'test_client'
        oe = OdooEnv(options)
        cmds = oe.run_client(client_name)

        cmd = cmds[0]
        self.assertEqual(
            cmd.usr_msg, 'Starting Odoo image for client '
            'test_client on port 8069')

        command = \
            "sudo docker run -d " \
            "--link aeroo:aeroo " \
            "-p 8069:8069 " \
            "-p 8072:8072 " \
            "-v /odoo_ar/odoo-9.0/test_client/config:/opt/odoo/etc/ " \
            "-v /odoo_ar/odoo-9.0/test_client/data_dir:/opt/odoo/data " \
            "-v /odoo_ar/odoo-9.0/test_client/log:/var/log/odoo " \
            "-v /odoo_ar/odoo-9.0/test_client/sources:" \
            "/opt/odoo/custom-addons " \
            "-v /odoo_ar/odoo-9.0/test_client/backup_dir:/var/odoo/backups/ " \
            "--link pg-test_client:db " \
            "--restart=always " \
            "--name test_client " \
            "-e ODOO_CONF=/dev/null " \
            "jobiols/odoo-jeo:9.0 " \
            "--logfile=/var/log/odoo/odoo.log "

        self.assertEqual(cmd.command, command)
Exemple #5
0
    def test_cmd(self):
        """ ########################################################## TEST CMD
        """
        options = {
            'debug': False,
            'no-repos': False,
            'nginx': False,
        }
        oe = OdooEnv(options)

        # si no tiene argumentos para chequear no requiere chequeo
        c = Command(oe, command='cmd', usr_msg='hola')
        self.assertEqual(c.command, 'cmd')
        self.assertEqual(c.usr_msg, 'hola')
        self.assertEqual(c.args, False)
        self.assertEqual(c.check(), True)

        c = MakedirCommand(oe, command='cmd', args='no_existe_este_directorio')
        self.assertEqual(c.check_args(), True)

        c = CreateNginxTemplate(oe,
                                command='cmd',
                                args='no_exist',
                                usr_msg='Testing msg')
        self.assertEqual(c.usr_msg, 'Testing msg')
Exemple #6
0
    def test_run_cli_debug(self):
        """ ############################################## TEST RUN CLI W/DEBUG
        """
        options = {
            'debug': True,
            'nginx': False,
        }
        client_name = 'test_client'
        oe = OdooEnv(options)
        cmds = oe.run_client(client_name)

        cmd = cmds[0]
        self.assertEqual(
            cmd.usr_msg, 'Starting Odoo image for client '
            'test_client on port 8069')
        command = \
            'sudo docker run --rm -it ' \
            '--link aeroo:aeroo ' \
            '--link wdb ' \
            '-p 8069:8069 -p 8072:8072 ' \
            '-v /odoo_ar/odoo-9.0/test_client/config:/opt/odoo/etc/ ' \
            '-v /odoo_ar/odoo-9.0/test_client/data_dir:/opt/odoo/data ' \
            '-v /odoo_ar/odoo-9.0/test_client/log:/var/log/odoo ' \
            '-v /odoo_ar/odoo-9.0/test_client/sources:' \
            '/opt/odoo/custom-addons ' \
            '-v /odoo_ar/odoo-9.0/test_client/backup_dir:/var/odoo/backups/ ' \
            '-v /odoo_ar/odoo-9.0/extra-addons:/opt/odoo/extra-addons ' \
            '-v /odoo_ar/odoo-9.0/dist-packages:' \
            '/usr/lib/python2.7/dist-packages ' \
            '-v /odoo_ar/odoo-9.0/dist-local-packages:' \
            '/usr/local/lib/python2.7/dist-local-packages ' \
            '--link pg-test_client:db ' \
            '--name test_client ' \
            '-e ODOO_CONF=/dev/null ' \
            '-e SERVER_MODE=test ' \
            '-e WDB_SOCKET_SERVER=wdb jobiols/odoo-jeo:9.0.debug ' \
            '--logfile=/dev/stdout '

        self.assertEqual(cmd.command, command)
Exemple #7
0
    def test_qa(self):
        """ ########################################################### TEST QA
        """
        options = {'debug': False}
        client_name = 'test_client'
        database = 'cliente_test'
        modules = 'modulo_a_testear'

        oe = OdooEnv(options)
        client = Client(oe, client_name)

        cmds = oe.qa(client_name, database, modules, client_test=client)

        cmd = cmds[0]
        self.assertEqual(
            cmd.usr_msg, 'Performing tests on module '
            'modulo_a_testear for client '
            'test_client and database cliente_test')

        command = \
            "sudo docker run --rm -it " \
            "-v /odoo_ar/odoo-9.0/test_client/config:/opt/odoo/etc/ " \
            "-v /odoo_ar/odoo-9.0/test_client/data_dir:/opt/odoo/data " \
            "-v /odoo_ar/odoo-9.0/test_client/log:/var/log/odoo " \
            "-v /odoo_ar/odoo-9.0/test_client/sources:" \
            "/opt/odoo/custom-addons " \
            "-v /odoo_ar/odoo-9.0/test_client/backup_dir:/var/odoo/backups/ " \
            "--link wdb " \
            "-e WDB_SOCKET_SERVER=wdb " \
            "-e ODOO_CONF=/dev/null " \
            "--link pg-test_client:db jobiols/odoo-jeo:9.0.debug -- " \
            "-d cliente_test " \
            "--stop-after-init " \
            "--log-level=test " \
            "--test-enable " \
            "-u modulo_a_testear "

        self.assertEqual(cmd.command, command)
Exemple #8
0
    def test_restore(self):
        """ ################################################# TEST PULL RESTORE
        """
        options = {
            'debug': False,
            'nginx': False,
        }
        client_name = 'test_client'
        database = 'client_prod'
        backup_file = 'bkp.zip'
        oe = OdooEnv(options)
        cmds = oe.restore(client_name, database, backup_file, deactivate=True)
        command = \
            'sudo docker run --rm -i ' \
            '--link pg-test_client:db ' \
            '-v /odoo_ar/odoo-9.0/test_client/backup_dir/:/backup ' \
            '-v /odoo_ar/odoo-9.0/test_client/data_dir/filestore:/filestore ' \
            '--env NEW_DBNAME=client_prod ' \
            '--env ZIPFILE=bkp.zip ' \
            '--env DEACTIVATE=True ' \
            'jobiols/dbtools '

        self.assertEqual(cmds[0].command, command)
Exemple #9
0
    def test_download_image_sources(self):
        """ ####################################### TEST DOWNLOAD IMAGE SOURCES
        """
        options = {
            'debug': True,
            'no-repos': False,
            'nginx': False,
        }
        oe = OdooEnv(options)
        cmds = oe.install('test_client')

        command = 'sudo mkdir /odoo_ar/'
        self.assertEqual(cmds[0].command, command)

        #command = 'sudo chown jobiols:jobiols /odoo_ar/'
        #self.assertEqual(cmds[1].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/test_client/postgresql'
        self.assertEqual(cmds[2].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/test_client/config'
        self.assertEqual(cmds[3].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/test_client/data_dir'
        self.assertEqual(cmds[4].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/test_client/backup_dir'
        self.assertEqual(cmds[5].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/test_client/log'
        self.assertEqual(cmds[6].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/test_client/sources'
        self.assertEqual(cmds[7].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/dist-packages'
        self.assertEqual(cmds[8].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/dist-local-packages'
        self.assertEqual(cmds[9].command, command)

        command = 'mkdir -p /odoo_ar/odoo-9.0/extra-addons'
        self.assertEqual(cmds[10].command, command)

        command = 'chmod og+w /odoo_ar/odoo-9.0/dist-packages'
        self.assertEqual(cmds[11].command, command)

        command = 'chmod og+w /odoo_ar/odoo-9.0/dist-local-packages'
        self.assertEqual(cmds[12].command, command)

        command = 'chmod og+w /odoo_ar/odoo-9.0/extra-addons'
        self.assertEqual(cmds[13].command, command)

        command = 'chmod o+w /odoo_ar/odoo-9.0/test_client/config'
        self.assertEqual(cmds[14].command, command)

        command = 'chmod o+w /odoo_ar/odoo-9.0/test_client/data_dir'
        self.assertEqual(cmds[15].command, command)

        command = 'chmod o+w /odoo_ar/odoo-9.0/test_client/log'
        self.assertEqual(cmds[16].command, command)

        command = 'chmod o+w /odoo_ar/odoo-9.0/test_client/backup_dir'
        self.assertEqual(cmds[17].command, command)

        command = 'sudo docker run -it --rm ' \
                  '--entrypoint=/extract_dist-packages.sh ' \
                  '-v /odoo_ar/odoo-9.0/dist-packages/:/mnt/dist-packages ' \
                  'jobiols/odoo-jeo:9.0.debug '
        self.assertEqual(cmds[18].command, command)

        command = 'sudo docker run -it --rm ' \
                  '--entrypoint=/extract_dist-local-packages.sh ' \
                  '-v /odoo_ar/odoo-9.0/dist-local-packages/:' \
                  '/mnt/dist-local-packages ' \
                  'jobiols/odoo-jeo:9.0.debug '
        self.assertEqual(cmds[19].command, command)

        command = 'sudo docker run -it --rm ' \
                  '--entrypoint=/extract_extra-addons.sh ' \
                  '-v /odoo_ar/odoo-9.0/extra-addons/:/mnt/extra-addons ' \
                  'jobiols/odoo-jeo:9.0.debug '
        self.assertEqual(cmds[20].command, command)

        command = 'sudo chmod -R og+w /odoo_ar/odoo-9.0/dist-packages/'
        self.assertEqual(cmds[21].command, command)

        command = 'sudo chmod -R og+w /odoo_ar/odoo-9.0/dist-local-packages/'
        self.assertEqual(cmds[22].command, command)

        command = 'sudo chmod -R og+w /odoo_ar/odoo-9.0/extra-addons/'
        self.assertEqual(cmds[23].command, command)

        command = '/odoo_ar/odoo-9.0/dist-packages/.gitignore'
        self.assertEqual(cmds[24].command, command)

        command = '/odoo_ar/odoo-9.0/dist-local-packages/.gitignore'
        self.assertEqual(cmds[25].command, command)

        command = '/odoo_ar/odoo-9.0/extra-addons/.gitignore'
        self.assertEqual(cmds[26].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/dist-packages/ init '
        self.assertEqual(cmds[27].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/dist-local-packages/ init '
        self.assertEqual(cmds[28].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/extra-addons/ init '
        self.assertEqual(cmds[29].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/dist-packages/ add . '
        self.assertEqual(cmds[30].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/dist-local-packages/ add . '
        self.assertEqual(cmds[31].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/extra-addons/ add . '
        self.assertEqual(cmds[32].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/dist-packages/ commit -m inicial '
        self.assertEqual(cmds[33].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/dist-local-packages/ ' \
                  'commit -m inicial '
        self.assertEqual(cmds[34].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/extra-addons/ commit -m inicial '
        self.assertEqual(cmds[35].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/test_client/sources/ ' \
                  'clone --depth 1 -b 9.0 ' \
                  'https://github.com/jobiols/cl-test-client'
        self.assertEqual(cmds[36].command, command)

        command = 'git -C ' \
                  '/odoo_ar/odoo-9.0/test_client/sources/cl-test-client ' \
                  'pull'
        self.assertEqual(cmds[37].command, command)

        command = 'git -C /odoo_ar/odoo-9.0/test_client/sources/ ' \
                  'clone --depth 1 ' \
                  '-b 9.0 https://github.com/jobiols/odoo-addons'
        self.assertEqual(cmds[38].command, command)

        command = 'git -C ' \
                  '/odoo_ar/odoo-9.0/test_client/sources/odoo-addons ' \
                  'pull'
        self.assertEqual(cmds[39].command, command)
Exemple #10
0
    def test_install(self):
        """ ################################################# TEST INSTALLATION
        """
        options = {
            'debug': False,
            'no-repos': False,
            'nginx': True,
        }

        base_dir = '/odoo_ar/'
        oe = OdooEnv(options)
        cmds = oe.install('test_client')
        self.assertEqual(cmds[0].args, base_dir)
        self.assertEqual(cmds[0].command, 'sudo mkdir ' + base_dir)
        self.assertEqual(cmds[0].usr_msg, 'Installing client test_client')

        self.assertEqual(cmds[2].args,
                         '{}odoo-9.0/test_client/postgresql'.format(base_dir))
        self.assertEqual(
            cmds[2].command,
            'mkdir -p {}odoo-9.0/test_client/postgresql'.format(base_dir))
        self.assertEqual(cmds[2].usr_msg, False)

        self.assertEqual(cmds[3].args, '/odoo_ar/odoo-9.0/test_client/config')
        self.assertEqual(cmds[3].command,
                         'mkdir -p /odoo_ar/odoo-9.0/test_client/config')
        self.assertEqual(cmds[3].usr_msg, False)

        self.assertEqual(cmds[4].args,
                         '/odoo_ar/odoo-9.0/test_client/data_dir')
        self.assertEqual(cmds[4].command,
                         'mkdir -p /odoo_ar/odoo-9.0/test_client/data_dir')
        self.assertEqual(cmds[4].usr_msg, False)

        self.assertEqual(cmds[5].args,
                         '/odoo_ar/odoo-9.0/test_client/backup_dir')
        self.assertEqual(cmds[5].command,
                         'mkdir -p /odoo_ar/odoo-9.0/test_client/backup_dir')
        self.assertEqual(cmds[5].usr_msg, False)

        self.assertEqual(cmds[6].args, '/odoo_ar/odoo-9.0/test_client/log')
        self.assertEqual(cmds[6].command,
                         'mkdir -p /odoo_ar/odoo-9.0/test_client/log')
        self.assertEqual(cmds[6].usr_msg, False)

        self.assertEqual(cmds[7].args, '/odoo_ar/odoo-9.0/test_client/sources')
        self.assertEqual(cmds[7].command,
                         'mkdir -p /odoo_ar/odoo-9.0/test_client/sources')
        self.assertEqual(cmds[7].usr_msg, False)

        self.assertEqual(cmds[8].args, False)
        self.assertEqual(cmds[8].command,
                         'chmod o+w /odoo_ar/odoo-9.0/test_client/config')
        self.assertEqual(cmds[8].usr_msg, False)

        self.assertEqual(cmds[9].args, False)
        self.assertEqual(cmds[9].command,
                         'chmod o+w /odoo_ar/odoo-9.0/test_client/data_dir')
        self.assertEqual(cmds[9].usr_msg, False)

        self.assertEqual(cmds[10].args, False)
        self.assertEqual(cmds[10].command,
                         'chmod o+w /odoo_ar/odoo-9.0/test_client/log')
        self.assertEqual(cmds[10].usr_msg, False)

        self.assertEqual(cmds[11].args, False)
        self.assertEqual(cmds[11].command,
                         'chmod o+w /odoo_ar/odoo-9.0/test_client/backup_dir')
        self.assertEqual(cmds[11].usr_msg, False)

        self.assertEqual(cmds[12].args, '/odoo_ar/nginx/cert')
        self.assertEqual(cmds[12].command, 'mkdir -p /odoo_ar/nginx/cert')
        self.assertEqual(cmds[12].usr_msg, False)

        self.assertEqual(cmds[13].args, '/odoo_ar/nginx/conf')
        self.assertEqual(cmds[13].command, 'mkdir -p /odoo_ar/nginx/conf')
        self.assertEqual(cmds[13].usr_msg, False)

        self.assertEqual(cmds[14].args, '/odoo_ar/nginx/log')
        self.assertEqual(cmds[14].command, 'mkdir -p /odoo_ar/nginx/log')
        self.assertEqual(cmds[14].usr_msg, False)

        self.assertEqual(cmds[15].args, '/odoo_ar/nginx/conf/nginx.conf')
        self.assertEqual(cmds[15].command, '/odoo_ar/nginx/conf/nginx.conf')
        self.assertEqual(cmds[15].usr_msg, 'Generating nginx.conf template')

        self.assertEqual(
            cmds[16].args,
            '/odoo_ar/odoo-9.0/test_client/sources/cl-test-client')
        self.assertEqual(
            cmds[16].command,
            'git -C /odoo_ar/odoo-9.0/test_client/sources/ clone --depth 1 '
            '-b 9.0 https://github.com/jobiols/cl-test-client')
        self.assertEqual(cmds[16].usr_msg,
                         'cloning b 9.0     jobiols/cl-test-client        ')

        self.assertEqual(
            cmds[17].args,
            '/odoo_ar/odoo-9.0/test_client/sources/cl-test-client')
        self.assertEqual(
            cmds[17].command,
            'git -C /odoo_ar/odoo-9.0/test_client/sources/cl-test-client pull')
        self.assertEqual(cmds[17].usr_msg,
                         'pulling b 9.0     jobiols/cl-test-client        ')

        self.assertEqual(cmds[18].args,
                         '/odoo_ar/odoo-9.0/test_client/sources/odoo-addons')
        self.assertEqual(
            cmds[18].command,
            'git -C /odoo_ar/odoo-9.0/test_client/sources/ clone --depth 1 '
            '-b 9.0 https://github.com/jobiols/odoo-addons')
        self.assertEqual(cmds[18].usr_msg,
                         'cloning b 9.0     jobiols/odoo-addons           ')

        self.assertEqual(cmds[19].args,
                         '/odoo_ar/odoo-9.0/test_client/sources/odoo-addons')
        self.assertEqual(
            cmds[19].command,
            'git -C /odoo_ar/odoo-9.0/test_client/sources/odoo-addons pull')
        self.assertEqual(cmds[19].usr_msg,
                         'pulling b 9.0     jobiols/odoo-addons           ')
Exemple #11
0
def main():
    parser = argparse.ArgumentParser(description="""
Odoo Environment Manager v%s - by jeo Software <*****@*****.**>
""" % __version__)

    parser.add_argument(
        '-i',
        '--install',
        action='store_true',
        help="Install. Creates dir structure, and pull all the repositories "
        "declared in the client manifest. Use with --debug to copy Odoo "
        "image sources to host")

    parser.add_argument(
        '-p',
        '--pull-images',
        action='store_true',
        help="Pull Images. Download all images declared in client manifest.")

    parser.add_argument('-w',
                        '--write-config',
                        action='store_true',
                        help="Create / Overwrite config file.")

    parser.add_argument('-R',
                        '--run-env',
                        action='store_true',
                        help="Run postgres and aeroo images.")

    parser.add_argument('-r',
                        '--run-cli',
                        action='store_true',
                        help="Run odoo image")

    parser.add_argument('-S',
                        '--stop-env',
                        action='store_true',
                        help="Stop postgres and aeroo images.")

    parser.add_argument('-s',
                        '--stop-cli',
                        action='store_true',
                        help="Stop odoo image.")

    parser.add_argument(
        '-u',
        '--update',
        action='store_true',
        help="Update modules to database. Use --debug to force update with "
        "image sources. use -m modulename to update this only module "
        "default is all use -d databasename to update this database, "
        "default is clientname_default")

    parser.add_argument(
        '-c',
        action='append',
        dest='client',
        help="Set default client name. This option is persistent")

    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        help="Go verbose mode. Prints every command")

    parser.add_argument('--deactivate',
                        action='store_true',
                        help="Deactivate database before restore")

    parser.add_argument(
        '--debug',
        action='store_true',
        help='Set default environment mode to debug'
        'This option has the following efects: '
        '1.- When doing an install it copies the image sources to host '
        'and clones repos with depth=100'
        '2.- When doing an update all, (option -u) it forces update with '
        'image sources.'
        'This option is persistent.')
    parser.add_argument(
        '--prod',
        action='store_true',
        help='Set default environment mode to production'
        'This option is intended to install a production environment.'
        'This option is persistent.')

    parser.add_argument(
        '--no-repos',
        action='store_true',
        help='Does not clone or pull repos when doing -i (install)')

    parser.add_argument('-d',
                        action='store',
                        nargs=1,
                        dest='database',
                        help="Set default Database name."
                        "This option is persistent")

    parser.add_argument(
        '-m',
        action='append',
        dest='module',
        help="Module to update. Used with -u (update) i.e. -m sale for "
        "updating sale module -m all for updating all modules. NOTE: if "
        "you perform -u without -m it asumes all modules")

    parser.add_argument(
        '--nginx',
        action='store_true',
        help='Add nginx to installation: Used with -i creates nginx dir '
        'with config file. '
        'Used with -r starts an nginx container linked to odoo.'
        'Used with -s stops nginx container. '
        'If you want to add certificates review nginx.conf file located '
        'in /odoo_ar/nginx/conf')

    parser.add_argument(
        '-Q',
        action='store',
        metavar='repo',
        nargs=1,
        dest='quality_assurance',
        help="Perform QA running tests, argument are repository to test. "
        "Need -d, -m and -c options Note: for the test to run the "
        "database must be created with demo data and must have "
        "admin user with password admin.")

    parser.add_argument('--backup-list',
                        action='store_true',
                        help="List all backup files available for restore")

    parser.add_argument(
        '--restore',
        action='store_true',
        help="Restores a backup. it uses last backup and restores to default "
        "database. You can change the backup file to restore with -f "
        "option and change database name -d option")

    parser.add_argument(
        '-f',
        action='append',
        dest='backup_file',
        help="Filename to restore. Used with --restore. To get the name of "
        "this file issue a --backup-list command."
        "If ommited the newest file will be restored")

    parser.add_argument(
        '-H',
        '--server-help',
        action='store_true',
        help="Show odoo server help, it shows the help from the odoo image"
        "declared in the cliente manifest")

    parser.add_argument('-V',
                        '--version',
                        action='store_true',
                        help="Show version number and exit.")

    args = parser.parse_args()
    if args.debug:
        OeConfig().save_environment('debug')

    if args.prod:
        OeConfig().save_environment('prod')

    debug_option = OeConfig().get_environment() == 'debug'
    options = {
        'verbose': args.verbose,
        'debug': debug_option,
        'no-repos': args.no_repos,
        'nginx': args.nginx,
        'backup_file': args.backup_file,
    }
    commands = []

    if args.server_help:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).server_help(client_name)

    if args.backup_list:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).backup_list(client_name)

    if args.restore:
        client_name = get_param(args, 'client')
        database = get_param(args, 'database')
        backup_file = get_param(args, 'backup_file')
        deactivate = get_param(args, 'deactivate')
        commands += OdooEnv(options).restore(client_name, database,
                                             backup_file, deactivate)

    if args.install:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).install(client_name)

    if args.write_config:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).write_config(client_name)

    if args.pull_images:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).pull_images(client_name)

    if args.stop_env:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).stop_environment(client_name)

    if args.run_env:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).run_environment(client_name)

    if args.stop_cli:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).stop_client(client_name)

    if args.run_cli:
        client_name = get_param(args, 'client')
        commands += OdooEnv(options).run_client(client_name)

    if args.update:
        client_name = get_param(args, 'client')
        database = get_param(args, 'database')
        modules = get_param(args, 'module')
        commands += OdooEnv(options).update(client_name, database, modules)

    if args.quality_assurance:
        client_name = get_param(args, 'client')
        database = get_param(args, 'database')
        commands += OdooEnv(options).qa(client_name, database,
                                        args.quality_assurance[0])
    if args.version:
        Msg().inf('oe version %s' % __version__)
        exit()

    # Verificar la version del script en pypi
    conf = OeConfig()
    conf.check_version()

    # #####################################################################
    # ejecutar comandos
    # ######################################################################
    for command in commands:
        if command and command.check():
            Msg().inf(command.usr_msg)
            command.execute()