aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-23 21:05:04 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-05-23 21:11:40 +0300
commit4d471baad6dced77bdc02195943864550ea70706 (patch)
tree2c6fd5357d61d2edb9f8e7bf0ed924d761f0d352
parent346a9c151b67bf550102da5247475e2a32b7ad84 (diff)
downloadlinaro-aws-tools-4d471baad6dced77bdc02195943864550ea70706.tar.gz
linaro-ami: Allow to specify root device size of created AMI.
This is initial step to address SYS-7: to cache Android checkout in an AMI, we need to have space for it. This feature requires boto version fresher than shipped in Ubuntu 12.04. Change-Id: Ib1cc629ae4dfb9c24ab02c25184366b3577ec213
-rw-r--r--linaro-ami/README11
-rw-r--r--linaro-ami/aws_controller.py14
-rw-r--r--linaro-ami/linaro-ami.conf11
-rw-r--r--linaro-ami/linaro_ami.py3
4 files changed, 33 insertions, 6 deletions
diff --git a/linaro-ami/README b/linaro-ami/README
index e21a684..ec4f425 100644
--- a/linaro-ami/README
+++ b/linaro-ami/README
@@ -8,10 +8,17 @@ the AMI based on that instance.
Dependencies
------------
-You need the boto (>2.0) and paramiko Python modules (Ubuntu python-boto and
+You need the boto (>=2.20) and paramiko Python modules (Ubuntu python-boto and
python-paramiko packages) to use these scripts.
- $ apt-get install python-boto python-paramiko
+Ubuntu 14.04 should have fresh enough boto package, for earlier versions, you
+may need to use PPA:
+
+ $ sudo add-apt-repository ppa:chris-lea/python-boto; sudo apt-get update
+
+To install packages:
+
+ $ sudo apt-get install python-boto python-paramiko
Setting up AWS credentials
diff --git a/linaro-ami/aws_controller.py b/linaro-ami/aws_controller.py
index 1ffc703..29c77dc 100644
--- a/linaro-ami/aws_controller.py
+++ b/linaro-ami/aws_controller.py
@@ -1,8 +1,10 @@
-import boto
import logging
import sys
import time
+import boto
+from boto.ec2.blockdevicemapping import BlockDeviceMapping, BlockDeviceType
+
class InstanceRunFailedError(Exception):
"""Instance still not running after waiting for it to start."""
@@ -80,12 +82,18 @@ class AwsController:
"""Start an already running instance."""
self._connection.start_instances([instance_id])
- def create_image(self, instance_id, name, description):
+ def create_image(self, instance_id, name, description, root_size):
"""Create image from an instance.
Returns image id as string.
"""
- return self._connection.create_image(instance_id, name, description)
+ dev_sda1 = BlockDeviceType()
+ dev_sda1.size = root_size
+ dev_sda1.delete_on_termination = True
+ bdm = BlockDeviceMapping()
+ bdm["/dev/sda1"] = dev_sda1
+ return self._connection.create_image(instance_id, name, description,
+ block_device_mapping=bdm)
def list_images(self):
"""List all images owned by current user."""
diff --git a/linaro-ami/linaro-ami.conf b/linaro-ami/linaro-ami.conf
index 24411d7..c75e398 100644
--- a/linaro-ami/linaro-ami.conf
+++ b/linaro-ami/linaro-ami.conf
@@ -7,6 +7,8 @@ instance_type = t1.micro
log_file = linaro-ami.log
vcs_install = sudo apt-get --assume-yes install bzr git
key_name = linaro-ami-key
+# GB
+root_size = 8
[ab-natty-64bit]
base_ami = ami-87c31aee
@@ -20,6 +22,15 @@ init_script_fetch = git clone http://git.linaro.org/git/infrastructure/linaro-an
init_script = node/setup-build-android
description = Build Slave AMI for android-build.linaro.org based on Precise 64bit
+[ab-precise-64bit-seed]
+base_ami = ami-23d9a94a
+init_script_fetch = git clone http://git.linaro.org/git/infrastructure/linaro-android-build-tools.git
+#init_script = node/setup-build-android
+init_script = /bin/true
+description = Build Slave AMI for android-build.linaro.org based on Precise 64bit with Android repo seed
+# GB
+root_size = 15
+
[ci-natty-64bit]
base_ami = ami-87c31aee
init_script_repo = lp:~linaro-infrastructure/linaro-ci/lci-build-tools
diff --git a/linaro-ami/linaro_ami.py b/linaro-ami/linaro_ami.py
index 76c92a9..273ffad 100644
--- a/linaro-ami/linaro_ami.py
+++ b/linaro-ami/linaro_ami.py
@@ -110,7 +110,8 @@ class LinaroAMI:
descr += " | " + self.options.descr
ami_id = self.aws.create_image(
instance.id, ami_name + "-" + iso_timestamp(),
- descr)
+ descr,
+ root_size=self.config.get(ami_name, "root_size", 8))
self.aws.create_tags([ami_id],
{"Name": ami_name, "Type": DEFAULT_AMI_TYPE})