-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dell Enterprise SONiC 'image_management' module (#311)
* Add Dell Enterprise SONiC 'image_management' module * Add warning for ignored options
- Loading branch information
1 parent
5d76569
commit 7f53777
Showing
25 changed files
with
1,580 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
tests/regression/roles/sonic_image_management/defaults/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
ansible_connection: httpapi | ||
module_name: image_management |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
collections: | ||
- dellemc.enterprise_sonic | ||
dependencies: | ||
- { role: common } |
22 changes: 22 additions & 0 deletions
22
tests/regression/roles/sonic_image_management/tasks/firmware_cancel.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: Test case - firmware cancel | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
firmware: | ||
command: 'cancel' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.status is defined | ||
- result.status == 'SUCCESS' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'firmware_cancel' | ||
test_case_input: | ||
firmware: | ||
command: 'cancel' |
21 changes: 21 additions & 0 deletions
21
tests/regression/roles/sonic_image_management/tasks/firmware_get_list.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Test case - firmware get-result | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
firmware: | ||
command: 'get-list' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'firmware_get_list' | ||
test_case_input: | ||
firmware: | ||
command: 'get-list' |
21 changes: 21 additions & 0 deletions
21
tests/regression/roles/sonic_image_management/tasks/firmware_get_status.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Test case - firmware get-status | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
firmware: | ||
command: 'get-status' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'firmware_get_status' | ||
test_case_input: | ||
firmware: | ||
command: 'get-status' |
30 changes: 30 additions & 0 deletions
30
tests/regression/roles/sonic_image_management/tasks/firmware_install.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Test case - firmware install | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
firmware: | ||
command: 'install' | ||
path: 'file://tmp/test.bin' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.set_fact: | ||
result_msg: "{{ result.msg | from_yaml }}" | ||
when: result.msg is defined | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == true | ||
- result.msg is defined | ||
- result_msg['code'] == 400 | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-type'] == 'application' | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-tag'] == 'invalid-value' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'firmware_install' | ||
test_case_input: | ||
firmware: | ||
command: 'install' | ||
path: 'file://tmp/test.bin' |
22 changes: 22 additions & 0 deletions
22
tests/regression/roles/sonic_image_management/tasks/image_cancel.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
- name: Test case - image cancel | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'cancel' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.status is defined | ||
- result.status == 'SUCCESS' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_cancel' | ||
test_case_input: | ||
image: | ||
command: 'cancel' |
24 changes: 24 additions & 0 deletions
24
tests/regression/roles/sonic_image_management/tasks/image_get_list.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Test case - image get-list | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'get-list' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
- result.info.available is defined | ||
- result.info.current is defined and result.info.current in result.info.available | ||
- result.info.next is defined and result.info.next in result.info.available | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_get_list' | ||
test_case_input: | ||
image: | ||
command: 'get-list' |
21 changes: 21 additions & 0 deletions
21
tests/regression/roles/sonic_image_management/tasks/image_get_status.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Test case - image get-status | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'get-status' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_get_status' | ||
test_case_input: | ||
image: | ||
command: 'get-status' |
30 changes: 30 additions & 0 deletions
30
tests/regression/roles/sonic_image_management/tasks/image_install.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Test case - image install | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'install' | ||
path: 'file://tmp/test.bin' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.set_fact: | ||
result_msg: "{{ result.msg | from_yaml }}" | ||
when: result.msg is defined | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == true | ||
- result.msg is defined | ||
- result_msg['code'] == 400 | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-type'] == 'application' | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-tag'] == 'invalid-value' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_install' | ||
test_case_input: | ||
image: | ||
command: 'install' | ||
path: 'file://tmp/test.bin' |
9 changes: 9 additions & 0 deletions
9
tests/regression/roles/sonic_image_management/tasks/image_management.test.facts.report.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- ansible.builtin.set_fact: | ||
ansible_facts: | ||
test_reports: "{{ ansible_facts['test_reports'] | default({}) | combine({module_name: {test_case_name: { | ||
'status': 'Passed' if (assert_result.failed == false) else 'Failed', | ||
'module_stderr': result.module_stderr | default(result.msg | default('No Error')), | ||
'configs': test_case_input | default('Not defined'), | ||
'result_info': result.info | default('N/A'), | ||
'result_status': result.status | default('N/A'), | ||
}}}, recursive=True) }}" |
30 changes: 30 additions & 0 deletions
30
tests/regression/roles/sonic_image_management/tasks/image_remove.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Test case - image remove - current image | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'remove' | ||
name: '{{ current_image_name }}' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.set_fact: | ||
result_msg: "{{ result.msg | from_yaml }}" | ||
when: result.msg is defined | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == true | ||
- result.msg is defined | ||
- result_msg['code'] == 400 | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-type'] == 'application' | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-tag'] == 'invalid-value' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_remove' | ||
test_case_input: | ||
image: | ||
command: 'remove' | ||
name: '{{ current_image_name }}' |
24 changes: 24 additions & 0 deletions
24
tests/regression/roles/sonic_image_management/tasks/image_set_default.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Test case - image set-default - current image | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'set-default' | ||
name: '{{ current_image_name }}' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.status is defined | ||
- result.status == 'SUCCESS' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_set_default' | ||
test_case_input: | ||
image: | ||
command: 'set-default' | ||
name: '{{ current_image_name }}' |
28 changes: 28 additions & 0 deletions
28
tests/regression/roles/sonic_image_management/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- ansible.builtin.debug: | ||
msg: "sonic_image_management Test started ..." | ||
|
||
- name: Preparations for image_management | ||
ansible.builtin.include_tasks: preparation_tests.yml | ||
|
||
- ansible.builtin.include_tasks: image_install.yml | ||
- ansible.builtin.include_tasks: image_cancel.yml | ||
- ansible.builtin.include_tasks: image_remove.yml | ||
- ansible.builtin.include_tasks: image_set_default.yml | ||
- ansible.builtin.include_tasks: image_get_list.yml | ||
- ansible.builtin.include_tasks: image_get_status.yml | ||
|
||
- ansible.builtin.include_tasks: patch_install.yml | ||
- ansible.builtin.include_tasks: patch_rollback.yml | ||
- ansible.builtin.include_tasks: patch_get_history.yml | ||
- ansible.builtin.include_tasks: patch_get_list.yml | ||
- ansible.builtin.include_tasks: patch_get_status.yml | ||
|
||
- ansible.builtin.include_tasks: firmware_install.yml | ||
- ansible.builtin.include_tasks: firmware_cancel.yml | ||
- ansible.builtin.include_tasks: firmware_get_list.yml | ||
- ansible.builtin.include_tasks: firmware_get_status.yml | ||
|
||
- name: Display all variables/facts known for a host | ||
ansible.builtin.debug: | ||
var: hostvars[inventory_hostname].ansible_facts.test_reports |
21 changes: 21 additions & 0 deletions
21
tests/regression/roles/sonic_image_management/tasks/patch_get_history.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Test case - patch get-history | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
patch: | ||
command: 'get-history' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'patch_get_history' | ||
test_case_input: | ||
patch: | ||
command: 'get-history' |
21 changes: 21 additions & 0 deletions
21
tests/regression/roles/sonic_image_management/tasks/patch_get_list.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Test case - patch get-list | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
patch: | ||
command: 'get-list' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'patch_get_list' | ||
test_case_input: | ||
patch: | ||
command: 'get-list' |
21 changes: 21 additions & 0 deletions
21
tests/regression/roles/sonic_image_management/tasks/patch_get_status.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Test case - patch get-status | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
patch: | ||
command: 'get-status' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.info is defined | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'patch_get_status' | ||
test_case_input: | ||
patch: | ||
command: 'get-status' |
Oops, something went wrong.