Skip to content

Commit

Permalink
Last one 🙏
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkeen authored Dec 11, 2019
1 parent 531e28d commit 4fdf07e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions update_varnish_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import boto3
import os
import io
import json
import paramiko
import jinja2
from io import StringIO


from datetime import datetime

Expand All @@ -30,7 +31,7 @@ def handle(event, context):
backend_template_vars['varnish_backend_instances_extra'] = [{'private_ip_address': ip, 'instance_id': 'ext' + ip.replace('.', '')} for ip in extra_hosts]
backend_vcl = jinja2.Environment(loader=jinja2.BaseLoader).from_string(backend_template).render(**backend_template_vars)

ssh_key = paramiko.RSAKey.from_private_key(StringIO.StringIO(ssh_key))
ssh_key = paramiko.RSAKey.from_private_key(io.StringIO(ssh_key))

for host in varnish_hosts:
ssh_client = paramiko.SSHClient()
Expand All @@ -41,7 +42,7 @@ def handle(event, context):

print('Copying new backends vcl to %s ...' % new_vcl_name)
sftp = ssh_client.open_sftp()
sftp.putfo(StringIO.StringIO(backend_vcl), new_vcl_name)
sftp.putfo(io.StringIO(backend_vcl), new_vcl_name)

print('Updating vcls...')
execute_command(ssh_client, 'sudo /usr/bin/varnish_update_backends %s' % new_vcl_name)
Expand Down

0 comments on commit 4fdf07e

Please sign in to comment.