1
2
3
4
5 from boto.resultset import ResultSet
6 -def register_image(conn, name=None, description=None, image_location=None,
7 architecture=None, kernel_id=None, ramdisk_id=None,
8 root_device_name=None, block_device_map=None):
9 """
10 Register an image.
11
12 :type name: string
13 :param name: The name of the AMI. Valid only for EBS-based images.
14
15 :type description: string
16 :param description: The description of the AMI.
17
18 :type image_location: string
19 :param image_location: Full path to your AMI manifest in Amazon S3 storage.
20 Only used for S3-based AMI's.
21
22 :type architecture: string
23 :param architecture: The architecture of the AMI.
24 Valid choices are: i386 | x86_64
25
26 :type kernel_id: string
27 :param kernel_id: The ID of the kernel with which to launch the instances
28
29 :type root_device_name: string
30 :param root_device_name: The root device name (e.g. /dev/sdh)
31
32 :type block_device_map: :class:`boto.ec2.blockdevicemapping.BlockDeviceMapping`
33 :param block_device_map:
34 A BlockDeviceMapping data structure describing the EBS volumes associated
35 with the Image.
36
37 :rtype: string
38 :return: The new image id
39 """
40 params = {}
41 if name:
42 params['Name'] = name
43 if description:
44 params['Description'] = description
45 if architecture:
46 params['Architecture'] = architecture
47 if kernel_id:
48 params['KernelId'] = kernel_id
49 if ramdisk_id:
50 params['RamdiskId'] = ramdisk_id
51 if image_location:
52 params['ImageLocation'] = image_location
53 if root_device_name:
54 params['RootDeviceName'] = root_device_name
55 if block_device_map:
56 block_device_map.build_list_params(params)
57 rs = conn.get_object('RegisterImage', params, ResultSet)
58 image_id = getattr(rs, 'imageId', None)
59 return image_id
60