Add compute capabilities traits

The virt driver API in nova has a capabilities dict that lists the
capabilities of the virt driver.

Based on the patch at https://review.openstack.org/#/c/538498/6, let's
try to standardize the relevant capabilities into a new
os_traits.compute module.

Change-Id: I77f2c4c696010dfe25d3282374dac702b08abaa6
This commit is contained in:
Jay Pipes 2018-02-21 12:48:57 -05:00
parent 2c704cae31
commit 56531c2a81
4 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# 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.
TRAITS = [
# The virt driver supports associating a tag with a device *at boot time*
'DEVICE_TAGGING',
]

21
os_traits/compute/net.py Normal file
View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# 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.
TRAITS = [
# The virt driver supports attaching a network interface after boot
'ATTACH_INTERFACE',
# The virt driver supports attaching a network interface after boot and
# specifying a device tag for the interface
'ATTACH_INTERFACE_WITH_TAG',
]

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# 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.
TRAITS = [
# The virt driver supports attaching a volume after boot
'ATTACH',
# The virt driver supports attaching a volume after boot and specifying a
# device tag for the volume
'ATTACH_WITH_TAG',
# The virt driver supports extending a volume after boot
'EXTEND',
# The virt driver supports volumes that can be attached to multiple guests
'MULTI_ATTACH',
]

View File

@ -47,6 +47,16 @@ class TestSymbols(base.TestCase):
self.assertNotIn('CUSTOM_NAMESPACE', traits)
self.assertNotIn('os_traits', traits)
def test_dunderinit_and_nondunderinit(self):
"""Make sure we can have both dunderinit'd traits and submodules
co-exist in the same namespace.
"""
traits = ot.get_traits('COMPUTE')
self.assertIn("COMPUTE_DEVICE_TAGGING", traits)
self.assertIn(ot.COMPUTE_DEVICE_TAGGING, traits)
self.assertIn("COMPUTE_VOLUME_EXTEND", traits)
self.assertIn(ot.COMPUTE_NET_ATTACH_INTERFACE, traits)
def test_get_traits_filter_by_suffix(self):
traits = ot.get_traits(suffix='SSE42')
self.assertIn("HW_CPU_X86_SSE42", traits)