Пример #1
0
 def get_first(self, *paths):
     result = self._get_first(*paths)
     if result:
         return result
     else:
         return jinja2.StrictUndefined('Nothing found matching paths: %s' %
                                       ','.join(paths))
Пример #2
0
def configure(application,
              title=None,
              copyright=None,
              version=None,
              date=None):  # pylint: disable = redefined-builtin
    application.config[
        "WEBSITE_TITLE"] = title if title is not None else "Job Orchestra"
    application.config[
        "WEBSITE_COPYRIGHT"] = copyright if copyright is not None else bhamon_orchestra_website.__copyright__
    application.config[
        "WEBSITE_VERSION"] = version if version is not None else bhamon_orchestra_website.__version__
    application.config[
        "WEBSITE_DATE"] = date if date is not None else bhamon_orchestra_website.__date__

    application.jinja_env.undefined = jinja2.StrictUndefined()
    application.jinja_env.trim_blocks = True
    application.jinja_env.lstrip_blocks = True
    application.jinja_env.filters[
        "build_pipeline_view"] = pipeline_view.build_pipeline_view
    application.jinja_env.filters[
        "describe_cron_expression"] = helpers.describe_cron_expression
    application.jinja_env.filters["truncate_text"] = helpers.truncate_text
    application.jinja_env.globals["authorize_view"] = authorize_view
    application.permanent_session_lifetime = datetime.timedelta(days=7)
    application.session_refresh_interval = datetime.timedelta(days=1)
Пример #3
0
    def get(self, *, kind=None, name=None, schema=None):
        result = _get(self.documents, kind=kind, schema=schema, name=name)

        if result:
            return result['data']
        else:
            return jinja2.StrictUndefined(
                'No document found matching kind=%s schema=%s name=%s' %
                (kind, schema, name))
Пример #4
0
    def kubelet_name(self):
        for document in self.iterate(kind='Genesis'):
            return 'genesis'

        for document in self.iterate(kind='KubernetesNode'):
            return document['data']['hostname']

        return jinja2.StrictUndefined(
            'No Genesis or KubernetesNode found while getting kubelet name')
Пример #5
0
 def join_ips(self):
     maybe_ips = self.get_path('KubernetesNode:join_ips')
     if maybe_ips is not None:
         return maybe_ips
     else:
         maybe_ip = self._get_first('KubernetesNode:join_ip', 'Genesis:ip')
         if maybe_ip:
             return [maybe_ip]
         else:
             return jinja2.StrictUndefined('Could not find join IPs')
Пример #6
0
 def __getitem__(self, path):
     value = self.get_path(path)
     if value:
         return value
     else:
         return jinja2.StrictUndefined('No match found for path %s' % path)
Пример #7
0
 def __getitem__(self, path):
     return self.get_path(
         path, jinja2.StrictUndefined('No match found for path %s' % path))