Skip to content

Commit

Permalink
Merge pull request #569 from HewlettPackard/API_checking
Browse files Browse the repository at this point in the history
POC for API validation changes in playbooks
  • Loading branch information
chebroluharika committed Sep 15, 2020
2 parents 25e4d2d + b107025 commit a102ee1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export ONEVIEWSDK_USERNAME='Administrator'
export ONEVIEWSDK_PASSWORD='secret123'

# Optional
export ONEVIEWSDK_API_VERSION='1800' # default value is 600
export ONEVIEWSDK_API_VERSION='1800'
export ONEVIEWSDK_AUTH_LOGIN_DOMAIN='authdomain'
export ONEVIEWSDK_PROXY='<proxy_host>:<proxy_port>'
```
Expand Down Expand Up @@ -257,9 +257,9 @@ Note: Most of the examples provided in this repository uses OneView Credentials

### 5. Setting your OneView version

The Ansible modules for HPE OneView support the API endpoints for HPE OneView 4.00, 4.10, 4.20, 5.00 and 5.20.
The Ansible modules for HPE OneView support the API endpoints for HPE OneView 4.00, 4.10, 4.20, 5.00, 5.20, 5.30.

The current `default` HPE OneView version used by the modules is `4.00`, API `600`.
The current `default` HPE OneView version will pick the OneView appliance version.

To use a different API, you must set the API version together with your credentials, either using the JSON configuration:

Expand All @@ -272,7 +272,7 @@ OR using the Environment variable:
export ONEVIEWSDK_API_VERSION='1800'
```

If this property is not specified, it will fall back to the ```600``` default value.
If this property is not specified, it will fall back to the default value.

The API list is as follows:

Expand Down
23 changes: 21 additions & 2 deletions examples/oneview_ethernet_network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
- '/rest/scopes/63d1ca81-95b3-41f1-a1ee-f9e1bc2d635f'
- '/rest/scopes/96661df3-fb4f-4617-a1fb-d6f11adf18d3'
tasks:
- name: Get currrentVersion from URL
oneview_version_facts:
config: "{{ config }}"
delegate_to: localhost
when: contents.api_version|length == 0
register: version

- name: Print currentVersion if api version is not specified in config file
set_fact:
currentVersion: "{{ version.ansible_facts.version.currentVersion | int }}"
when: contents.api_version|length == 0

- name: Print currentVersion if api version is specified in config file
set_fact:
currentVersion: contents.api_version | string
when: contents.api_version|length != 0

- name: Create an Ethernet Network
oneview_ethernet_network:
config: "{{ config }}"
Expand Down Expand Up @@ -66,7 +83,7 @@
data:
name: "{{ network_name }}"
scopeUris: []
when: contents.api_version >= 300 and contents.api_version <= 500
when: currentVersion >= '300' and currentVersion <= '500'
delegate_to: localhost

- name: Ensure Ethernet Network has two scopes
Expand All @@ -76,7 +93,7 @@
data:
name: "{{ network_name }}"
scopeUris: "{{ network_scope_uris }}"
when: contents.api_version >= 300 and contents.api_version <= 500
when: currentVersion >= '300' and currentVersion <= '500'
delegate_to: localhost

- name: Rename the Ethernet Network to 'Updated Ethernet Network'
Expand Down Expand Up @@ -121,3 +138,5 @@
networkUris:
- "/rest/ethernet-networks/e2f0031b-52bd-4223-9ac1-d91cb519d548"
delegate_to: localhost
when: currentVersion >= '1600'

25 changes: 20 additions & 5 deletions examples/oneview_fc_network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
- '/rest/scopes/d0324c4b-56c9-485b-b7dd-8f6218a4b5bb'
- '/rest/scopes/9422ce05-dc39-4358-b723-c8c825eae412'
tasks:
- name: Get currrentVersion from URL
oneview_version_facts:
config: "{{ config }}"
delegate_to: localhost
when: contents.api_version|length == 0
register: version

- name: Print currentVersion if api version is not specified in config file
set_fact:
currentVersion: "{{ version.ansible_facts.version.currentVersion | int }}"
when: contents.api_version|length == 0

- name: Print currentVersion if api version is specified in config file
set_fact:
currentVersion: contents.api_version | string
when: contents.api_version|length != 0

- name: Create a Fibre Channel Network
oneview_fc_network:
config: "{{ config }}"
Expand All @@ -37,10 +54,6 @@
delegate_to: localhost
register: fc_network_1

- name: Display the api version present in config file
debug:
var: contents.api_version

- name: Do nothing with the Fibre Channel Network when no changes are provided
oneview_fc_network:
config: "{{ config }}"
Expand Down Expand Up @@ -71,7 +84,7 @@
data:
name: "{{ network_name }}"
scopeUris: "{{ network_scope_uris }}"
when: contents.api_version >= 300 and contents.api_version <= 500
when: currentVersion >= '300' and currentVersion <= '500'
delegate_to: localhost

- name: Delete the Fibre Channel Network
Expand All @@ -90,6 +103,7 @@
delegate_to: localhost
register: deleted

# This feature is available only from OneView 5.20
- name: Delete Fibre Channel Networks in bulk
oneview_fc_network:
config: "{{ config }}"
Expand All @@ -98,3 +112,4 @@
networkUris:
- "/rest/fc-networks/e2f0031b-52bd-4223-9ac1-d91cb519d548"
delegate_to: localhost
when: currentVersion >= '1600'
5 changes: 3 additions & 2 deletions examples/oneview_fcoe_network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
newName: 'Test FCoE Network - Changed'
vlanId: 201
delegate_to: localhost
# Below task is supported only with OneView 3.10

# Below task is supported only with OneView 3.10
- name: Update the FCoE Network with two scopes
oneview_fcoe_network:
config: "{{ config }}"
state: present
data:
name: 'Test FCoE Network - Changed'
scopeUris: "{{ network_scope_uris }}"
when: contents.api_version >= 300 and contents.api_version <= 500
delegate_to: localhost

- name: Delete the FCoE Network
Expand All @@ -76,6 +76,7 @@
name: 'Test FCoE Network - Changed'
delegate_to: localhost

# This feature is available only from OneView 5.20
- name: Delete FCoE Networks in bulk
oneview_fcoe_network:
config: "{{ config }}"
Expand Down
1 change: 0 additions & 1 deletion examples/oneview_network_set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
data:
name: OneViewSDK Test Network Set
scopeUris: "{{ network_set_scope_uris }}"
when: contents.api_version >= 300 and contents.api_version <= 500
delegate_to: localhost

- name: Update the Network Set name to 'OneViewSDK Test Network Set - Renamed' and change the associated networks
Expand Down
3 changes: 0 additions & 3 deletions examples/oneview_storage_pool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
storageSystemUri: '{{ storage_system_uri }}'
poolName: '{{ storage_pool_name }}'
delegate_to: localhost
when: contents.api_version <= 300

- name: Do nothing when the Storage Pool already exists
oneview_storage_pool:
Expand Down Expand Up @@ -60,7 +59,6 @@
data:
poolName: '{{ storage_pool_name }}'
delegate_to: localhost
when: contents.api_version <= 300

- name: Do nothing when Storage Pool is absent
oneview_storage_pool:
Expand All @@ -69,4 +67,3 @@
data:
poolName: '{{ storage_pool_name }}'
delegate_to: localhost
when: contents.api_version <= 300

0 comments on commit a102ee1

Please sign in to comment.