Beispiel #1
0
 def __init__(self, conf):
     self._conf = conf
     self.base_dir = os.path.abspath(file_utils.find_base_dir())
     self.type_name = None
     self._enabled = self._conf.get('enabled', True)
     if not self._enabled:
         LOG.warn('Service %s disabled', self._conf['name'])
Beispiel #2
0
    def test_get_status_deps_done(self, m_zk_c):
        m_zk_c.return_value.__enter__.return_value = self.client
        config_path = os.path.join(
            file_utils.find_base_dir(), 'services/cinder')
        tasks = commands.get_tasks(config_path)
        # just get what we want for the test
        test_tasks = {'cinder-api/db_sync':
                      tasks['cinder-api/db_sync']}
        var = '/kolla/test/status'
        at = '%s/cinder_ansible_tasks' % var
        exp = {
            'register': ('%s/cinder-api/db_sync' % var, ''),
            'requirements': {
                '%s/create_database' % at: 'done',
                '%s/database_user_create' % at: 'done'}}

        # create the done states
        self.client.create(
            '%s/cinder_ansible_tasks/create_database' % var,
            'done'.encode('utf-8'), makepath=True)
        self.client.create(
            '%s/cinder_ansible_tasks/database_user_create' % var,
            'done'.encode('utf-8'), makepath=True)

        status = commands.get_status(test_tasks)
        self.assertEqual({'cinder-api/db_sync': exp}, status)
Beispiel #3
0
 def __init__(self):
     self.base_dir = os.path.abspath(file_utils.find_base_dir())
     self.config_dir = os.path.join(self.base_dir, 'config')
     LOG.debug("Kolla-Mesos base directory: %s" % self.base_dir)
     self.required_vars = {}
     self.marathon_client = marathon.Client()
     self.chronos_client = chronos.Client()
     self.start_time = time.time()
Beispiel #4
0
    def test_get_tasks_sanity(self):
        var = '/kolla/test/status'
        exp = {'register': '%s/cinder-api/db_sync' % var,
               'requires': [
                   '%s/cinder_ansible_tasks/create_database' % var,
                   '%s/cinder_ansible_tasks/database_user_create' % var]}

        config_path = os.path.join(
            file_utils.find_base_dir(), 'services/cinder')
        tasks = commands.get_tasks(config_path)
        self.assertEqual(exp, tasks['cinder-api/db_sync'])
Beispiel #5
0
def get_tasks(deploy_id):
    """Get list of tasks

    Reads through all the kolla mesos services config files and
    parses the requirements and resister options.

    Returns a dictionary of all the values registered by tasks
    {
    taskpath1: {
      'requires': [require1, require2...]
      'register': register_path
      }
    }

    taskpath examples -
      'keystone/keystone/db_sync',
      'keystone/keystone_ansible_tasks/create_database',
    """

    def get_task_from_cmd(role, cmd, cmd_info):
        reg = '/kolla/%s/status/%s/%s/.done' % (deploy_id, role, cmd)
        task = {'register': reg, 'requires': []}
        for dep in cmd_info.get('dependencies', []):
            task['requires'].append(
                '/kolla/%s/status/%s/.done' % (deploy_id, dep))
        return task

    tasks = {}
    config_dir = os.path.join(file_utils.find_base_dir(), 'services')
    for root, _, files in os.walk(config_dir):
        for name in files:
            if 'default.' in name:
                continue
            fpath = os.path.join(root, name)
            mini_vars = {'cinder_volume_driver': 'lvm',
                         'deployment_id': deploy_id}
            cfg = yaml.load(jinja_utils.jinja_render(fpath, mini_vars))

            def get_commands():
                for cmd in cfg.get('commands', {}):
                    yield cmd, cfg['commands'][cmd]
                if 'service' in cfg:
                    yield 'daemon', cfg['service']['daemon']

            _, group, role = cfg['name'].split('/')
            for cmd, cmd_info in get_commands():
                task_name = '/%s/%s/%s' % (group, role, cmd)
                tasks[task_name] = get_task_from_cmd(role, cmd,
                                                     cmd_info)
    return tasks
 def __init__(self):
     self.base_dir = os.path.abspath(file_utils.find_base_dir())
     self.config_dir = os.path.join(self.base_dir, 'config')
     LOG.debug("Kolla-Mesos base directory: " + self.base_dir)
     self.required_vars = {}
     self.marathon_client = marathon.create_client()
Beispiel #7
0
 def __init__(self, conf, name, service_name):
     self._conf = conf
     self._name = name
     self._service_name = service_name
     self.base_dir = os.path.abspath(file_utils.find_base_dir())
Beispiel #8
0
VERSION = '1.0'
CONF = cfg.CONF
CONF.import_group('kolla', 'kolla_mesos.config.kolla')
CONF.import_group('profiles', 'kolla_mesos.config.profiles')
CONF.import_group('zookeeper', 'kolla_mesos.config.zookeeper')
CONF.import_group('marathon', 'kolla_mesos.config.marathon')
CONF.import_group('chronos', 'kolla_mesos.config.chronos')
CONF.import_group('mesos', 'kolla_mesos.config.mesos')
CONF.import_opt('workers', 'kolla_mesos.config.multiprocessing_cli')

cli_opts = [
    cfg.StrOpt('service-dir',
               default=utils.env(
                   'KM_SERVICE_DIR', default=os.path.join(
                       file_utils.find_base_dir(), 'services')),
               help='Directory with services, (Env: KM_SERVICE_DIR)'),
]
CONF.register_cli_opts(cli_opts)

CMD_LIST = ('--version', '-v', '--verbose', '-q', '--quiet', '--debug')


class KollaMesosInteractiveApp(interactive.InteractiveApp):
    def do_list(self, arg):
        self.default(arg)

    def do_show(self, arg):
        self.default(arg)

    def do_run(self, arg):
 def test_when_is_a_test(self):
     tdir = file_utils.find_base_dir()
     self.assertEqual(self.project_dir, tdir)
 def test_when_is_a_test(self):
     mod_dir = os.path.dirname(sys.modules[__name__].__file__)
     project_dir = os.path.abspath(os.path.join(mod_dir, '..', '..', '..'))
     tdir = file_utils.find_base_dir()
     self.assertEqual(project_dir, tdir)