示例#1
0
 def __call__(self):
     import jujuresources
     result = True
     if not jujuresources.verify(self.which):
         mirror_url = hookenv.config('resources_mirror')
         hookenv.status_set('maintenance', 'Fetching resources')
         result = jujuresources.fetch(self.which, mirror_url=mirror_url)
         if not result:
             missing = jujuresources.invalid(self.which)
             hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
                 's' if len(missing) > 1 else '',
                 ', '.join(missing),
             ))
     return result
示例#2
0
 def __call__(self):
     import jujuresources
     result = True
     if not jujuresources.verify(self.which):
         mirror_url = hookenv.config('resources_mirror')
         hookenv.status_set('maintenance', 'Fetching resources')
         result = jujuresources.fetch(self.which, mirror_url=mirror_url)
         if not result:
             missing = jujuresources.invalid(self.which)
             hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
                 's' if len(missing) > 1 else '',
                 ', '.join(missing),
             ))
     return result
示例#3
0
def bootstrap():
    hookenv.status_set('maintenance', 'Installing base resources')
    apt_install(['python-pip', 'git'])  # git used for testing unreleased version of libs
    check_call(['pip', 'install', '-U', 'pip'])  # 1.5.1 (trusty) pip fails on --download with git repos
    mirror_url = hookenv.config('resources_mirror')
    if not jujuresources.fetch(mirror_url=mirror_url):
        missing = jujuresources.invalid()
        hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
            's' if len(missing) > 1 else '',
            ', '.join(missing),
        ))
        return
    jujuresources.install(['pathlib', 'jujubigdata'])
    set_state('bootstrapped')
示例#4
0
    def __call__(self):
        import jujuresources

        result = True
        if not jujuresources.verify(self.which):
            mirror_url = hookenv.config("resources_mirror")
            hookenv.status_set("maintenance", "Fetching resources")
            result = jujuresources.fetch(self.which, mirror_url=mirror_url)
            if not result:
                missing = jujuresources.invalid(self.which)
                hookenv.status_set(
                    "blocked",
                    "Unable to fetch required resource%s: %s" % ("s" if len(missing) > 1 else "", ", ".join(missing)),
                )
        return result
示例#5
0
def bootstrap_resources():
    """
    Attempt to load and install resources defined in resources.yaml
    """
    if unitdata.kv().get('charm.bootstrapped', False):
        return True
    hookenv.status_set('maintenance', 'Installing base resources')
    mirror_url = jujuresources.config_get('resources_mirror')
    if not jujuresources.fetch(mirror_url=mirror_url):
        missing = jujuresources.invalid()
        hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
            's' if len(missing) > 1 else '',
            ', '.join(missing),
        ))
        return False
    jujuresources.install(['pathlib', 'jujubigdata'])
    unitdata.kv().set('charm.bootstrapped', True)
    return True
示例#6
0
def bootstrap_resources():
    """
    Install required resources defined in resources.yaml
    """
    if unitdata.kv().get('charm.bootstrapped', False):
        return True
    hookenv.status_set('maintenance', 'Installing base resources')
    mirror_url = jujuresources.config_get('resources_mirror')
    if not jujuresources.fetch(mirror_url=mirror_url):
        missing = jujuresources.invalid()
        hookenv.status_set('blocked', 'Unable to fetch required resource%s: %s' % (
            's' if len(missing) > 1 else '',
            ', '.join(missing),
        ))
        return False
    jujuresources.install(['pathlib', 'jujubigdata'])
    unitdata.kv().set('charm.bootstrapped', True)
    return True