def update(self, resources): Driver.update(self, resources) if not resources: return # Get the templates directory. templates_dir = os.path.dirname(os.path.realpath(__file__)) + \ self._get_config_value('templates_path') templates_dir = os.path.realpath(templates_dir) # Setup template environment. env = Environment(loader=FileSystemLoader(templates_dir)) template = env.get_template(self._get_config_value('template_name')) # Switch this to load out of current_state. rendered_result = template.render({'resources': resources}) # Save to file. filename = '%s/%s' % (self._get_config_value('vcl_output_path'), self._get_config_value('vcl_output_name')) filename = os.path.realpath(filename) f = open(filename, "w") f.write(rendered_result) f.close() logging.debug(rendered_result) # Bounce the varnish config if self._config.getboolean(self._config_section, 'varnish_reload'): subprocess.call('service varnishd reload')
def update(self, resources): Driver.update(self, resources) if not resources: return # Get the templates directory. templates_dir = os.path.dirname(os.path.realpath(__file__)) + '/../../templates' templates_dir = os.path.realpath(templates_dir) # Setup template environment. env = Environment(loader=FileSystemLoader(templates_dir)) # @todo - Ben - Make a config param for this. template = env.get_template('backend.vcl') # Switch this to load out of current_state. rendered_result = template.render({'resources': resources}) # Save to file. # @todo - Ben - Make a config param for where to save to. logging.debug(rendered_result)
def update(self, resources): Driver.update(self, resources) if not resources: return ''' Get the templates directory. ''' templates_dir = os.path.dirname(os.path.realpath(__file__)) + '/../../templates' templates_dir = os.path.realpath(templates_dir) ''' Setup template environment. ''' env = Environment(loader=FileSystemLoader(templates_dir)) ''' Todo - Ben - Make a config param for this. ''' template = env.get_template('backend.vcl') ''' Switch this to load out of current_state. ''' rendered_result = template.render({'resources': resources}) ''' Save to file. ''' ''' Todo - Ben - Make a config param for where to save to. ''' print rendered_result ''' Reload the varnish config '''
def __init__(self, config): Driver.__init__(self, config)
def update(self, current_state): Driver.update(self, current_state)