Skip to content

Commit e935c86

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add extended Glance Image properties"
2 parents fd76be4 + a533b50 commit e935c86

File tree

2 files changed

+152
-1
lines changed

2 files changed

+152
-1
lines changed

openstack/image/v2/image.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,94 @@ class Image(resource2.Resource):
121121
#: The location metadata.
122122
metadata = resource2.Body('metadata', type=dict)
123123

124+
# Additional Image Properties
125+
# http://docs.openstack.org/developer/glance/common-image-properties.html
126+
# http://docs.openstack.org/cli-reference/glance-property-keys.html
127+
#: The CPU architecture that must be supported by the hypervisor.
128+
architecture = resource2.Body("architecture")
129+
#: The hypervisor type. Note that qemu is used for both QEMU and
130+
#: KVM hypervisor types.
131+
hypervisor_type = resource2.Body("hypervisor-type")
132+
#: Optional property allows created servers to have a different bandwidth
133+
#: cap than that defined in the network they are attached to.
134+
instance_type_rxtx_factor = resource2.Body("instance_type_rxtx_factor",
135+
type=float)
136+
# For snapshot images, this is the UUID of the server used to
137+
#: create this image.
138+
instance_uuid = resource2.Body('instance_uuid')
139+
#: Specifies whether the image needs a config drive.
140+
#: `mandatory` or `optional` (default if property is not used).
141+
needs_config_drive = resource2.Body('img_config_drive')
142+
#: The ID of an image stored in the Image service that should be used
143+
#: as the kernel when booting an AMI-style image.
144+
kernel_id = resource2.Body('kernel_id')
145+
#: The common name of the operating system distribution in lowercase
146+
os_distro = resource2.Body('os_distro')
147+
#: The operating system version as specified by the distributor.
148+
os_version = resource2.Body('os_version')
149+
#: Secure Boot is a security standard. When the instance starts,
150+
#: Secure Boot first examines software such as firmware and OS by
151+
#: their signature and only allows them to run if the signatures are valid.
152+
needs_secure_boot = resource2.Body('os_secure_boot')
153+
#: The ID of image stored in the Image service that should be used as
154+
#: the ramdisk when booting an AMI-style image.
155+
ramdisk_id = resource2.Body('ramdisk_id')
156+
#: The virtual machine mode. This represents the host/guest ABI
157+
#: (application binary interface) used for the virtual machine.
158+
vm_mode = resource2.Body('vm_mode')
159+
#: The preferred number of sockets to expose to the guest.
160+
hw_cpu_sockets = resource2.Body('hw_cpu_sockets', type=int)
161+
#: The preferred number of cores to expose to the guest.
162+
hw_cpu_cores = resource2.Body('hw_cpu_cores', type=int)
163+
#: The preferred number of threads to expose to the guest.
164+
hw_cpu_threads = resource2.Body('hw_cpu_threads', type=int)
165+
#: Specifies the type of disk controller to attach disk devices to.
166+
#: One of scsi, virtio, uml, xen, ide, or usb.
167+
hw_disk_bus = resource2.Body('hw_disk_bus')
168+
#: Adds a random-number generator device to the image's instances.
169+
hw_rng_model = resource2.Body('hw_rng_model')
170+
#: For libvirt: Enables booting an ARM system using the specified
171+
#: machine type.
172+
#: For Hyper-V: Specifies whether the Hyper-V instance will be a
173+
#: generation 1 or generation 2 VM.
174+
hw_machine_type = resource2.Body('hw_machine_type')
175+
#: Enables the use of VirtIO SCSI (virtio-scsi) to provide block device
176+
#: access for compute instances; by default, instances use VirtIO Block
177+
#: (virtio-blk).
178+
hw_scsi_model = resource2.Body('hw_scsi_model')
179+
#: Specifies the count of serial ports that should be provided.
180+
hw_serial_port_count = resource2.Body('hw_serial_port_count', type=int)
181+
#: The video image driver used.
182+
hw_video_model = resource2.Body('hw_video_model')
183+
#: Maximum RAM for the video image.
184+
hw_video_ram = resource2.Body('hw_video_ram', type=int)
185+
#: Enables a virtual hardware watchdog device that carries out the
186+
#: specified action if the server hangs.
187+
hw_watchdog_action = resource2.Body('hw_watchdog_action')
188+
#: The kernel command line to be used by the libvirt driver, instead
189+
#: of the default.
190+
os_command_line = resource2.Body('os_command_line')
191+
#: Specifies the model of virtual network interface device to use.
192+
hw_vif_model = resource2.Body('hw_vif_model')
193+
#: If true, this enables the virtio-net multiqueue feature.
194+
#: In this case, the driver sets the number of queues equal to the
195+
#: number of guest vCPUs. This makes the network performance scale
196+
#: across a number of vCPUs.
197+
is_hw_vif_multiqueue_enabled = resource2.Body('hw_vif_multiqueue_enabled',
198+
type=bool)
199+
#: If true, enables the BIOS bootmenu.
200+
is_hw_boot_menu_enabled = resource2.Body('hw_boot_menu', type=bool)
201+
#: The virtual SCSI or IDE controller used by the hypervisor.
202+
vmware_adaptertype = resource2.Body('vmware_adaptertype')
203+
#: A VMware GuestID which describes the operating system installed
204+
#: in the image.
205+
vmware_ostype = resource2.Body('vmware_ostype')
206+
#: If true, the root partition on the disk is automatically resized
207+
#: before the instance boots.
208+
has_auto_disk_config = resource2.Body('auto_disk_config', type=bool)
209+
#: The operating system installed on the image.
210+
os_type = resource2.Body('os_type')
211+
124212
def _action(self, session, action):
125213
"""Call an action on an image ID."""
126214
url = utils.urljoin(self.base_path, self.id, 'actions', action)

openstack/tests/unit/image/v2/test_image.py

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,37 @@
4343
'path': '18',
4444
'value': '19',
4545
'url': '20',
46-
'metadata': {'21': '22'}
46+
'metadata': {'21': '22'},
47+
'architecture': '23',
48+
'hypervisor-type': '24',
49+
'instance_type_rxtx_factor': 25.1,
50+
'instance_uuid': '26',
51+
'img_config_drive': '27',
52+
'kernel_id': '28',
53+
'os_distro': '29',
54+
'os_version': '30',
55+
'os_secure_boot': '31',
56+
'ramdisk_id': '32',
57+
'vm_mode': '33',
58+
'hw_cpu_sockets': 34,
59+
'hw_cpu_cores': 35,
60+
'hw_cpu_threads': 36,
61+
'hw_disk_bus': '37',
62+
'hw_rng_model': '38',
63+
'hw_machine_type': '39',
64+
'hw_scsi_model': '40',
65+
'hw_serial_port_count': 41,
66+
'hw_video_model': '42',
67+
'hw_video_ram': 43,
68+
'hw_watchdog_action': '44',
69+
'os_command_line': '45',
70+
'hw_vif_model': '46',
71+
'hw_vif_multiqueue_enabled': True,
72+
'hw_boot_menu': True,
73+
'vmware_adaptertype': '47',
74+
'vmware_ostype': '48',
75+
'auto_disk_config': True,
76+
'os_type': '49',
4777
}
4878

4979

@@ -95,6 +125,39 @@ def test_make_it(self):
95125
self.assertEqual(EXAMPLE['value'], sot.value)
96126
self.assertEqual(EXAMPLE['url'], sot.url)
97127
self.assertEqual(EXAMPLE['metadata'], sot.metadata)
128+
self.assertEqual(EXAMPLE['architecture'], sot.architecture)
129+
self.assertEqual(EXAMPLE['hypervisor-type'], sot.hypervisor_type)
130+
self.assertEqual(EXAMPLE['instance_type_rxtx_factor'],
131+
sot.instance_type_rxtx_factor)
132+
self.assertEqual(EXAMPLE['instance_uuid'], sot.instance_uuid)
133+
self.assertEqual(EXAMPLE['img_config_drive'], sot.needs_config_drive)
134+
self.assertEqual(EXAMPLE['kernel_id'], sot.kernel_id)
135+
self.assertEqual(EXAMPLE['os_distro'], sot.os_distro)
136+
self.assertEqual(EXAMPLE['os_version'], sot.os_version)
137+
self.assertEqual(EXAMPLE['os_secure_boot'], sot.needs_secure_boot)
138+
self.assertEqual(EXAMPLE['ramdisk_id'], sot.ramdisk_id)
139+
self.assertEqual(EXAMPLE['vm_mode'], sot.vm_mode)
140+
self.assertEqual(EXAMPLE['hw_cpu_sockets'], sot.hw_cpu_sockets)
141+
self.assertEqual(EXAMPLE['hw_cpu_cores'], sot.hw_cpu_cores)
142+
self.assertEqual(EXAMPLE['hw_cpu_threads'], sot.hw_cpu_threads)
143+
self.assertEqual(EXAMPLE['hw_disk_bus'], sot.hw_disk_bus)
144+
self.assertEqual(EXAMPLE['hw_rng_model'], sot.hw_rng_model)
145+
self.assertEqual(EXAMPLE['hw_machine_type'], sot.hw_machine_type)
146+
self.assertEqual(EXAMPLE['hw_scsi_model'], sot.hw_scsi_model)
147+
self.assertEqual(EXAMPLE['hw_serial_port_count'],
148+
sot.hw_serial_port_count)
149+
self.assertEqual(EXAMPLE['hw_video_model'], sot.hw_video_model)
150+
self.assertEqual(EXAMPLE['hw_video_ram'], sot.hw_video_ram)
151+
self.assertEqual(EXAMPLE['hw_watchdog_action'], sot.hw_watchdog_action)
152+
self.assertEqual(EXAMPLE['os_command_line'], sot.os_command_line)
153+
self.assertEqual(EXAMPLE['hw_vif_model'], sot.hw_vif_model)
154+
self.assertEqual(EXAMPLE['hw_vif_multiqueue_enabled'],
155+
sot.is_hw_vif_multiqueue_enabled)
156+
self.assertEqual(EXAMPLE['hw_boot_menu'], sot.is_hw_boot_menu_enabled)
157+
self.assertEqual(EXAMPLE['vmware_adaptertype'], sot.vmware_adaptertype)
158+
self.assertEqual(EXAMPLE['vmware_ostype'], sot.vmware_ostype)
159+
self.assertEqual(EXAMPLE['auto_disk_config'], sot.has_auto_disk_config)
160+
self.assertEqual(EXAMPLE['os_type'], sot.os_type)
98161

99162
def test_deactivate(self):
100163
sot = image.Image(**EXAMPLE)

0 commit comments

Comments
 (0)