Write the Nginx configuration file for this Site

def write_nginx_config(self):
        """
        Write the Nginx configuration file for this Site
        """
        log = logging.getLogger('ipsv.models.sites.site')
        if not os.path.exists(self.root):
            log.debug('Creating HTTP root directory: %s', self.root)
            os.makedirs(self.root, 0o755)

        # Generate our server block configuration
        server_block = ServerBlock(self)

        server_config_path = os.path.join(_cfg.get('Paths', 'NginxSitesAvailable'), self.domain.name)
        if not os.path.exists(server_config_path):
            log.debug('Creating new configuration path: %s', server_config_path)
            os.makedirs(server_config_path, 0o755)

        server_config_path = os.path.join(server_config_path, '{fn}.conf'.format(fn=self.slug))
        if os.path.exists(server_config_path):
            log.info('Server block configuration file already exists, overwriting: %s', server_config_path)
            os.remove(server_config_path)

        log.info('Writing Nginx server block configuration file')
        with open(server_config_path, 'w') as f:
            f.write(server_block.template)