Esempio n. 1
0
    def test_get_available_services(self):
        from shutil import rmtree
        from stakkr import file_utils

        # Original stakkr lib path
        stakkr_path = file_utils.get_lib_basedir()
        # Local static test files path
        static_path = os.path.dirname(os.path.realpath(__file__)) + '/static'
        rmtree(static_path + '/services/db', ignore_errors=True)
        rmtree(static_path + '/services/databases', ignore_errors=True)
        rmtree(static_path + '/services/php', ignore_errors=True)

        add_emails = [
            'stakkr', '-c', base_dir + '/static/stakkr.yml', 'services-add',
            'emails'
        ]
        subprocess.Popen(add_emails,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)

        services = sc.get_available_services(static_path)
        self.assertFalse('apache' in services)
        self.assertFalse('mongo' in services)
        self.assertFalse('elasticsearch' in services)
        self.assertTrue('php' in services)
        self.assertTrue('portainer' in services)
        self.assertTrue('maildev' in services)

        self.assertEqual(stakkr_path + '/static/services/portainer.yml',
                         services['portainer'])
        self.assertEqual(static_path + '/services/test/docker-compose/php.yml',
                         services['php'])
Esempio n. 2
0
    def test_get_available_services(self):
        services = sc.get_available_services()
        self.assertTrue('apache' in services)
        self.assertTrue('mongo' in services)
        self.assertTrue('php' in services)
        self.assertTrue('elasticsearch' in services)

        self.assertEqual('static/services/apache.yml', services['apache'][-26:])
        self.assertEqual('static/services/mongo.yml', services['mongo'][-25:])
Esempio n. 3
0
def services(ctx):
    """See command Help."""
    from stakkr.stakkr_compose import get_available_services

    print('Available services usable in compose.ini ', end='')
    print('({} = currently in use) : '.format(click.style('✔', fg='green')))

    enabled_services = ctx.obj['STAKKR']._get_config()['main']['services']
    for available_service in sorted(list(get_available_services().keys())):
        sign = click.style('✘', fg='red')
        if available_service in enabled_services:
            sign = click.style('✔', fg='green')

        print('  - {} ({})'.format(available_service, sign))
Esempio n. 4
0
def services(ctx):
    """See command Help."""
    ctx.obj['STAKKR'].init_project()

    from stakkr.stakkr_compose import get_available_services

    print('Available services usable in stakkr.yml ', end='')
    print('({} = disabled) : '.format(click.style('✘', fg='red')))

    svcs = ctx.obj['STAKKR'].get_config()['services']
    enabled_svcs = [
        svc for svc, opts in svcs.items() if opts['enabled'] is True
    ]
    available_svcs = get_available_services(ctx.obj['STAKKR'].project_dir)
    for available_svc in sorted(list(available_svcs.keys())):
        sign = click.style('✘', fg='red')
        if available_svc in enabled_svcs:
            version = svcs[available_svc]['version']
            sign = click.style(str(version), fg='green')

        print('  - {} ({})'.format(available_svc, sign))
    def test_get_available_services(self):
        from shutil import rmtree

        stakkr_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + '/stakkr'
        static_path = os.path.dirname(os.path.realpath(__file__)) + '/static'
        rmtree(static_path + '/services/db', ignore_errors=True)
        rmtree(static_path + '/services/databases', ignore_errors=True)
        rmtree(static_path + '/services/php', ignore_errors=True)

        add_emails = ['stakkr', '-c', base_dir + '/static/stakkr.yml', 'services-add', 'emails']
        subprocess.Popen(add_emails, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

        services = sc.get_available_services(static_path)
        self.assertFalse('apache' in services)
        self.assertFalse('mongo' in services)
        self.assertFalse('elasticsearch' in services)
        self.assertTrue('php' in services)
        self.assertTrue('portainer' in services)
        self.assertTrue('maildev' in services)

        self.assertEqual(stakkr_path + '/static/services/portainer.yml', services['portainer'])
        self.assertEqual(static_path + '/services/test/docker-compose/php.yml', services['php'])