# not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``accel`` namespaced extra specs.""" from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='accel:device_profile', description=( 'The name of a device profile to configure for the instance. ' 'A device profile may be viewed as a "flavor for devices".'), value={ 'type': str, 'description': 'A name of a device profile.', }, ), ] def register(): return EXTRA_SPEC_VALIDATORS
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``hw_rng`` namespaced extra specs.""" from nova.api.validation.extra_specs import base # TODO(stephenfin): Move these to the 'hw:' namespace EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='hw_rng:allowed', description=( 'Whether to disable configuration of a random number generator ' 'in their image. Before 21.0.0 (Ussuri), random number generators ' 'were not enabled by default so this was used to determine ' 'whether to **enable** configuration.'), value={ 'type': bool, }, ), base.ExtraSpecValidator( name='hw_rng:rate_bytes', description=( 'The allowed amount of bytes for the guest to read from the ' 'host\'s entropy per period.'), value={ 'type': int, 'min': 0, }, ),
from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [] for trait in os_traits.get_traits(): EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name=f'trait{{group}}:{trait}', description=f'Require or forbid trait {trait}.', value={ 'type': str, 'enum': [ 'required', 'forbidden', ], }, parameters=[ { 'name': 'group', 'pattern': r'([a-zA-Z0-9_-]{1,64})?', }, ], )) EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name='trait{group}:CUSTOM_{trait}', description=('Require or forbid trait CUSTOM_{trait}.'), value={ 'type': str,
These were all taken from the IBM documentation. https://www.ibm.com/support/knowledgecenter/SSXK2N_1.4.4/com.ibm.powervc.standard.help.doc/powervc_pg_flavorsextraspecs_hmc.html """ from nova.api.validation.extra_specs import base # TODO(stephenfin): A lot of these seem to overlap with existing 'hw:' extra # specs and could be deprecated in favour of those. EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='powervm:min_mem', description=( 'Minimum memory (MB). If you do not specify the value, the value ' 'is defaulted to the value for ``memory_mb``.'), value={ 'type': int, 'min': 256, 'description': 'Integer >=256 divisible by LMB size of the target', }, ), base.ExtraSpecValidator( name='powervm:max_mem', description=( 'Maximum memory (MB). If you do not specify the value, the value ' 'is defaulted to the value for ``memory_mb``.'), value={ 'type': int, 'min': 256, 'description': 'Integer >=256 divisible by LMB size of the target', },
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``pci_passthrough`` namespaced extra specs.""" from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='pci_passthrough:alias', description=( 'Specify the number of ``$alias`` PCI device(s) to attach to the ' 'instance. ' 'Must be of format ``$alias:$count``, where ``$alias`` ' 'corresponds to a particular PCI device class (as configured in ' '``nova.conf``) and ``$count`` is the amount of PCI devices of ' 'type ``$alias`` to be assigned to the instance. ' 'Use commas to specify multiple values. ' 'Only supported by the libvirt virt driver.'), value={ 'type': str, # one or more comma-separated '$alias:$count' values 'pattern': r'[^:]+:\d+(?:\s*,\s*[^:]+:\d+)*', }, ), ] def register(): return EXTRA_SPEC_VALIDATORS
# License for the specific language governing permissions and limitations # under the License. """Validators for ``os`` namespaced extra specs.""" from nova.api.validation.extra_specs import base # TODO(stephenfin): Most of these belong in the 'hw:' or 'hyperv:' namespace # and should be moved. EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='os:secure_boot', description=( 'Determine whether secure boot is enabled or not. Currently only ' 'supported by the HyperV driver.'), value={ 'type': str, 'description': 'Whether secure boot is required or not', 'enum': [ 'disabled', 'required', ], }, ), base.ExtraSpecValidator( name='os:resolution', description=( 'Guest VM screen resolution size. Only supported by the HyperV ' 'driver.'), value={ 'type': str, 'description':
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``hw`` namespaced extra specs.""" from nova.api.validation.extra_specs import base realtime_validators = [ base.ExtraSpecValidator( name='hw:cpu_realtime', description=( 'Determine whether realtime mode should be enabled for the ' 'instance or not. ' 'Only supported by the libvirt virt driver.'), value={ 'type': bool, 'description': 'Whether to enable realtime priority.', }, ), base.ExtraSpecValidator( name='hw:cpu_realtime_mask', description=('A exclusion mask of CPUs that should not be enabled for ' 'realtime. ' 'Only supported by the libvirt virt driver.'), value={ 'type': str, 'pattern': r'(\^)?\d+((-\d+)?(,\^?\d+(-\d+)?)?)*', }, ),
for key, name, unit in ( ('cpu', 'CPU', 'MHz'), ('memory', 'memory', 'MB'), ('disk_io', 'disk IO', 'I/O per second'), ('vif', 'virtual interface', 'Mbps'), ): EXTRA_SPEC_VALIDATORS.extend([ base.ExtraSpecValidator( name=f'quota:{key}_limit', description=( f'The upper limit for {name} allocation in {unit}. ' f'The utilization of an instance will not exceed this ' f'limit, even if there are available resources. ' f'This is typically used to ensure a consistent ' f'performance of instances independent of available ' f'resources.' f'The value ``0`` indicates that {name} usage is not ' f'limited.' f'Only supported by the VMWare virt driver.'), value={ 'type': int, 'min': 0, }, ), base.ExtraSpecValidator( name=f'quota:{key}_reservation', description=( f'The guaranteed minimum {name} reservation in {unit}. ' f'This means the specified amount of {name} that will ' f'be guaranteed for the instance. ' f'Only supported by the VMWare virt driver.'),
import os_resource_classes from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [] for resource_class in os_resource_classes.STANDARDS: EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name=f'resources{{group}}:{resource_class}', description=f'The amount of resource {resource_class} requested.', value={ 'type': int, }, parameters=[ { 'name': 'group', 'pattern': r'([a-zA-Z0-9_-]{1,64})?', }, ], )) EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name='resources{group}:CUSTOM_{resource}', description=('The amount of resource CUSTOM_{resource} requested.'), value={ 'type': int, }, parameters=[
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for non-namespaced extra specs.""" from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='hide_hypervisor_id', description=( 'Determine whether the hypervisor ID should be hidden from the ' 'guest. Only supported by the libvirt virt driver. ' 'This extra spec is not compatible with the ' 'AggregateInstanceExtraSpecsFilter scheduler filter. ' 'The ``hw:hide_hypervisor_id`` extra spec should be used instead.' ), value={ 'type': bool, 'description': 'Whether to hide the hypervisor ID.', }, deprecated=True, ), # TODO(stephenfin): This should be moved to a namespace base.ExtraSpecValidator( name='group_policy', description=( 'The group policy to apply when using the granular resource ' 'request syntax.'), value={ 'type': str,
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for non-namespaced extra specs.""" from nova.api.validation.extra_specs import base # TODO(stephenfin): These should be moved to a namespace EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='hide_hypervisor_id', description=( 'Determine whether the hypervisor ID should be hidden from the ' 'guest. Only supported by the libvirt driver.'), value={ 'type': bool, 'description': 'Whether to hide the hypervisor ID.', }, ), base.ExtraSpecValidator( name='group_policy', description=( 'The group policy to apply when using the granular resource ' 'request syntax.'), value={ 'type': str, 'enum': [ 'isolate', 'none', ],
import os_traits from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [] for trait in os_traits.get_traits(): EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name=f'trait{{group}}:{trait}', description=f'Require or forbid trait {trait}.', value={ 'type': str, 'enum': [ 'required', 'forbidden', ], }, parameters=[ { 'name': 'group', 'pattern': r'(_[a-zA-z0-9_]*|\d+)?', }, ], )) def register(): return EXTRA_SPEC_VALIDATORS
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``hw_video`` namespaced extra specs.""" from nova.api.validation.extra_specs import base # TODO(stephenfin): Move these to the 'hw:' namespace EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='hw_video:ram_max_mb', description=( 'The maximum amount of memory the user can request using the ' '``hw_video_ram`` image metadata property, which represents the ' 'video memory that the guest OS will see. This has no effect for ' 'vGPUs.' ), value={ 'type': int, 'min': 0, }, ), ] def register(): return EXTRA_SPEC_VALIDATORS
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``pci_passthrough`` namespaced extra specs.""" from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='pci_passthrough:alias', description=( 'Specify the number of ``$alias`` PCI device(s) to attach to the ' 'instance. Must be of format ``$alias:$number``. Use commas to ' 'specify multiple values.'), value={ 'type': str, # one or more comma-separated '$alias:$num' values 'pattern': r'[^:]+:\d+(?:\s*,\s*[^:]+:\d+)*', }, ), ] def register(): return EXTRA_SPEC_VALIDATORS
* ``s<=`` (less than or equal to as a string) * ``s<`` (less than as a string) * ``<in>`` (substring) * ``<all-in>`` (all elements contained in collection) * ``<or>`` (find one of these) * A specific value, e.g. ``true``, ``123``, ``testing`` """ EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='aggregate_instance_extra_specs:{key}', description=DESCRIPTION, parameters=[ { 'name': 'key', 'description': 'The metadata key to match on', 'pattern': r'.+', }, ], value={ # this is totally arbitary, since we need to support specific # values 'type': str, }, ), ] def register(): return EXTRA_SPEC_VALIDATORS
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``hw`` namespaced extra specs.""" from nova.api.validation.extra_specs import base realtime_validators = [ base.ExtraSpecValidator( name='hw:cpu_realtime', description=( 'Determine whether realtime mode should be enabled for the ' 'instance or not. Only supported by the libvirt driver.' ), value={ 'type': bool, 'description': 'Whether to enable realtime priority.', }, ), base.ExtraSpecValidator( name='hw:cpu_realtime_mask', description=( 'A exclusion mask of CPUs that should not be enabled for realtime.' ), value={ 'type': str, 'pattern': r'(\^)?\d+((-\d+)?(,\^?\d+(-\d+)?)?)*', }, ),
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. """Validators for ``vmware`` namespaced extra specs.""" from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [ base.ExtraSpecValidator( name='vmware:hw_version', description=( 'Specify the hardware version used to create images. In an ' 'environment with different host versions, you can use this ' 'parameter to place instances on the correct hosts.'), value={ 'type': str, }, ), base.ExtraSpecValidator( name='vmware:storage_policy', description=( 'Specify the storage policy used for new instances.' '\n' 'If Storage Policy-Based Management (SPBM) is not enabled, this ' 'parameter is ignored.'), value={ 'type': str, }, ),
'free_disk_mb', 'vcpus_total', 'vcpus_used', 'num_instances', 'num_io_ops', 'failed_builds', 'aggregates', 'cell_uuid', 'updated', ): EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name=f'capabilities:{capability}', description=DESCRIPTION.format(capability=capability), value={ # this is totally arbitary, since we need to support specific # values 'type': str, }, ), ) # nested capabilities (from 'nova.objects.compute_node.ComputeNode' and # nova.scheduler.host_manager.HostState') for capability in ( 'cpu_info', 'metrics', 'stats', 'numa_topology', 'supported_hv_specs', 'pci_device_pools',
"""Validators for ``quota`` namespaced extra specs.""" from nova.api.validation.extra_specs import base EXTRA_SPEC_VALIDATORS = [] # CPU, memory, disk IO and VIF quotas (VMWare) for resource in ('cpu', 'memory', 'disk_io', 'vif'): for key, fmt in (('limit', int), ('reservation', int), ('shares_level', str), ('shares_share', int)): EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name=f'quota:{resource}_{key}', description=( 'The {} for {}. Only supported by the VMWare virt ' 'driver.'.format(' '.join(key.split('_')), resource)), value={ 'type': fmt, }, )) # CPU quotas (libvirt) for key in ('shares', 'period', 'quota'): EXTRA_SPEC_VALIDATORS.append( base.ExtraSpecValidator( name=f'quota:cpu_{key}', description=( f'The quota {key} for CPU. Only supported by the libvirt ' f'virt driver.'), value={ 'type': int,