[Fix] Doc Issue: - It is not possible to pass [R]andom [N]umber [G]enerator device to libvirt guest xml in order to control entropy. - Doc has no information on how to provision vms using salt Solution: - Pass rng parameters via kwargs from node: pillar Attach rng xml object to generated xml. - Provide with an example Prod-Related: PROD-19214 Customer-Found Change-Id: Iea111f2d927edf46f06bb7ccfad06d37b752fba9pull/73/head
salt-call event.send 'salt/key/remove' | salt-call event.send 'salt/key/remove' | ||||
Control VM provisioning | |||||
.. code-block:: yaml | |||||
virt: | |||||
disk: | |||||
three_disks: | |||||
- system: | |||||
size: 4096 | |||||
image: ubuntu.qcow | |||||
- repository_snapshot: | |||||
size: 8192 | |||||
image: snapshot.qcow | |||||
- cinder-volume: | |||||
size: 2048 | |||||
salt: | |||||
control: | |||||
enabled: true | |||||
virt_enabled: true | |||||
size: | |||||
medium_three_disks: | |||||
cpu: 2 | |||||
ram: 4 | |||||
disk_profile: three_disks | |||||
cluster: | |||||
mycluster: | |||||
domain: neco.virt.domain.com | |||||
engine: virt | |||||
node: | |||||
ubuntu1: | |||||
provider: node01.domain.com | |||||
image: ubuntu.qcow | |||||
size: medium | |||||
img_dest: /var/lib/libvirt/ssdimages | |||||
rng: | |||||
backend: /dev/urandom | |||||
model: random | |||||
rate: | |||||
period: '1800' | |||||
bytes: '1500' | |||||
Jinja options | Jinja options | ||||
------------- | ------------- |
start=True, # pylint: disable=redefined-outer-name | start=True, # pylint: disable=redefined-outer-name | ||||
disk='default', | disk='default', | ||||
saltenv='base', | saltenv='base', | ||||
rng={}, | |||||
**kwargs): | **kwargs): | ||||
''' | ''' | ||||
Initialize a new vm | Initialize a new vm | ||||
.format(hypervisor)) | .format(hypervisor)) | ||||
xml = _gen_xml(name, cpu, mem, diskp, nicp, hypervisor, **kwargs) | xml = _gen_xml(name, cpu, mem, diskp, nicp, hypervisor, **kwargs) | ||||
# TODO: Remove this code and refactor module, when salt-common would have updated libvirt_domain.jinja template | |||||
if rng: | |||||
rng_model = rng.get('model', 'random') | |||||
rng_backend = rng.get('backend', '/dev/urandom') | |||||
xml_doc = minidom.parseString(xml) | |||||
rng_xml = xml_doc.createElement("rng") | |||||
rng_xml.setAttribute("model", "virtio") | |||||
backend = xml_doc.createElement("backend") | |||||
backend.setAttribute("model", rng_model) | |||||
backend.appendChild(xml_doc.createTextNode(rng_backend)) | |||||
rng_xml.appendChild(backend) | |||||
if 'rate' in rng: | |||||
rng_rate_period = rng['rate'].get('period', '2000') | |||||
rng_rate_bytes = rng['rate'].get('bytes', '1234') | |||||
rate = xml_doc.createElement("rate") | |||||
rate.setAttribute("period", rng_rate_period) | |||||
rate.setAttribute("bytes", rng_rate_bytes) | |||||
rng_xml.appendChild(rate) | |||||
xml_doc.getElementsByTagName("domain")[0].getElementsByTagName("devices")[0].appendChild(rng_xml) | |||||
xml = xml_doc.toxml() | |||||
define_xml_str(xml) | define_xml_str(xml) | ||||
if start: | if start: |
- start: True | - start: True | ||||
- disk: {{ size.disk_profile }} | - disk: {{ size.disk_profile }} | ||||
- nic: {{ size.net_profile }} | - nic: {{ size.net_profile }} | ||||
{%- if node.rng is defined %} | |||||
- rng: {{ node.rng }} | |||||
{%- endif %} | |||||
- kwargs: | - kwargs: | ||||
seed: True | seed: True | ||||
serial_type: pty | serial_type: pty |
provider: node03.domain.com | provider: node03.domain.com | ||||
image: meowbuntu.qcom2 | image: meowbuntu.qcom2 | ||||
size: medium_three_disks | size: medium_three_disks | ||||
rng: | |||||
backend: /dev/urandom | |||||
model: random | |||||
rate: | |||||
period: '1800' | |||||
bytes: '1500' |