|
10 | 10 | parser.add_argument('--version', help='the CoreOS version to use', default='current') |
11 | 11 | args = vars(parser.parse_args()) |
12 | 12 |
|
13 | | -url = "http://{channel}.release.core-os.net/amd64-usr/{version}/coreos_production_ami_all.json".format(**args) |
14 | | -try: |
15 | | - amis = json.load(urllib2.urlopen(url)) |
16 | | -except (IOError, ValueError): |
17 | | - print "The URL {} is invalid.".format(url) |
18 | | - raise |
19 | | - |
20 | 13 | CURR_DIR = os.path.dirname(os.path.realpath(__file__)) |
21 | 14 |
|
22 | 15 | # Add AWS-specific units to the shared user-data |
|
85 | 78 | After=prepare-etcd-data-directory.service |
86 | 79 | ''' |
87 | 80 |
|
| 81 | +def coreos_amis(channel, version): |
| 82 | + url = "http://{channel}.release.core-os.net/amd64-usr/{version}/coreos_production_ami_all.json".format(channel=channel, version=version) |
| 83 | + try: |
| 84 | + amis = json.load(urllib2.urlopen(url)) |
| 85 | + except (IOError, ValueError): |
| 86 | + print "The URL {} is invalid.".format(url) |
| 87 | + raise |
| 88 | + |
| 89 | + return dict(map(lambda n: (n['name'], dict(PV=n['pv'], HVM=n['hvm'])), amis['amis'])) |
| 90 | + |
88 | 91 | new_units = [ |
89 | 92 | dict({'name': 'format-docker-volume.service', 'command': 'start', 'content': FORMAT_DOCKER_VOLUME}), |
90 | 93 | dict({'name': 'var-lib-docker.mount', 'command': 'start', 'content': MOUNT_DOCKER_VOLUME}), |
|
112 | 115 |
|
113 | 116 | template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = ["\n", header + dump.split("\n")] |
114 | 117 | template['Parameters']['ClusterSize']['Default'] = str(os.getenv('DEIS_NUM_INSTANCES', 3)) |
115 | | -template['Mappings']['CoreOSAMIs'] = dict(map(lambda n: (n['name'], dict(PV=n['pv'], HVM=n['hvm'])), amis['amis'])) |
| 118 | +template['Mappings']['CoreOSAMIs'] = coreos_amis(args['channel'], args['version']) |
116 | 119 |
|
117 | 120 | VPC_ID = os.getenv('VPC_ID', None) |
118 | 121 | VPC_SUBNETS = os.getenv('VPC_SUBNETS', None) |
|
0 commit comments