Skip to content

Commit 437e069

Browse files
Merge pull request openstack-k8s-operators#984 from fmount/manila-improvements
Optimize manila adoption code
2 parents 68b38a3 + 5a8e78c commit 437e069

File tree

5 files changed

+96
-72
lines changed

5 files changed

+96
-72
lines changed

tests/playbooks/test_minimal.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
- role: glance_adoption
4949
tags:
5050
- glance_adoption
51+
- role: manila_adoption
52+
tags:
53+
- manila_adoption
5154
- role: placement_adoption
5255
tags:
5356
- placement_adoption

tests/roles/manila_adoption/defaults/main.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# manila_backend can be 'cephfs', 'cephnfs', 'netapp'
2-
manila_backend: cephfs
2+
manila_backend: ''
33
os_net_conf_path: "/etc/os-net-config/config.yaml"
44
manila_storagenfs_nic: "nic2"
55
manila_storagenfs_vlan_id: "70"
@@ -20,3 +20,8 @@ manila_netapp_vars:
2020
- netapp_password
2121
- netapp_server_hostname
2222
- netapp_vserver
23+
# supported backends in the manila adoption test suite
24+
supported_backends:
25+
- cephfs
26+
- cephnfs
27+
- netapp
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- name: Check the required input when manila_backend is NFS
2+
when: manila_backend == "cephnfs"
3+
block:
4+
- name: Get ceph-nfs IP Address
5+
become: true
6+
ansible.builtin.shell: |
7+
{{ shell_header }}
8+
${CONTROLLER1_SSH} awk -F '[=;]' '/Bind_Addr/ {gsub(/ /, "", $2); print $2}' {{ ganesha_default_path }}
9+
register: cephnfs_vip
10+
11+
- name: Fail if the OLD Ganesha VIP is not a good input value
12+
when:
13+
- not (cephnfs_vip.stdout | ansible.builtin.ipaddr)
14+
ansible.builtin.fail:
15+
msg: "The (TRIPLEO) gathered Ganesha server IP is malformed"
16+
17+
- name: Deploy Podified Manila - Ceph
18+
when: manila_backend == "cephfs" or manila_backend == "cephnfs"
19+
block:
20+
- name: Generate CR config based on the selected backend
21+
ansible.builtin.template:
22+
src: manila_cephfs.yaml.j2
23+
dest: /tmp/manila_cephfs.yaml
24+
mode: "0600"
25+
26+
- name: Deploy podified Manila with cephfs backend
27+
ansible.builtin.shell: |
28+
{{ shell_header }}
29+
{{ oc_header }}
30+
oc patch openstackcontrolplane openstack --type=merge --patch-file=/tmp/manila_cephfs.yaml
Lines changed: 37 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,46 @@
1-
- name: Check the required input when manila_backend is NFS
2-
when: manila_backend == "cephnfs"
3-
block:
4-
- name: Set shell vars to connect to controller1
5-
no_log: "{{ use_no_log }}"
6-
ansible.builtin.set_fact:
7-
controller_ssh: |
8-
CONTROLLER1_SSH="{{ controller1_ssh }}"
9-
10-
- name: Get ceph-nfs IP Address
11-
become: true
12-
ansible.builtin.shell: |
13-
{{ shell_header }}
14-
{{ controller_ssh }}
15-
${CONTROLLER1_SSH} awk -F '[=;]' '/Bind_Addr/ {gsub(/ /, "", $2); print $2}' {{ ganesha_default_path }}
16-
register: cephnfs_vip
17-
18-
- name: Fail if the OLD Ganesha VIP is not a good input value
19-
when:
20-
- not (cephnfs_vip.stdout | ansible.builtin.ipaddr)
21-
ansible.builtin.fail:
22-
msg: "The (TRIPLEO) gathered Ganesha server IP is malformed"
23-
241
- name: Deploy Podified Manila - Ceph
252
when: manila_backend == "cephfs" or manila_backend == "cephnfs"
26-
block:
27-
- name: Generate CR config based on the selected backend
28-
ansible.builtin.template:
29-
src: manila_cephfs.yaml.j2
30-
dest: /tmp/manila_cephfs.yaml
31-
mode: "0600"
32-
33-
- name: Deploy podified Manila with cephfs backend
34-
ansible.builtin.shell: |
35-
{{ shell_header }}
36-
{{ oc_header }}
37-
oc patch openstackcontrolplane openstack --type=merge --patch-file=/tmp/manila_cephfs.yaml
3+
ansible.builtin.include_tasks: ceph.yaml
384

395
- name: Deploy Podified Manila - Netapp
406
when: manila_backend == "netapp"
417
ansible.builtin.include_tasks: netapp.yaml
428

43-
- name: Wait for Manila to start up
44-
ansible.builtin.shell: |
45-
{{ shell_header }}
46-
{{ oc_header }}
47-
oc wait pod --for condition=Ready --selector=component=manila-api
48-
oc wait pod --for condition=Ready --selector=component=manila-scheduler
49-
oc wait pod --for condition=Ready --selector=component=manila-share
50-
register: manila_running_result
51-
until: manila_running_result is success
52-
retries: 60
53-
delay: 2
54-
55-
- name: Check that Manila is reachable and its endpoints are defined
56-
ansible.builtin.shell: |
57-
{{ shell_header }}
58-
{{ oc_header }}
59-
alias openstack="oc exec -t openstackclient -- openstack"
9+
- name: Check Manila deployment
10+
when:
11+
- manila_backend is defined
12+
- manila_backend | length > 0
13+
block:
14+
- name: Wait for Manila to start up
15+
ansible.builtin.shell: |
16+
{{ shell_header }}
17+
{{ oc_header }}
18+
oc wait pod --for condition=Ready --selector=component=manila-api
19+
oc wait pod --for condition=Ready --selector=component=manila-scheduler
20+
oc wait pod --for condition=Ready --selector=component=manila-share
21+
register: manila_running_result
22+
until: manila_running_result is success
23+
retries: 60
24+
delay: 2
25+
26+
- name: Check that Manila is reachable and its endpoints are defined
27+
ansible.builtin.shell: |
28+
{{ shell_header }}
29+
{{ oc_header }}
30+
alias openstack="oc exec -t openstackclient -- openstack"
6031
61-
${BASH_ALIASES[openstack]} endpoint list | grep -i share
62-
${BASH_ALIASES[openstack]} share pool list
63-
register: manila_responding_result
64-
until: manila_responding_result is success
65-
retries: 15
32+
${BASH_ALIASES[openstack]} endpoint list | grep -i share
33+
${BASH_ALIASES[openstack]} share pool list
34+
register: manila_responding_result
35+
until: manila_responding_result is success
36+
retries: 15
6637

67-
- name: Create default share type
68-
ansible.builtin.shell: |
69-
{{ shell_header }}
70-
{{ oc_header }}
71-
alias openstack="oc exec -t openstackclient -- openstack"
72-
${BASH_ALIASES[openstack]} share type create {{ share_type_name }} {{ driver_handles_share_servers }}
73-
vars:
74-
share_type_name: default
75-
driver_handles_share_servers: false
38+
- name: Create default share type
39+
ansible.builtin.shell: |
40+
{{ shell_header }}
41+
{{ oc_header }}
42+
alias openstack="oc exec -t openstackclient -- openstack"
43+
${BASH_ALIASES[openstack]} share type create {{ share_type_name }} {{ driver_handles_share_servers }}
44+
vars:
45+
share_type_name: default
46+
driver_handles_share_servers: false

tests/roles/manila_adoption/tasks/netapp.yaml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- name: Deploy Podified Manila - Netapp
1+
- name: Get manila.conf from controller nodes
22
block:
33
- name: Slurp manila.conf from controller
44
become: true
@@ -8,11 +8,26 @@
88
CONTROLLER1_SCP="{{ controller1_ssh | regex_replace('^ssh', 'scp')}}"
99
${CONTROLLER1_SCP}:{{ manila_tripleo_path }} {{ manila_conf_path }}
1010
11-
- name: Extract Netapp data from manila.conf
12-
ansible.builtin.set_fact:
13-
manila_netapp_config: "{{ manila_netapp_config | default({}) | combine({item: lookup('ansible.builtin.ini', item, file=manila_conf_path, section=manila_netapp_backend, allow_no_value=True)}) }}"
14-
loop: "{{ manila_netapp_vars }}"
11+
- name: Stat the retrieved manila.conf file
12+
ansible.builtin.stat:
13+
path: "{{ manila_conf_path }}"
14+
register: manila_conf
15+
16+
- name: Fail if manila.conf is not present
17+
when: not manila_conf.stat.exists
18+
ansible.builtin.fail:
19+
msg: "manila.conf does not exist"
1520

21+
- name: Deploy Podified Manila - Netapp
22+
vars:
23+
manila_netapp_config: |
24+
{% set manila_netapp_conf = {} %}
25+
{% for item in manila_netapp_vars %}
26+
{% set value = lookup('ansible.builtin.ini', item, file=manila_conf_path, section=manila_netapp_backend, allow_no_value=True) %}
27+
{% set _ = manila_netapp_conf.__setitem__(item, value) %}
28+
{% endfor %}
29+
{{ manila_netapp_conf }}
30+
block:
1631
- name: Fail if manila_netapp_config params are not defined
1732
when: |
1833
manila_netapp_config.netapp_login is not defined or

0 commit comments

Comments
 (0)