Skip to content

Commit a649267

Browse files
authored
Merge pull request #37 from cloudify-incubator/0.9.4-build
0.9.4 build
2 parents 0ad2739 + 9bb406a commit a649267

9 files changed

Lines changed: 602 additions & 23 deletions

File tree

.circleci/config.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2.1
22

33
orbs:
4-
node: cloudify/public-unittest-orb@1 #orb version
5-
wagonorb: cloudify/wagon-bulder-orb@2.4.0 #orb version
6-
releaseorb: cloudify/release-orb@1.4.0 #orb version
7-
managerorb: cloudify/manager-orb@1
4+
node: cloudify/public-unittest-orb@volatile
5+
wagonorb: cloudify/wagon-bulder-orb@volatile
6+
releaseorb: cloudify/release-orb@volatile
7+
managerorb: cloudify/manager-orb@volatile
88

99
checkout:
1010
post:
@@ -60,14 +60,6 @@ workflows:
6060
filters:
6161
branches:
6262
only: /([0-9\.]*\-build|master|main)/
63-
- wagonorb/build_bundle:
64-
filters:
65-
branches:
66-
only: /([0-9\.]*\-build|master|main)/
67-
requires:
68-
- wagonorb/wagon
69-
- wagonorb/arch64_wagon
70-
- wagonorb/rhel_wagon
7163
- releaseorb/release:
7264
filters:
7365
branches:
@@ -76,7 +68,6 @@ workflows:
7668
- wagonorb/wagon
7769
- wagonorb/arch64_wagon
7870
- wagonorb/rhel_wagon
79-
- wagonorb/build_bundle
8071
- node/validate_version_job
8172
- node/validate_documentation_job
8273
- releaseorb/merge_docs_job:

CHANGELOG.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
- Port source code to python3
3333
0.9.1.1: Testing webhook for Marketplace scraping
3434
0.9.2: Rerelease for build system.
35-
0.9.3: Rerelease with rhel8.
35+
0.9.3: Rerelease with rhel8.
36+
0.9.4: Add Passthrough Devices support.

cloudify_libvirt/__version__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = '0.9.4'

cloudify_libvirt/common.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,47 @@ def get_libvirt_params(**kwargs):
5050
return libvirt_auth, template_params
5151

5252

53+
def handle_device_type(d_type, device):
54+
handled_device = {}
55+
serial_values = ['source_path', 'target_port']
56+
usb_values = ['vendor_id', 'product_id']
57+
pci_values = ['bus', 'slot', 'function']
58+
tpm_values = ['path']
59+
valid_values = None
60+
if d_type == 'serial':
61+
valid_values = serial_values
62+
elif d_type == 'usb':
63+
valid_values = usb_values
64+
elif d_type == 'pci':
65+
valid_values = pci_values
66+
elif d_type == 'tpm':
67+
valid_values = tpm_values
68+
if valid_values:
69+
for k in device:
70+
if k in valid_values:
71+
handled_device[k] = device.get(k)
72+
return handled_device
73+
74+
75+
def handle_devices(devices):
76+
serial_devices = []
77+
usb_devices = []
78+
pci_devices = []
79+
tpm_devices = []
80+
for device in devices:
81+
to_append = handle_device_type(device.get('type'), device)
82+
if to_append:
83+
if device.get('type') == 'serial':
84+
serial_devices.append(to_append)
85+
elif device.get('type') == 'usb':
86+
usb_devices.append(to_append)
87+
elif device.get('type') == 'pci':
88+
pci_devices.append(to_append)
89+
elif device.get('type') == 'tpm':
90+
tpm_devices.append(to_append)
91+
return serial_devices, usb_devices, pci_devices, tpm_devices
92+
93+
5394
def gen_xml_template(kwargs, template_params, default_template):
5495
# templates
5596
template_resource = kwargs.get('template_resource')
@@ -70,6 +111,21 @@ def gen_xml_template(kwargs, template_params, default_template):
70111
params = {"ctx": ctx}
71112
if template_params:
72113
params.update(template_params)
114+
# let's handle devices properly
115+
passthrough_devices = params.pop('devices', None)
116+
if passthrough_devices:
117+
serial_devices, usb_devices, pci_devices, tpm_devices = \
118+
handle_devices(passthrough_devices)
119+
if serial_devices:
120+
params.update({'serial_devices': serial_devices})
121+
if usb_devices:
122+
params.update({'usb_devices': usb_devices})
123+
if pci_devices:
124+
params.update({'pci_devices': pci_devices})
125+
if tpm_devices:
126+
params.update({'tpm_devices': tpm_devices})
127+
if not isinstance(template_content, str):
128+
template_content = template_content.decode("utf-8")
73129
xmlconfig = filters.render_template(template_content, params)
74130
ctx.logger.debug(repr(xmlconfig))
75131
return xmlconfig

cloudify_libvirt/templates/domain.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,34 @@
4848
<driver type="{{ disk.type }}"/>
4949
</disk>
5050
{% endfor %}
51+
{% for serial_device in serial_devices %}
52+
<serial type='pty'>
53+
<source path='{{ serial_device.source_path }}'/>
54+
<target port='{{ serial_device.target_port }}'/>
55+
</serial>
56+
{% endfor %}
57+
{% for usb_device in usb_devices %}
58+
<hostdev mode='subsystem' type='usb' managed='yes'>
59+
<source>
60+
<vendor id='{{ usb_device.vendor_id }}'/>
61+
<product id='{{ usb_device.product_id }}'/>
62+
</source>
63+
</hostdev>
64+
{% endfor %}
65+
{% for pci_device in pci_devices %}
66+
<hostdev mode='subsystem' type='pci' managed='yes'>
67+
<source>
68+
<address domain='0x0000' bus='{{ pci_device.bus }}' slot='{{ pci_device.slot }}' function='{{ pci_device.function }}'/>
69+
</source>
70+
</hostdev>
71+
{% endfor %}
72+
{% for tpm_device in tpm_devices %}
73+
<tpm model='tpm-tis'>
74+
<backend type='passthrough'>
75+
<device path='{{ tpm_device.path }}'/>
76+
</backend>
77+
</tpm>
78+
{% endfor %}
5179
</devices>
5280
<on_crash>restart</on_crash>
5381
<on_reboot>restart</on_reboot>

plugin.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins:
22
libvirt:
33
executor: central_deployment_agent
44
package_name: cloudify-libvirt-plugin
5-
package_version: '0.9.3'
5+
package_version: '0.9.4'
66

77
data_types:
88

@@ -155,6 +155,23 @@ data_types:
155155
description: >
156156
Type of virtualization
157157
default: qemu
158+
devices:
159+
description: >
160+
List of devices to passthrough to guest as a dict in this format:
161+
for example:
162+
- type: serial
163+
source_path: /dev/ttyS1
164+
target_port: 1
165+
- type: usb
166+
vendor_id: 0x1d6b
167+
product_id: 0x0002
168+
- type: pci
169+
bus: 0x01
170+
slot: 0x00
171+
function: 0x1
172+
- type: tpm
173+
path: /dev/tpm0
174+
default: []
158175

159176
node_types:
160177

@@ -357,7 +374,7 @@ node_types:
357374
implementation: libvirt.cloudify_libvirt.volume_tasks.create
358375
inputs:
359376
params:
360-
type: cloudify.datatypes.volume
377+
default: {}
361378
template_resource:
362379
default: ''
363380
template_content:

0 commit comments

Comments
 (0)