roles: bifrost-create-vm-nodes: Improve host matching when deleting from vbmc

Assuming that 'vm_name' is 'foobar' then 'vm_name in vbmc_list.stdout'
will also match when there is a foobar[a-zA-Z0-9]* host registered so
there is a chance for the task to try and delete non-existing hosts
as obsereved below:

fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["vbmc",
"delete", "jumphost"], "delta": "0:00:00.343033", "end": "2017-03-20
02:10:19.759738", "failed": true, "invocation": {"module_args":
{"_raw_params": "vbmc delete jumphost", "_uses_shell": false, "chdir":
null, "creates": null, "executable": null, "removes": null, "warn":
true}, "module_name": "command"}, "rc": 1, "start": "2017-03-20
02:10:19.416705", "stderr": "No domain with matching name jumphost was
found", "stdout": "", "stdout_lines": [], "warnings": []}

That happens because a 'jumphost.opnfvlocal' is registered in vbmc
but the 'vm_name' for this run is just 'jumphost'.

We fix this by using the 'find' method and looking for '{{vm_name}} '
instead.

Change-Id: I1675a978489bfd0633eabb30e2227ed7cb70c7ef
This commit is contained in:
Markos Chandras 2017-03-20 09:59:47 +00:00
parent 36e32ecdc2
commit a40dfaf9c3

View File

@ -96,7 +96,7 @@
- name: delete vm from virtualbmc if it is there
command: vbmc delete {{ vm_name }}
when: "{{ vm_name in vbmc_list.stdout }}"
when: vbmc_list.stdout.find("{{ vm_name }} ") != -1
- set_fact:
virtual_ipmi_port: "{{ (test_vm_ipmi_port_start|default(623) | int ) + (testvm_json_data | length) }}"