Skip to content

Commit 6e494d7

Browse files
committed
cinder adoption: add support for PureStorage/FC
Support the adoption of a cinder/PureStorage backend. This initial implementation only supports FiberChannel, but the code is generic enough that it should be easy to add other supported protocols, following the pattern already followed for the cinder/NetApp adoption. In fact this code follows a lot the workflow already used for the cinder/NetApp adoption, minimizing the amount of facts sets: - the configuration is fetched from 17.1, checking if all required variables are available; - sensitive details retrieved (basically the API key) are stored as a secret in the OpenShift cluster; - a cinder-volume spec is defined using the retrieved configuration and the secret, and applied to the control plane.
1 parent cd1af69 commit 6e494d7

File tree

5 files changed

+103
-2
lines changed

5 files changed

+103
-2
lines changed

tests/roles/cinder_adoption/defaults/main.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Volume backends: ceph, ontap-nfs, ontap-iscsi
1+
# Volume backends: ceph, ontap-nfs, ontap-iscsi, pure-fc
22
# Backup backends: ceph, swift, ontap-nfs
33
cinder_volume_backend: ""
44
cinder_backup_backend: ""
@@ -116,8 +116,9 @@ cinder_conf_path: "/tmp/cinder.conf"
116116
# The path where we temporarily save shares.conf fetched from TripleO controller node
117117
cinder_nfs_shares_conf_path: "/tmp/shares.conf"
118118

119-
# The backend name generated by puppet-tripleo
119+
# The backend names generated by puppet-tripleo
120120
cinder_netapp_backend: "tripleo_netapp"
121+
cinder_pure_backend: "tripleo_pure"
121122

122123
# List of netapp credentials to be captured from tripleo cinder.conf
123124
cinder_volume_netapp_vars:
@@ -127,6 +128,11 @@ cinder_volume_netapp_vars:
127128
- netapp_vserver
128129
- netapp_pool_name_search_pattern
129130

131+
# List of pure credentials to be captured from tripleo cinder
132+
cinder_volume_pure_vars:
133+
- san_ip
134+
- pure_api_token
135+
130136
# Vars for cinder-backup
131137
cinder_backup_nfs_backup_mount_point_base: "/var/lib/cinder/backup"
132138
cinder_retry_delay: 5
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
- name: Slurp cinder.conf from controller
2+
become: true
3+
ansible.builtin.shell: |
4+
{{ shell_header }}
5+
CONTROLLER1_SCP="{{ controller1_ssh | regex_replace('^ssh', 'scp')}}"
6+
${CONTROLLER1_SCP}:{{ cinder_tripleo_path }} {{ cinder_conf_path }}
7+
chmod a+r {{ cinder_conf_path }}
8+
9+
- name: Stat the retrieved cinder.conf file
10+
ansible.builtin.stat:
11+
path: "{{ cinder_conf_path }}"
12+
register: cinder_conf
13+
14+
- name: Fail if cinder.conf is not present
15+
when: not cinder_conf.stat.exists
16+
ansible.builtin.fail:
17+
msg: "cinder.conf does not exist"
18+
19+
- name: Deploy Podified Cinder-Volume - Pure
20+
vars:
21+
cinder_pure_config: |
22+
{% set cinder_pure_conf = {} %}
23+
{% for item in cinder_volume_pure_vars %}
24+
{% set value = lookup('ansible.builtin.ini', item, file=cinder_conf_path, section=cinder_pure_backend, allow_no_value=True) %}
25+
{% set _ = cinder_pure_conf.__setitem__(item, value) %}
26+
{% endfor %}
27+
{{ cinder_pure_conf }}
28+
cinder_configuration_template:
29+
pure-fc: 'cinder_volume_pure_fc.yaml.j2'
30+
block:
31+
- name: Fail if cinder_pure_config params are not defined
32+
when: |
33+
cinder_pure_config.san_ip is not defined or
34+
cinder_pure_config.pure_api_token is not defined
35+
ansible.builtin.fail:
36+
msg:
37+
- 'Missing required pure-related parameters in the configuration of the cluster being adopted'
38+
39+
- name: Render Pure OpenShift Secret template
40+
ansible.builtin.template:
41+
src: "{{ role_path }}/templates/cinder-volume-pure-secrets.yaml.j2"
42+
dest: /tmp/cinder-volume-pure-secrets.yaml
43+
mode: "0600"
44+
45+
- name: Render cinder pure OpenShift patch file template
46+
ansible.builtin.template:
47+
src: "{{ role_path }}/templates/{{ cinder_configuration_template[cinder_volume_backend] }}"
48+
dest: /tmp/cinder_volume_pure_config.yaml
49+
mode: "0600"
50+
51+
- name: Apply the rendered Pure secret in the openstack namespace
52+
ansible.builtin.shell: |
53+
{{ shell_header }}
54+
{{ oc_header }}
55+
oc apply -f /tmp/cinder-volume-pure-secrets.yaml
56+
57+
- name: Configure the appropriate pure backend
58+
ansible.builtin.shell: |
59+
{{ shell_header }}
60+
{{ oc_header }}
61+
oc patch openstackcontrolplane openstack --type=merge --patch-file=/tmp/cinder_volume_pure_config.yaml

tests/roles/cinder_adoption/tasks/volume_backend.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
cinder_volume_backend == 'ontap-nfs' or
1111
cinder_volume_backend == 'ontap-iscsi'
1212
ansible.builtin.include_tasks: cinder_volume_netapp.yaml
13+
14+
- name: deploy podified Cinder volume with pure FC
15+
when: >
16+
cinder_volume_backend == 'pure-fc'
17+
ansible.builtin.include_tasks: cinder_volume_pure.yaml
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Define the "cinder-volume-pure-secrets" Secret that contains sensitive
2+
# information pertaining to the pure-based backends.
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
labels:
7+
service: cinder
8+
component: cinder-volume
9+
name: cinder-volume-pure-secrets
10+
type: Opaque
11+
stringData:
12+
pure-cinder-secrets: |
13+
[{{ cinder_pure_backend }}]
14+
san_ip = {{ cinder_pure_config.san_ip }}
15+
pure_api_token = {{ cinder_pure_config.pure_api_token }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
spec:
2+
cinder:
3+
template:
4+
cinderVolumes:
5+
pure-fc:
6+
networkAttachments:
7+
- storage
8+
customServiceConfig: |
9+
[{{ cinder_pure_backend }}]
10+
volume_backend_name=pure-fc
11+
volume_driver=cinder.volume.drivers.pure.PureFCDriver
12+
consistencygroup_support=True
13+
customServiceConfigSecrets:
14+
- cinder-volume-pure-secrets

0 commit comments

Comments
 (0)