示例#1
0
    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')
示例#2
0
    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)
示例#3
0
    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 '''
示例#4
0
 def __init__(self, config):
     Driver.__init__(self, config)
示例#5
0
 def update(self, current_state):
     Driver.update(self, current_state)