Commvault / ansible

Ansible Library for Commvault
21 stars 11 forks source link

ClientGroup not available #2

Closed tonyhogsten closed 4 years ago

tonyhogsten commented 4 years ago

According to the documentation we are able to use clientgroup, but when attempting to use it

entity_type: clientgroup

it's not available

The error was: NameError: name 'clientgroup' is not defined

tonyhogsten commented 4 years ago

Haven't tried using a specific function as the class clientgroup cannot be instantiated with the ansible module as there is no support for it as I can see in the code.

- name: get all client groups within the commcell
  commvault:
    commcell: "{{ commcell }}"
    operation: "_get_clientgroups"
    entity_type: clientgroup
    entity: {
      clientgroup: "_Avvecklade"
    }
  register: clientgroups

- name: debug clients
  debug:
    var: clientgroups

Generated the error I wrote, The error was: NameError: name 'clientgroup' is not defined

I've made changes to the commvault.py code locally, added

Line 243  global commcell, client, clients, agent, agents, instance, instances, backupset, backupsets, subclient, subclients, result, clientgroup, clientgroups

    if 'clientgroup' in entity:
        clientgroups = commcell_object.client_groups
        clientgroup = clientgroups.get(entity['clientgroup'])   

And this worked and retrieved all clientgroups. Is this a miss in the original code? As you wrote entity_type with the value clientgroups was supported?

spakhare commented 4 years ago

Yes, our bad we missed adding support for the clientgroup. Please let us know if you would like to create a merge request to add support for clientgroup or do you want us to add the fix?

Thanks for your help.