Commit 37efda8d authored by Łukasz Nowak's avatar Łukasz Nowak

Use dedicated section for networkcache.

If it is possible to use slapos.libnetworkcache check if parameter
networkcache-section exists. If so, try to find section named by this parameter.

Such section has two required parameters: download-cache-url and
download-dir-url. upload-cache-url and upload-dir-url are optional parameters.

Minimalistic profile for networkcache control looks like:

  [buildout]
  parts =

  networkcache-section = readcache

  [readcache]
  download-cache-url = http:///
  download-dir-url = http:///
  #upload-cache-url = http:///
  #upload-dir-url = http:///
parent bd3b9c3b
...@@ -336,6 +336,32 @@ class Buildout(UserDict.DictMixin): ...@@ -336,6 +336,32 @@ class Buildout(UserDict.DictMixin):
os.chdir(options['directory']) os.chdir(options['directory'])
if LIBNETWORKCACHE_ENABLED:
# support networkcache
networkcache_section_name = options.get('networkcache-section')
if networkcache_section_name:
networkcache_section = self[networkcache_section_name]
self.download_cache_url = networkcache_section[
'download-cache-url']
self.download_dir_url = networkcache_section[
'download-dir-url']
self.upload_cache_url = networkcache_section.get(
'upload-cache-url', '')
self.upload_dir_url = networkcache_section.get(
'upload-dir-url', '')
self._logger.info('Networkcache enabled.')
self._logger.info('Networkcache download cache: %r, directory '
'%r' % (self.download_cache_url, self.download_dir_url))
self._logger.info('Networkcache upload cache: %r, directory %r'%
(self.upload_cache_url, self.upload_dir_url))
else:
self._logger.warning('Networkcache functionality not enabled.')
self.download_cache_url = None
self.download_dir_url = None
self.upload_cache_url = None
self.upload_dir_url = None
def _buildout_path(self, name): def _buildout_path(self, name):
if '${' in name: if '${' in name:
return name return name
...@@ -370,8 +396,8 @@ class Buildout(UserDict.DictMixin): ...@@ -370,8 +396,8 @@ class Buildout(UserDict.DictMixin):
newest=self.newest, newest=self.newest,
allow_hosts=self._allow_hosts, allow_hosts=self._allow_hosts,
prefer_final=not self.accept_buildout_test_releases, prefer_final=not self.accept_buildout_test_releases,
sha_cache=options.get('sha-cache'), sha_cache=self.download_cache_url,
sha_dir=options.get('sha-dir'), sha_dir=self.download_dir_url,
) )
# Now copy buildout and setuptools eggs, and record destination eggs: # Now copy buildout and setuptools eggs, and record destination eggs:
...@@ -873,8 +899,8 @@ class Buildout(UserDict.DictMixin): ...@@ -873,8 +899,8 @@ class Buildout(UserDict.DictMixin):
path = [options['develop-eggs-directory']], path = [options['develop-eggs-directory']],
allow_hosts = self._allow_hosts, allow_hosts = self._allow_hosts,
prefer_final=not self.accept_buildout_test_releases, prefer_final=not self.accept_buildout_test_releases,
sha_cache=options.get('sha-cache'), sha_cache=self.download_cache_url,
sha_dir=options.get('sha-cache'), sha_dir=self.download_dir_url,
) )
upgraded = [] upgraded = []
...@@ -1103,8 +1129,8 @@ def _install_and_load(spec, group, entry, buildout): ...@@ -1103,8 +1129,8 @@ def _install_and_load(spec, group, entry, buildout):
newest=buildout.newest, newest=buildout.newest,
allow_hosts=buildout._allow_hosts, allow_hosts=buildout._allow_hosts,
prefer_final=not buildout.accept_buildout_test_releases, prefer_final=not buildout.accept_buildout_test_releases,
sha_dir=buildout_options.get('sha-dir'), sha_cache=self.download_cache_url,
sha_cache=buildout_options.get('sha-cache')) sha_dir=self.download_dir_url)
__doing__ = 'Loading %s recipe entry %s:%s.', group, spec, entry __doing__ = 'Loading %s recipe entry %s:%s.', group, spec, entry
return pkg_resources.load_entry_point( return pkg_resources.load_entry_point(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment