Expose max_local_block_devices as an explicit charm option

It's useful to force instance creations to fail if ephemeral drives are
requested when cloud admins want users to use persistent volumes always.

Closes-Bug: #1953561
Change-Id: I1c958b4bcf79512c06de6d81fe55c681bb5f38a7
This commit is contained in:
Nobuto Murata 2021-12-08 10:50:55 +09:00
parent 1c7f320cb6
commit 0e9136fe1e
13 changed files with 53 additions and 0 deletions

View File

@ -770,3 +770,12 @@ options:
Allow resizing to the same host. Setting this option to True will add the
source host to the destination options for consideration by the
scheduler when resizing an instance.
max-local-block-devices:
type: int
default:
description: |
Maximum number of local devices which can be attached to an
instance. Possible values are 0: Creating a local disk is not
allowed and letting the request fail, Negative number: Allows
unlimited number of local devices, Positive number: Allows only
these many number of local devices.

View File

@ -449,6 +449,8 @@ class NovaConfigContext(ch_context.WorkerConfigContext):
'placement-aggregate-required-for-tenants')
ctxt['enable_isolated_aggregate_filtering'] = hookenv.config(
'enable-isolated-aggregate-filtering')
ctxt['max_local_block_devices'] = hookenv.config(
'max-local-block-devices')
return ctxt

View File

@ -93,6 +93,10 @@ keystone_ec2_url = {{ keystone_ec2_url }}
glance_api_servers = {{ glance_api_servers }}
{% endif -%}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -99,6 +99,10 @@ keystone_ec2_url = {{ keystone_ec2_url }}
glance_api_servers = {{ glance_api_servers }}
{% endif -%}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -99,6 +99,10 @@ memcached_servers = {{ memcached_servers }}
keystone_ec2_url = {{ keystone_ec2_url }}
{% endif -%}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -102,6 +102,10 @@ memcached_servers = {{ memcached_servers }}
keystone_ec2_url = {{ keystone_ec2_url }}
{% endif -%}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -87,6 +87,10 @@ quota_server_group_members = {{ quota_server_group_members }}
{% include "parts/novnc" %}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -90,6 +90,10 @@ quota_server_group_members = {{ quota_server_group_members }}
{% include "parts/novnc" %}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -47,6 +47,10 @@ my_ip = {{ host_ip }}
{% include "parts/novnc" %}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -52,6 +52,10 @@ my_ip = {{ host_ip }}
{% include "parts/novnc" %}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -52,6 +52,10 @@ my_ip = {{ host_ip }}
{% include "parts/novnc" %}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -52,6 +52,10 @@ my_ip = {{ host_ip }}
{% include "parts/novnc" %}
{% if max_local_block_devices is not none -%}
max_local_block_devices = {{ max_local_block_devices }}
{% endif -%}
{% if rbd_pool -%}
rbd_pool = {{ rbd_pool }}
rbd_user = {{ rbd_user }}

View File

@ -401,6 +401,8 @@ class NovaComputeContextTests(CharmTestCase):
)
self.assertEqual(ctxt['enable_isolated_aggregate_filtering'],
self.config('enable-isolated-aggregate-filtering'))
self.assertEqual(ctxt['max_local_block_devices'],
self.config('max-local-block-devices'))
_pci_alias1 = {
"name": "IntelNIC",