HewlettPackard / oneview-ansible-collection

Ansible Collection and Sample Playbooks for HPE OneView
Apache License 2.0
26 stars 22 forks source link

Unassign server profile #235

Closed dobey-xx closed 1 year ago

dobey-xx commented 1 year ago

Hi,

I've been trying to use this task:

But it doesn't seem to update the server profile in any way. The return message is: "Server Profile is already present", which makes sense because it is :)..

In the output I can see the connection settings with the data as following: "invocation": { "module_args": { "hostname": "", "username": "", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "auth_login_domain": "Local", "api_version": 3200, "auto_assign_server_hardware": false, "data": { "name": "profile" },

As you can see the option "serverHardwareName" isn't posted in the data section. So it seems it's not passing that through with the task.

alisha-k-kalladassery commented 1 year ago

Hi,

We will look into this issue.

alisha-k-kalladassery commented 1 year ago

Hi We understood the issue and will be fixing it per priority. Kindly try using 'serverHardwareUri' instead of 'serverHardwareName' and let us know if you still face any issues.

dobey-xx commented 1 year ago

Hi, I have tried that already but that doesn't unassign the serverhardware from the serverprofile

alisha-k-kalladassery commented 1 year ago

Hi Below is the playbook which I tried to check the issue.

- name: Fetch Session Id
  oneview_get_session_id:
    config: "{{ config }}"
    name: "Test_Session"
  delegate_to: localhost
  register: session

- name: Gather facts about all Scopes
  oneview_scope_facts:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
  delegate_to: localhost

- name: Create a Server Profile from a Server Profile Template
  oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    data:
      serverProfileTemplateName: "{{ contents.server_profile.ov_template }}"
      name: "{{ contents.server_profile.inventory_hostname }}"
      description: "{{ contents.server_profile.server_profile_description }}"
      # User should set initialScopeUris in case of scoped user
      # Otherwise collects scopeUris from OV when its not given
      # explicitly
      initialScopeUris:
        - "{{ scopes[0].uri }}"
    params: # Supported only in API version >= 600
      force: True
  delegate_to: localhost
  register: result

- name: Unassign Server Hardware from Server Profile
  oneview_server_profile:
    config: "{{ config }}"
    sessionID: "{{ session.ansible_facts.session }}"
    # This is required for unassigning a SH, or creating a SP and not auto-assigning a SH
    auto_assign_server_hardware: False
    data:
      name: "{{ contents.server_profile.inventory_hostname }}"
      # Specify a blank serverHardwareName or serverHardwareUri when auto_assign_server_hardware is False to unassign a SH
      serverHardwareUri:
  delegate_to: localhost

Kindly check the same and share your playbook and appliance/SDK details if it does not help you .

dobey-xx commented 1 year ago

This is what i've used:

The output says: { "changed": true, "msg": "Server profile updated",

But when i check the profile in OneView, the hardware is still assigned

alisha-k-kalladassery commented 1 year ago

Kindly try keeping the serverHardwareUri blank as in example. We are working on fixing this issue.

serverHardwareUri:
dobey-xx commented 1 year ago

Yes that seems to work, i missed removing the "". Thanks

alisha-k-kalladassery commented 1 year ago

Hi, We have merged the fix and changes are available in master branch. It will be released as part of OV8.1 release.