Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'data_center' #617

Open
powimod opened this issue Nov 9, 2022 · 1 comment
Open

AttributeError: 'NoneType' object has no attribute 'data_center' #617

powimod opened this issue Nov 9, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@powimod
Copy link

powimod commented Nov 9, 2022

ovirt_vm
STEPS TO REPRODUCE

With ovirt_vm, specify an invalid cluster name like this :

- name: Create VMs
      ovirt_vm:
        auth: "{{ ovirt_auth }}"
        cluster: "INVALID_CLUSTER_NAME"
       [...]
ACTUAL RESULTS

You will have the following error :

The full traceback is:
Traceback (most recent call last):
  File "x/ansible/modules/cloud/ovirt/ovirt_vm.py", line 2477, in main
  File "x/ansible/module_utils/ovirt.py", line 622, in create
	self.build_entity(),
  File "x/ansible/modules/cloud/ovirt/ovirt_vm.py", line 1376, in build_entity
  File "x/ansible/modules/cloud/ovirt/ovirt_vm.py", line 1293, in __get_template_with_version
AttributeError: 'NoneType' object has no attribute 'data_center'
EXPECTED RESULTS

You should obtain an explicit error which explains that cluster name was not found.

CODE ISSUE

In __get_template_with_version (file ovirt_vm.py, line 1293), the cluster variable is initialized with :

cluster = search_by_name(clusters_service, self.param('cluster'))

And just after, cluster is used to get it's data_center attribute without testing if it's value is None :

data_center = self._connection.follow_link(cluster.data_center)

A test shoud be added between :

cluster = search_by_name(clusters_service, self.param('cluster'))
if cluster is None:
    raise ValueError("Cluster with name '%s' was not found" % ( self.param('cluster')))
data_center = self._connection.follow_link(cluster.data_center)
@powimod powimod added the bug Something isn't working label Nov 9, 2022
@mnecas
Copy link
Member

mnecas commented Nov 9, 2022

@emesika

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants