[Cinder] Add visibilty settings to volume types
This is to add public/private visibility option and project level access list to a volume type while creating. Change-Id: Id33c8c9f10e60fcdb4b6c49e69f3b5d8f11850c6
This commit is contained in:
parent
1d9e3ecc00
commit
48625ad984
@ -14,7 +14,7 @@ apiVersion: v1
|
|||||||
appVersion: v1.0.0
|
appVersion: v1.0.0
|
||||||
description: OpenStack-Helm Cinder
|
description: OpenStack-Helm Cinder
|
||||||
name: cinder
|
name: cinder
|
||||||
version: 0.2.18
|
version: 0.2.19
|
||||||
home: https://docs.openstack.org/cinder/latest/
|
home: https://docs.openstack.org/cinder/latest/
|
||||||
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Cinder/OpenStack_Project_Cinder_vertical.png
|
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Cinder/OpenStack_Project_Cinder_vertical.png
|
||||||
sources:
|
sources:
|
||||||
|
@ -22,30 +22,53 @@ export HOME=/tmp
|
|||||||
{{- /* Create volume types defined in Values.bootstrap */}}
|
{{- /* Create volume types defined in Values.bootstrap */}}
|
||||||
{{- /* Types can only be created for backends defined in Values.conf */}}
|
{{- /* Types can only be created for backends defined in Values.conf */}}
|
||||||
{{- $volumeTypes := .Values.bootstrap.volume_types }}
|
{{- $volumeTypes := .Values.bootstrap.volume_types }}
|
||||||
|
{{- /* Generating list of backends listed in .Values.conf.backends */}}
|
||||||
|
{{- $backendsList := list}}
|
||||||
{{- range $backend_name, $backend_properties := .Values.conf.backends }}
|
{{- range $backend_name, $backend_properties := .Values.conf.backends }}
|
||||||
{{- if $backend_properties }}
|
{{- if and $backend_properties $backend_properties.volume_backend_name }}
|
||||||
{{- range $name, $properties := $volumeTypes }}
|
{{- $backendsList = append $backendsList $backend_properties.volume_backend_name }}
|
||||||
{{- if $properties.volume_backend_name }}
|
{{- end }}
|
||||||
{{- if (eq $properties.volume_backend_name $backend_properties.volume_backend_name) }}
|
{{- end }}
|
||||||
if [[ $(openstack volume type list -f value -c Name | grep -w {{ $name }}) ]]; then
|
|
||||||
if [[ ! $(openstack volume type show {{ $name }} | grep volume_backend_name) ]]; then
|
{{- range $name, $properties := $volumeTypes }}
|
||||||
openstack volume type set \
|
{{- if and $properties.volume_backend_name (has $properties.volume_backend_name $backendsList) }}
|
||||||
{{- range $key, $value := $properties }}
|
{{- $access_type := $properties.access_type | default "public"}}
|
||||||
--property {{ $key }}={{ $value }} \
|
# Create a volume type if it doesn't exist.
|
||||||
{{- end }}
|
# Assumption: the volume type name is unique.
|
||||||
|
openstack volume type show {{ $name }} || \
|
||||||
|
openstack volume type create \
|
||||||
|
--{{ $access_type }} \
|
||||||
{{ $name }}
|
{{ $name }}
|
||||||
fi
|
{{/*
|
||||||
else
|
We will try to set or update volume type properties.
|
||||||
openstack volume type create \
|
To update properties, the volume type MUST NOT BE IN USE,
|
||||||
--public \
|
and projects and domains with access to the volume type
|
||||||
{{- range $key, $value := $properties }}
|
MUST EXIST, as well.
|
||||||
--property {{ $key }}={{ $value }} \
|
*/}}
|
||||||
{{- end }}
|
is_in_use=$(openstack volume list --long --all-projects -c Type -f value | grep -E "^{{ $name }}\s*$" || true)
|
||||||
{{ $name }}
|
if [[ -z ${is_in_use} ]]; then
|
||||||
fi
|
{{- if (eq $access_type "private") }}
|
||||||
{{- end }}
|
volumeTypeID=$(openstack volume type show {{ $name }} -f value -c id)
|
||||||
|
cinder type-update --is-public false ${volumeTypeID}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
|
||||||
|
{{- if and $properties.grant_access (eq $access_type "private") }}
|
||||||
|
{{- range $domain, $domainProjects := $properties.grant_access }}
|
||||||
|
{{- range $project := $domainProjects }}
|
||||||
|
project_id=$(openstack project show --domain {{ $domain }} -c id -f value {{ $project }})
|
||||||
|
if [[ -z $(openstack volume type show {{ $name }} -c access_project_ids -f value | grep ${project_id} || true) ]]; then
|
||||||
|
openstack volume type set --project-domain {{ $domain }} --project {{ $project }} {{ $name }}
|
||||||
|
fi
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- range $key, $value := $properties }}
|
||||||
|
{{- if and (ne $key "access_type") (ne $key "grant_access") $value }}
|
||||||
|
openstack volume type set --property {{ $key }}={{ $value }} {{ $name }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
fi
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
@ -53,11 +76,11 @@ fi
|
|||||||
{{- if .Values.bootstrap.bootstrap_conf_backends }}
|
{{- if .Values.bootstrap.bootstrap_conf_backends }}
|
||||||
{{- range $name, $properties := .Values.conf.backends }}
|
{{- range $name, $properties := .Values.conf.backends }}
|
||||||
{{- if $properties }}
|
{{- if $properties }}
|
||||||
openstack volume type show {{ $name }} || \
|
openstack volume type show {{ $name }} || \
|
||||||
openstack volume type create \
|
openstack volume type create \
|
||||||
--public \
|
--public \
|
||||||
--property volume_backend_name={{ $properties.volume_backend_name }} \
|
--property volume_backend_name={{ $properties.volume_backend_name }} \
|
||||||
{{ $name }}
|
{{ $name }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@ -65,32 +88,31 @@ openstack volume type show {{ $name }} || \
|
|||||||
{{- /* Create and associate volume QoS if defined */}}
|
{{- /* Create and associate volume QoS if defined */}}
|
||||||
{{- if .Values.bootstrap.volume_qos}}
|
{{- if .Values.bootstrap.volume_qos}}
|
||||||
{{- range $qos_name, $qos_properties := .Values.bootstrap.volume_qos }}
|
{{- range $qos_name, $qos_properties := .Values.bootstrap.volume_qos }}
|
||||||
type_defined=true
|
type_defined=true
|
||||||
{{- /* If the volume type to associate with is not defined, skip the qos */}}
|
{{- /* If the volume type to associate with is not defined, skip the qos */}}
|
||||||
{{- range $qos_properties.associates }}
|
{{- range $qos_properties.associates }}
|
||||||
if ! openstack volume type show {{ . }}; then
|
if ! openstack volume type show {{ . }}; then
|
||||||
type_defined=false
|
type_defined=false
|
||||||
fi
|
fi
|
||||||
{{- end }}
|
{{- end }}
|
||||||
if $type_defined; then
|
if [[ ${type_defined} ]]; then
|
||||||
openstack volume qos show {{ $qos_name }} || \
|
openstack volume qos show {{ $qos_name }} || \
|
||||||
openstack volume qos create \
|
openstack volume qos create \
|
||||||
--consumer {{ $qos_properties.consumer }} \
|
--consumer {{ $qos_properties.consumer }} \
|
||||||
{{- range $key, $value := $qos_properties.properties }}
|
{{- range $key, $value := $qos_properties.properties }}
|
||||||
--property {{ $key }}={{ $value }} \
|
--property {{ $key }}={{ $value }} \
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ $qos_name }}
|
{{ $qos_name }}
|
||||||
{{- range $qos_properties.associates }}
|
{{- range $qos_properties.associates }}
|
||||||
openstack volume qos associate {{ $qos_name }} {{ . }}
|
openstack volume qos associate {{ $qos_name }} {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
fi
|
fi
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- /* Check volume type and properties were added */}}
|
{{- /* Check volume type and properties were added */}}
|
||||||
openstack volume type list --long
|
openstack volume type list --long
|
||||||
openstack volume qos list
|
openstack volume qos list
|
||||||
|
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -368,6 +368,19 @@ bootstrap:
|
|||||||
name:
|
name:
|
||||||
group:
|
group:
|
||||||
volume_backend_name:
|
volume_backend_name:
|
||||||
|
# access_type: "private"
|
||||||
|
# If you set up access_type to private, only the creator
|
||||||
|
# will get an access to the volume type. You can extend
|
||||||
|
# the access to your volume type by providing a list of
|
||||||
|
# domain names and projects as shown below
|
||||||
|
# grant_access:
|
||||||
|
# <domain name 1>:
|
||||||
|
# - <project name 1>
|
||||||
|
# - <project name 2>
|
||||||
|
# <...>
|
||||||
|
# <domain name 2>:
|
||||||
|
# - <project name 1>
|
||||||
|
# <...>
|
||||||
# Volume QoS if any. By default, None QoS is created.
|
# Volume QoS if any. By default, None QoS is created.
|
||||||
# Below values with a number at the end need to be replaced
|
# Below values with a number at the end need to be replaced
|
||||||
# with real names.
|
# with real names.
|
||||||
|
@ -22,6 +22,10 @@ bootstrap:
|
|||||||
PURE-MULTIATTACH:
|
PURE-MULTIATTACH:
|
||||||
multiattach: "\"<is> True\""
|
multiattach: "\"<is> True\""
|
||||||
volume_backend_name: "PURE_BE"
|
volume_backend_name: "PURE_BE"
|
||||||
|
access_type: "private"
|
||||||
|
grant_access:
|
||||||
|
default:
|
||||||
|
- admin
|
||||||
conf:
|
conf:
|
||||||
cinder:
|
cinder:
|
||||||
DEFAULT:
|
DEFAULT:
|
||||||
|
@ -35,4 +35,5 @@ cinder:
|
|||||||
- 0.2.16 Enable taint toleration for Openstack services
|
- 0.2.16 Enable taint toleration for Openstack services
|
||||||
- 0.2.17 Remove unsupported values overrides
|
- 0.2.17 Remove unsupported values overrides
|
||||||
- 0.2.18 Add helm hook in bootstrap job
|
- 0.2.18 Add helm hook in bootstrap job
|
||||||
|
- 0.2.19 Add volume types visibility (public/private)
|
||||||
...
|
...
|
||||||
|
Loading…
Reference in New Issue
Block a user