Skip to content

Commit

Permalink
Merge branch 'release/2.6.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
flibbertigibbet committed Mar 4, 2019
2 parents b8ef54a + de2e7ea commit 6bfce0e
Show file tree
Hide file tree
Showing 10 changed files with 1,315 additions and 2,030 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ root_static_dir: "/srv/cac"
root_media_dir: "/media/cac"

cac_python_dependencies:
- { name: 'base58', version: '1.0.2' }
- { name: 'base58', version: '1.0.3' }
- { name: 'boto', version: '2.49.0' }
- { name: 'django', version: '1.11.18' }
- { name: 'django', version: '1.11.20' }
- { name: 'django-ckeditor', version: '5.6.1' }
- { name: 'django-image-cropping', version: '1.2.0' }
- { name: 'django-extensions', version: '1.9.9' }
Expand Down
8 changes: 5 additions & 3 deletions deployment/cac-stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def launch_stacks(cac_config, creds, stack_type, stack_color, **kwargs):
delete_creds()


def create_ami(machine_type, aws_region, creds, **kwargs):
def create_ami(machine_type, aws_region, creds, aws_config, **kwargs):
"""Creates the specified AMI(s)
Args:
machine_type (str): Optional type of AMI to build (all are built if unspecified)
aws_region (str): AWS region id
creds (Dict): Dictionary containing AWS credentials
"""
run_packer(machine_type, aws_region, creds)
run_packer(machine_type, aws_region, creds, aws_config)


def main():
Expand Down Expand Up @@ -97,8 +97,10 @@ def main():
args = parser.parse_args()
creds = get_creds(args.aws_access_key_id, args.aws_secret_access_key,
args.aws_role_arn)
aws_config = {'aws_access_key_id': args.aws_access_key_id,
"aws_secret_access_key": args.aws_secret_access_key}
cac_config = get_config(args.cac_config_path, args.cac_profile)
args.func(cac_config=cac_config, creds=creds, **vars(args))
args.func(cac_config=cac_config, creds=creds, aws_config=aws_config, **vars(args))

if __name__ == '__main__':
main()
46 changes: 21 additions & 25 deletions deployment/packer/cac_packer.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
"""Helper stuff to deal with packer"""

import csv
import os
import subprocess
import urllib2
import shutil

from boto import ec2

CANONICAL_ACCOUNT_ID = '099720109477'


class CacStackException(Exception):
pass


def get_ubuntu_ami(region):
def get_ubuntu_ami(region, creds):
"""Gets AMI ID for current release in region
Args:
region (str): AWS region id
creds (Dict): Dictionary containing AWS credentials
"""

response = urllib2.urlopen('http://cloud-images.ubuntu.com/query/trusty/'
'server/released.current.txt').readlines()
fieldnames = ['version', 'version_type', 'release_status', 'date',
'storage', 'arch', 'region', 'id', 'kernel',
'unknown_col', 'virtualization_type']
reader = csv.DictReader(response, fieldnames=fieldnames, delimiter='\t')

def ami_filter(ami):
"""Helper function to filter AMIs"""
return (ami['region'] == region and
ami['arch'] == 'amd64' and
ami['storage'] == 'ebs-ssd' and
ami['virtualization_type'] == 'hvm')

amis = [row for row in reader if ami_filter(row)]
conn = ec2.connect_to_region(region, **creds)
amis = conn.get_all_images(owners=[CANONICAL_ACCOUNT_ID], filters={
'name': 'ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*',
'architecture': 'x86_64',
'root-device-type': 'ebs',
'virtualization-type': 'hvm',
})

amis = sorted(amis, key=lambda ami: ami.creationDate, reverse=True)

if len(amis) == 0:
raise CacStackException('Did not find any ubuntu AMIs to use')
elif len(amis) > 1:
raise CacStackException('Found multiple ubuntu AMIs to use, should only be one')
return amis[0]['id']
return amis[0].id


def run_packer(machine_type, region, creds):
def run_packer(machine_type, region, creds, aws_config):
"""Runs packer command to build the desired AMI(s)
Args:
Expand All @@ -58,13 +54,13 @@ def run_packer(machine_type, region, creds):
print('Removing {}'.format(examples_path))
shutil.rmtree(examples_path)

aws_ubuntu_ami = get_ubuntu_ami(region)

env = os.environ.copy()
env['AWS_ACCESS_KEY_ID'] = creds['aws_access_key_id']
env['AWS_SECRET_ACCESS_KEY'] = creds['aws_secret_access_key']
env['AWS_SESSION_TOKEN'] = creds['aws_security_token']

aws_ubuntu_ami = get_ubuntu_ami(region, aws_config)

packer_template_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'cac.json')
packer_command = ['packer', 'build',
'-var', 'aws_region={}'.format(region),
Expand All @@ -78,4 +74,4 @@ def run_packer(machine_type, region, creds):
packer_command.append(packer_template_path)

print 'Running Packer Command: {}'.format(' '.join(packer_command))
subprocess.check_call(packer_command, env=env)
subprocess.check_call(packer_command, env=env)
2 changes: 1 addition & 1 deletion python/cac_tripplanner/destinations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DestinationAdmin(ImageCroppingMixin, gis.admin.OSMGeoAdmin):
map_template = 'admin/cac-geocoding-map.html'

# Include geocoder dependencies
jquery = 'https://code.jquery.com/jquery-3.2.1.min.js'
jquery = 'https://code.jquery.com/jquery-3.3.1.min.js'
if settings.DEBUG:
extra_js = [
jquery,
Expand Down
2 changes: 1 addition & 1 deletion python/cac_tripplanner/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

{% block jsimports %}

<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
jQuery.noConflict(); // because JotForms.
</script>
Expand Down
2 changes: 1 addition & 1 deletion python/cac_tripplanner/templates/service-worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Service Worker to support functioning as a PWA
// https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers

var CACHE_NAME = 'cac_tripplanner_v19';
var CACHE_NAME = 'cac_tripplanner_v20';

var cacheFiles = {{ cache_files | safe }};

Expand Down
2 changes: 1 addition & 1 deletion src/app/scripts/cac/control/cac-control-itinerary-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CAC.Control.ItineraryList = (function (_, $, MapTemplates) {
dots: true,
infinite: false,
mobileFirst: true,
variableWidth: true,
variableWidth: false,
adaptiveHeight: true,
responsive : [
{
Expand Down
6 changes: 3 additions & 3 deletions src/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"private": true,
"dependencies": {
"console-polyfill": "~0.3.0",
"handlebars": "~4.0.12",
"handlebars": "~4.1.0",
"jquery": "~3.3.1",
"leaflet": "~0.7.7",
"cartodb.js": "~3.15.17",
"js-storage": "~1.0.4",
"Leaflet.awesome-markers": "~2.0.2",
"Leaflet.encoded": "~0.0.8",
"moment": "~2.22.2",
"moment": "~2.24.0",
"moment-duration-format": "~2.2.2",
"lodash": "~4.17.11",
"spinkit": "~1.2.5",
"typeahead.js": "~0.10.5",
"slick-carousel": "~1.8.1",
"riot-route": "^3.1.4"
"riot-route": "~3.1.4"
}
}
Loading

0 comments on commit 6bfce0e

Please sign in to comment.