Introduce VIFState object
This object will be used by the Zun CNI plugin which is under development. Change-Id: I093fdfc5beb1ca45993b36c4c9512fa511773965 Implements: blueprint support-cni
This commit is contained in:
parent
29df262075
commit
9cc9267897
@ -70,6 +70,7 @@ os-resource-classes==0.1.0
|
||||
os-service-types==1.2.0
|
||||
os-testr==1.0.0
|
||||
os-traits==0.15.0
|
||||
os-vif==1.15.1
|
||||
os-win==4.0.0
|
||||
osc-lib==1.10.0
|
||||
oslo.cache==1.29.0
|
||||
|
@ -29,6 +29,7 @@ oslo.upgradecheck>=0.1.0 # Apache-2.0
|
||||
os-brick>=2.2.0 # Apache-2.0
|
||||
os-resource-classes>=0.1.0 # Apache-2.0
|
||||
os-traits>=0.15.0 # Apache-2.0
|
||||
os-vif>=1.15.1 # Apache-2.0
|
||||
six>=1.10.0 # MIT
|
||||
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
|
@ -25,6 +25,7 @@ from zun.objects import registry
|
||||
from zun.objects import request_group
|
||||
from zun.objects import resource_class
|
||||
from zun.objects import resource_provider
|
||||
from zun.objects import vif
|
||||
from zun.objects import volume
|
||||
from zun.objects import volume_mapping
|
||||
from zun.objects import zun_network
|
||||
@ -56,6 +57,7 @@ ContainerActionEvent = container_action.ContainerActionEvent
|
||||
ExecInstance = exec_instance.ExecInstance
|
||||
Registry = registry.Registry
|
||||
RequestGroup = request_group.RequestGroup
|
||||
VIFState = vif.VIFState
|
||||
|
||||
__all__ = (
|
||||
'Container',
|
||||
@ -82,4 +84,5 @@ __all__ = (
|
||||
'ExecInstance',
|
||||
'Registry',
|
||||
'RequestGroup',
|
||||
'VIFState',
|
||||
)
|
||||
|
@ -10,10 +10,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from os_vif.objects import vif
|
||||
from oslo_serialization import jsonutils as json
|
||||
from oslo_versionedobjects import fields
|
||||
import six
|
||||
|
||||
from zun.common import consts
|
||||
|
||||
@ -132,3 +132,8 @@ class PciDeviceTypeField(fields.BaseEnumField):
|
||||
|
||||
class PciDeviceStatusField(fields.BaseEnumField):
|
||||
AUTO_TYPE = PciDeviceStatus()
|
||||
|
||||
|
||||
class DictOfVIFsField(fields.AutoTypedField):
|
||||
AUTO_TYPE = fields.Dict(fields.Object(vif.VIFBase.__name__,
|
||||
subclasses=True))
|
||||
|
45
zun/objects/vif.py
Normal file
45
zun/objects/vif.py
Normal file
@ -0,0 +1,45 @@
|
||||
# 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.
|
||||
|
||||
from os_vif.objects import vif as obj_osvif
|
||||
from oslo_versionedobjects import fields as obj_fields
|
||||
|
||||
from zun.common import consts
|
||||
from zun.objects import base
|
||||
from zun.objects import fields as zun_fields
|
||||
|
||||
|
||||
@base.ZunObjectRegistry.register
|
||||
class VIFState(base.ZunObject):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
|
||||
# FIXME(dulek): I know it's an ugly hack, but turns out you cannot
|
||||
# serialize-deserialize objects containing objects from
|
||||
# different namespaces, so we need 'os_vif' namespace here.
|
||||
OBJ_PROJECT_NAMESPACE = 'os_vif'
|
||||
OBJ_SERIAL_NAMESPACE = 'versioned_object'
|
||||
|
||||
fields = {
|
||||
'default_vif': obj_fields.ObjectField(obj_osvif.VIFBase.__name__,
|
||||
subclasses=True, nullable=False),
|
||||
'additional_vifs': zun_fields.DictOfVIFsField(default={}),
|
||||
}
|
||||
|
||||
@property
|
||||
def vifs(self):
|
||||
d = {
|
||||
consts.DEFAULT_IFNAME: self.default_vif,
|
||||
}
|
||||
if self.obj_attr_is_set('additional_vifs'):
|
||||
d.update(self.additional_vifs)
|
||||
return d
|
@ -380,8 +380,14 @@ class TestObjectVersions(test_base.TestCase):
|
||||
# Test the versions of current objects with the static tree above.
|
||||
# This ensures that any incompatible object changes require a version
|
||||
# bump.
|
||||
classes = base.ZunObjectRegistry.obj_classes()
|
||||
checker = fixture.ObjectVersionChecker(obj_classes=classes)
|
||||
all_classes = base.ZunObjectRegistry.obj_classes()
|
||||
zun_classes = {}
|
||||
for name in all_classes:
|
||||
objclasses = all_classes[name]
|
||||
if (objclasses[0].OBJ_PROJECT_NAMESPACE ==
|
||||
base.ZunObject.OBJ_PROJECT_NAMESPACE):
|
||||
zun_classes[name] = objclasses
|
||||
checker = fixture.ObjectVersionChecker(obj_classes=zun_classes)
|
||||
|
||||
expected, actual = checker.test_hashes(object_data)
|
||||
self.assertEqual(expected, actual,
|
||||
|
Loading…
Reference in New Issue
Block a user