Skip to content

Commit

Permalink
Simplify crypto attachment support and improve error handling
Browse files Browse the repository at this point in the history
Details:

- Simplified and addressed complexity of code in ensure_attached()
  by renaming variables, moving code around so that code that
  logically belongs together is also located together.

- Simplified the example playbooks for crypto attachment, by
  having them deal with a single target partition.

- Improved error handling by wrappering zhmcclient exceptions
  so the message shows a better context of what was attempted.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Mar 1, 2019
1 parent 43a2578 commit 5c8266f
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 231 deletions.
8 changes: 4 additions & 4 deletions playbooks/attach_crypto_2.yml → playbooks/attach_crypto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
- vault.yml
tasks:

- name: Ensure domains 1-max on 1 adapter are attached in usage mode to partition 2
- name: "Ensure domains 2-max on 4 adapters are attached in usage mode to partition {{ partition_name }}"
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
cpc_name: "{{ cpc_name }}"
partition_name: "{{ partition2_name }}"
partition_name: "{{ partition_name }}"
state: attached
crypto_type: ep11
adapter_count: 1
domain_range: 1,-1
adapter_count: 4
domain_range: 2,-1
access_mode: usage
log_file: crypto.log
register: result
Expand Down
43 changes: 0 additions & 43 deletions playbooks/attach_crypto_1.yml

This file was deleted.

25 changes: 0 additions & 25 deletions playbooks/attach_crypto_3.yml

This file was deleted.

30 changes: 1 addition & 29 deletions playbooks/detach_crypto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- vault.yml
tasks:

- name: Ensure partition 1 has all crypto adapters and domains detached
- name: "Ensure partition {{ partition_name }} has all crypto adapters and domains detached"
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
Expand All @@ -19,31 +19,3 @@
- name: Print the result
debug:
var: result

- name: Ensure partition 2 has all crypto adapters and domains detached
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
cpc_name: "{{ cpc_name }}"
partition_name: "{{ partition2_name }}"
state: detached
log_file: crypto.log
register: result

- name: Print the result
debug:
var: result

- name: Ensure partition 3 has all crypto adapters and domains detached
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
cpc_name: "{{ cpc_name }}"
partition_name: "{{ partition3_name }}"
state: detached
log_file: crypto.log
register: result

- name: Print the result
debug:
var: result
30 changes: 1 addition & 29 deletions playbooks/facts_crypto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- vault.yml
tasks:

- name: Get facts about crypto config of partition 1
- name: "Get facts about crypto config of partition {{ partition_name }}"
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
Expand All @@ -19,31 +19,3 @@
- name: Print the result
debug:
var: result

- name: Get facts about crypto config of partition 2
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
cpc_name: "{{ cpc_name }}"
partition_name: "{{ partition2_name }}"
state: facts
log_file: crypto.log
register: result

- name: Print the result
debug:
var: result

- name: Get facts about crypto config of partition 3
zhmc_crypto_attachment:
hmc_host: "{{ hmc_host }}"
hmc_auth: "{{ hmc_auth }}"
cpc_name: "{{ cpc_name }}"
partition_name: "{{ partition3_name }}"
state: facts
log_file: crypto.log
register: result

- name: Print the result
debug:
var: result
Loading

0 comments on commit 5c8266f

Please sign in to comment.