示例#1
0
class VimSoftwareImage(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'vim_connection_id': fields.StringField(nullable=True),
        'vnfd_software_image_id': fields.StringField(nullable=False),
        'vim_software_image_id': fields.StringField(nullable=False)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_img = super(VimSoftwareImage,
                            cls).obj_from_primitive(primitive, context)
        else:
            obj_img = VimSoftwareImage._from_dict(primitive)

        return obj_img

    @classmethod
    def _from_dict(cls, data_dict):
        vim_connection_id = data_dict.get('vim_connection_id')
        vnfd_software_image_id = data_dict.get('vnfd_software_image_id')
        vim_software_image_id = data_dict.get('vim_software_image_id')

        obj = cls(vim_connection_id=vim_connection_id,
                  vnfd_software_image_id=vnfd_software_image_id,
                  vim_software_image_id=vim_software_image_id)
        return obj
示例#2
0
class VimComputeResourceFlavour(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'vim_connection_id': fields.StringField(nullable=True),
        'vnfd_virtual_compute_desc_id': fields.StringField(nullable=False),
        'vim_flavour_id': fields.StringField(nullable=False)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_flavour = super(VimComputeResourceFlavour,
                                cls).obj_from_primitive(primitive, context)
        else:
            obj_flavour = VimComputeResourceFlavour._from_dict(primitive)

        return obj_flavour

    @classmethod
    def _from_dict(cls, data_dict):
        vim_connection_id = data_dict.get('vim_connection_id')
        vnfd_virtual_compute_desc_id = data_dict.get(
            'vnfd_virtual_compute_desc_id')
        vim_flavour_id = data_dict.get('vim_flavour_id')

        obj = cls(vim_connection_id=vim_connection_id,
                  vnfd_virtual_compute_desc_id=vnfd_virtual_compute_desc_id,
                  vim_flavour_id=vim_flavour_id)
        return obj
示例#3
0
class GrantInfo(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'resource_definition_id': fields.StringField(nullable=False),
        'vim_connection_id': fields.StringField(nullable=True),
        'zone_id': fields.StringField(nullable=True)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_grant_info = super(GrantInfo,
                                   cls).obj_from_primitive(primitive, context)
        else:
            obj_grant_info = GrantInfo._from_dict(primitive)

        return obj_grant_info

    @classmethod
    def _from_dict(cls, data_dict):
        resource_definition_id = data_dict.get('resource_definition_id')
        vim_connection_id = data_dict.get('vim_connection_id')
        zone_id = data_dict.get('zone_id')

        obj = cls(resource_definition_id=resource_definition_id,
                  vim_connection_id=vim_connection_id,
                  zone_id=zone_id)
        return obj
class ResourceHandle(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'resource_id': fields.StringField(nullable=False, default=""),
        'vim_level_resource_type': fields.StringField(nullable=True,
                                                      default=None)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            resource_handle = super(ResourceHandle, cls).obj_from_primitive(
                primitive, context)
        else:
            resource_handle = ResourceHandle._from_dict(primitive)

        return resource_handle

    @classmethod
    def _from_dict(cls, data_dict):
        resource_id = data_dict.get('resource_id', "")
        vim_level_resource_type = data_dict.get('vim_level_resource_type')

        obj = cls(resource_id=resource_id,
                  vim_level_resource_type=vim_level_resource_type)

        return obj

    def to_dict(self):
        return {
            'resource_id': self.resource_id,
            'vim_level_resource_type': self.vim_level_resource_type
        }
示例#5
0
class ScaleVnfRequest(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'type': fields.StringField(nullable=False),
        'aspect_id': fields.StringField(nullable=False),
        'number_of_steps': fields.IntegerField(nullable=True, default=1),
        'additional_params': fields.DictOfStringsField(nullable=True,
                                                       default={}),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_scle_vnf_req = super(ScaleVnfRequest, cls).obj_from_primitive(
                primitive, context)
        else:
            obj_scle_vnf_req = ScaleVnfRequest._from_dict(primitive)

        return obj_scle_vnf_req

    @classmethod
    def _from_dict(cls, data_dict):
        type = data_dict.get('type')
        aspect_id = data_dict.get('aspect_id')
        number_of_steps = data_dict.get('number_of_steps')
        additional_params = data_dict.get('additional_params')

        obj = cls(type=type,
                  aspect_id=aspect_id,
                  number_of_steps=number_of_steps,
                  additional_params=additional_params)
        return obj
示例#6
0
class ResourceDefinition(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id':
        fields.StringField(nullable=False),
        'type':
        fields.StringField(nullable=False),
        'vdu_id':
        fields.StringField(nullable=True, default=None),
        'resource_template_id':
        fields.StringField(nullable=False),
        'resource':
        fields.ObjectField('ResourceHandle', nullable=True, default=None)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_grant_req = super(
                ResourceDefinition, cls).\
                obj_from_primitive(primitive, context)
        else:
            if 'resource' in primitive.keys():
                obj_data = ResourceHandle._from_dict(primitive.get('resource'))
                primitive.update({'resource': obj_data})
            obj_grant_req = ResourceDefinition._from_dict(primitive)

        return obj_grant_req

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        type = data_dict.get('type')
        vdu_id = data_dict.get('vdu_id')
        resource_template_id = data_dict.get('resource_template_id')
        resource = data_dict.get('resource')

        obj = cls(id=id,
                  type=type,
                  vdu_id=vdu_id,
                  resource_template_id=resource_template_id,
                  resource=resource)
        return obj

    def to_dict(self):
        data = {
            'id': self.id,
            'type': self.type,
            'resource_template_id': self.resource_template_id
        }
        if self.vdu_id:
            data.update({'vdu_id': self.vdu_id})
        if self.resource:
            data.update({'resource': self.resource.to_dict()})
        return data
示例#7
0
class ExtVirtualLinkData(base.TackerObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id':
        fields.StringField(nullable=False),
        'resource_id':
        fields.StringField(nullable=False),
        'ext_cps':
        fields.ListOfObjectsField('VnfExtCpData', nullable=True, default=[]),
        'ext_link_ports':
        fields.ListOfObjectsField('ExtLinkPortData', nullable=True,
                                  default=[]),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_ext_virt_link = super(ExtVirtualLinkData,
                                      cls).obj_from_primitive(
                                          primitive, context)
        else:
            if 'ext_cps' in primitive.keys():
                obj_data = [
                    VnfExtCpData.obj_from_primitive(ext_cp, context)
                    for ext_cp in primitive.get('ext_cps', [])
                ]
                primitive.update({'ext_cps': obj_data})

            if 'ext_link_ports' in primitive.keys():
                obj_data = [
                    ExtLinkPortData.obj_from_primitive(ext_link_port_data,
                                                       context)
                    for ext_link_port_data in primitive.get(
                        'ext_link_ports', [])
                ]
                primitive.update({'ext_link_ports': obj_data})

            obj_ext_virt_link = ExtVirtualLinkData._from_dict(primitive)

        return obj_ext_virt_link

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        resource_id = data_dict.get('resource_id')
        ext_cps = data_dict.get('ext_cps', [])
        ext_link_ports = data_dict.get('ext_link_ports', [])

        obj = cls(id=id,
                  resource_id=resource_id,
                  ext_cps=ext_cps,
                  ext_link_ports=ext_link_ports)
        return obj
示例#8
0
class VnfPackageVnfd(base.TackerObject, base.TackerObjectDictCompat,
                     base.TackerPersistentObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.UUIDField(nullable=False),
        'package_uuid': fields.UUIDField(nullable=False),
        'vnfd_id': fields.UUIDField(nullable=False),
        'vnf_provider': fields.StringField(nullable=False),
        'vnf_product_name': fields.StringField(nullable=False),
        'vnf_software_version': fields.StringField(nullable=False),
        'vnfd_version': fields.StringField(nullable=False),
    }

    @staticmethod
    def _from_db_object(context, vnf_package_vnfd, db_vnf_package_vnfd):

        for key in vnf_package_vnfd.fields:
            if db_vnf_package_vnfd[key]:
                setattr(vnf_package_vnfd, key, db_vnf_package_vnfd[key])

        vnf_package_vnfd._context = context
        vnf_package_vnfd.obj_reset_changes()

        return vnf_package_vnfd

    @base.remotable
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exceptions.ObjectActionError(action='create',
                                               reason=_('already created'))
        updates = self.obj_get_changes()

        if 'id' not in updates:
            updates['id'] = uuidutils.generate_uuid()
            self.id = updates['id']

        updates = self.obj_get_changes()
        db_vnf_package_vnfd = _vnf_package_vnfd_create(self._context, updates)
        self._from_db_object(self._context, self, db_vnf_package_vnfd)

    @classmethod
    def obj_from_db_obj(cls, context, db_obj):
        return cls._from_db_object(context, cls(), db_obj)

    @base.remotable_classmethod
    def get_by_id(cls, context, id):
        db_vnf_package_vnfd = _vnf_package_vnfd_get_by_id(context, id)
        return cls._from_db_object(context, cls(), db_vnf_package_vnfd)
示例#9
0
class VimConnectionInfo(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id':
        fields.StringField(nullable=False),
        'vim_id':
        fields.StringField(nullable=True, default=None),
        'vim_type':
        fields.StringField(nullable=False),
        'interface_info':
        fields.DictOfNullableStringsField(nullable=True, default={}),
        'access_info':
        fields.DictOfNullableStringsField(nullable=True, default={}),
    }

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        vim_id = data_dict.get('vim_id')
        vim_type = data_dict.get('vim_type')
        access_info = data_dict.get('access_info', {})
        interface_info = data_dict.get('interface_info', {})
        obj = cls(id=id,
                  vim_id=vim_id,
                  vim_type=vim_type,
                  interface_info=interface_info,
                  access_info=access_info)
        return obj

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            vim_connection_info = super(VimConnectionInfo,
                                        cls).obj_from_primitive(
                                            primitive, context)
        else:
            vim_connection_info = VimConnectionInfo._from_dict(primitive)

        return vim_connection_info

    def to_dict(self):
        return {
            'id': self.id,
            'vim_id': self.vim_id,
            'vim_type': self.vim_type,
            'interface_info': self.interface_info,
            'access_info': self.access_info
        }
示例#10
0
class AffectedVirtualStorage(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.StringField(nullable=False),
        'virtual_storage_desc_id': fields.StringField(nullable=False),
        'change_type': fields.StringField(nullable=False),
        'storage_resource': fields.ObjectField('ResourceHandle',
                                               nullable=False)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            affected_virtual_storage = super(AffectedVirtualStorage,
                                             cls).obj_from_primitive(
                                                 primitive, context)
        else:
            if 'storage_resource' in primitive.keys():
                obj_data = ResourceHandle._from_dict(
                    primitive.get('storage_resource'))
                primitive.update({'storage_resource': obj_data})
            affected_virtual_storage = AffectedVirtualStorage._from_dict(
                primitive)

        return affected_virtual_storage

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        virtual_storage_desc_id = data_dict.get('virtual_storage_desc_id')
        change_type = data_dict.get('change_type')
        storage_resource = ResourceHandle._from_dict(
            data_dict.get('storage_resource'))

        obj = cls(id=id,
                  virtual_storage_desc_id=virtual_storage_desc_id,
                  change_type=change_type,
                  storage_resource=storage_resource)

        return obj

    def to_dict(self):
        return {
            'id': self.id,
            'virtual_storage_desc_id': self.virtual_storage_desc_id,
            'change_type': self.change_type,
            'storage_resource': self.storage_resource.to_dict()
        }
示例#11
0
文件: vnf.py 项目: vutuong/tacker
class VNF(base.TackerObject, base.TackerObjectDictCompat,
          base.TackerPersistentObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.UUIDField(nullable=False),
        'tenant_id': fields.UUIDField(nullable=False),
        'name': fields.StringField(nullable=False),
        'vnfd_id': fields.UUIDField(nullable=False),
        'instance_id': fields.StringField(nullable=True),
        'mgmt_ip_address': fields.StringField(nullable=True),
        'status': fields.StringField(nullable=True),
        'description': fields.StringField(nullable=True),
        'placement_attr': fields.StringField(nullable=True),
        'vim_id': fields.StringField(nullable=False),
        'error_reason': fields.StringField(nullable=True),
        'vnf_attribute': fields.ObjectField('VNFAttribute', nullable=True),
        'vnfd': fields.ObjectField('VNFD', nullable=True),
    }

    @base.remotable
    def save(self):
        updates = self.obj_clone()
        _vnf_update(self._context, updates)

    @base.remotable_classmethod
    def vnf_index_list(cls, id, context):
        # get vnf_instance data
        expected_attrs = ["vnf_attribute", "vnfd"]
        db_vnf = _vnf_get(context, id, columns_to_join=expected_attrs)
        return db_vnf
示例#12
0
class VnfdAttribute(base.TackerObject, base.TackerObjectDictCompat,
                    base.TackerPersistentObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.UUIDField(nullable=False),
        'vnfd_id': fields.UUIDField(nullable=False),
        'key': fields.StringField(nullable=True),
        'value': fields.StringField(nullable=True),
    }

    @staticmethod
    def _from_db_object(context, vnfd_attribute, db_vnfd_attribute):

        for key in vnfd_attribute.fields:

            if db_vnfd_attribute.get(key):
                setattr(vnfd_attribute, key, db_vnfd_attribute[key])

        vnfd_attribute._context = context
        vnfd_attribute.obj_reset_changes()

        return vnfd_attribute

    @base.remotable
    def create(self):
        updates = self.obj_get_changes()
        db_vnfd_attribute = _vnfd_attribute_create(self._context, updates)
        self._from_db_object(self._context, self, db_vnfd_attribute)

    @classmethod
    def obj_from_db_obj(cls, context, db_obj):
        return cls._from_db_object(context, cls(), db_obj)

    @base.remotable
    def destroy(self, id):
        vnfd_attribute_id = _get_vnfd_id(self._context, id)
        if vnfd_attribute_id:
            _vnfd_attribute_delete(self._context, vnfd_attribute_id)

    @base.remotable
    def delete(self, id):
        _vnfd_attribute_delete(self._context, id)

    @base.remotable
    def check_vnfd_attribute(self, id):
        return _check_vnfd_attribute(self._context, id)
示例#13
0
class Vnfd(base.TackerObject, base.TackerObjectDictCompat,
           base.TackerPersistentObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.UUIDField(nullable=False),
        'tenant_id': fields.UUIDField(nullable=False),
        'name': fields.StringField(nullable=False),
        'description': fields.StringField(nullable=True),
        'mgmt_driver': fields.StringField(nullable=True),
        'deleted_at': fields.DateTimeField(nullable=True),
    }

    @staticmethod
    def _from_db_object(context, vnfd, db_vnfd):

        for key in vnfd.fields:
            if db_vnfd.get(key):
                setattr(vnfd, key, db_vnfd[key])

        vnfd._context = context
        vnfd.obj_reset_changes()

        return vnfd

    @base.remotable
    def create(self):
        updates = self.obj_get_changes()
        db_vnfd = _vnfd_create(self._context, updates)
        self._from_db_object(self._context, self, db_vnfd)

    @classmethod
    def obj_from_db_obj(cls, context, db_obj):
        return cls._from_db_object(context, cls(), db_obj)

    @base.remotable
    def destroy(self, id):
        _vnfd_destroy(self._context, id)

    @base.remotable
    def delete(self, id):
        _vnfd_delete(self._context, id)

    @base.remotable
    def check_vnfd(self, id):
        return _check_vnfd(self._context, id)
示例#14
0
 def setUp(self):
     super(TestString, self).setUp()
     self.field = fields.StringField()
     self.coerce_good_values = [('foo', 'foo'), (1, '1'), (True, 'True')]
     if six.PY2:
         self.coerce_good_values.append((int(1), '1'))
     self.coerce_bad_values = [None]
示例#15
0
class IpOverEthernetAddressData(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'mac_address': fields.StringField(nullable=True, default=None),
        'ip_addresses': fields.ListOfObjectsField('IpAddress', nullable=True,
            default=[]),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            ip_over_ethernet = super(
                IpOverEthernetAddressData, cls).obj_from_primitive(
                primitive, context)
        else:
            if 'ip_addresses' in primitive.keys():
                obj_data = [IpAddress._from_dict(
                    ip_address) for ip_address in primitive.get(
                        'ip_addresses', [])]
                primitive.update({'ip_addresses': obj_data})

            ip_over_ethernet = IpOverEthernetAddressData._from_dict(primitive)

        return ip_over_ethernet

    @classmethod
    def _from_dict(cls, data_dict):
        mac_address = data_dict.get('mac_address')
        ip_addresses = data_dict.get('ip_addresses', [])
        obj = cls(mac_address=mac_address, ip_addresses=ip_addresses)
        return obj
示例#16
0
class CpProtocolData(base.TackerObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'layer_protocol': fields.StringField(nullable=False),
        'ip_over_ethernet': fields.ObjectField(
            'IpOverEthernetAddressData', nullable=True, default=None),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_cp_protocal = super(CpProtocolData, cls).obj_from_primitive(
                primitive, context)
        else:
            if 'ip_over_ethernet' in primitive.keys():
                obj_data = IpOverEthernetAddressData.obj_from_primitive(
                    primitive.get('ip_over_ethernet', {}), context)
                primitive.update({'ip_over_ethernet': obj_data})
            obj_cp_protocal = CpProtocolData._from_dict(primitive)

        return obj_cp_protocal

    @classmethod
    def _from_dict(cls, data_dict):
        layer_protocol = data_dict.get('layer_protocol')
        ip_over_ethernet = data_dict.get('ip_over_ethernet')

        obj = cls(layer_protocol=layer_protocol,
                  ip_over_ethernet=ip_over_ethernet)
        return obj
示例#17
0
class Link(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {'href': fields.StringField(nullable=False)}

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_link = super(Link, cls).obj_from_primitive(primitive, context)
        else:
            obj_link = Link._from_dict(primitive)

        return obj_link

    @classmethod
    def _from_dict(cls, data_dict):
        href = data_dict.get('href')

        obj = cls(href=href)
        return obj

    def to_dict(self):
        return {'href': self.href}
示例#18
0
class IpAddress(base.TackerObject, base.TackerPersistentObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'type': fields.IpAddressTypeField(nullable=False),
        'subnet_id': fields.StringField(nullable=True, default=None),
        'is_dynamic': fields.BooleanField(nullable=True, default=False),
        'addresses': fields.ListOfStringsField(nullable=True, default=[]),
    }

    @classmethod
    def _from_dict(cls, data_dict):
        type = data_dict.get('type', fields.IpAddressType.IPV4)
        subnet_id = data_dict.get('subnet_id')
        is_dynamic = data_dict.get('is_dynamic', False)
        addresses = data_dict.get('addresses', [])

        obj = cls(type=type,
                  subnet_id=subnet_id,
                  is_dynamic=is_dynamic,
                  addresses=addresses)

        return obj

    def to_dict(self):
        return {
            'type': self.type,
            'subnet_id': self.subnet_id,
            'is_dynamic': self.is_dynamic,
            'addresses': self.addresses
        }
示例#19
0
class ScaleInfo(base.TackerObject, base.TackerObjectDictCompat,
                base.TackerPersistentObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'aspect_id': fields.StringField(nullable=False),
        'scale_level': fields.IntegerField(nullable=False),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_scale_status = super(ScaleInfo, cls).obj_from_primitive(
                primitive, context)
        else:
            obj_scale_status = ScaleInfo._from_dict(primitive)

        return obj_scale_status

    @classmethod
    def _from_dict(cls, data_dict):
        aspect_id = data_dict.get('aspect_id')
        scale_level = data_dict.get('scale_level')

        obj = cls(aspect_id=aspect_id, scale_level=scale_level)
        return obj

    def to_dict(self):

        return {'aspect_id': self.aspect_id, 'scale_level': self.scale_level}
示例#20
0
class VnfExtCpData(base.TackerObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'cpd_id': fields.StringField(nullable=False),
        'cp_config': fields.ListOfObjectsField(
            'VnfExtCpConfig', nullable=True, default=[]),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_vnf_ext_cp_data = super(VnfExtCpData, cls).obj_from_primitive(
                primitive, context)
        else:
            if 'cp_config' in primitive.keys():
                obj_data = [VnfExtCpConfig.obj_from_primitive(
                    vnf_ext_cp_conf, context)
                    for vnf_ext_cp_conf in primitive.get('cp_config', [])]
                primitive.update({'cp_config': obj_data})

            obj_vnf_ext_cp_data = VnfExtCpData._from_dict(primitive)

        return obj_vnf_ext_cp_data

    @classmethod
    def _from_dict(cls, data_dict):
        cpd_id = data_dict.get('cpd_id')
        cp_config = data_dict.get('cp_config', [])

        obj = cls(cpd_id=cpd_id, cp_config=cp_config)
        return obj
示例#21
0
class HealVnfAdditionalParams(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'parameter': fields.StringField(),
        'cause': fields.ListOfStringsField()
    }
示例#22
0
class VnfLinkPortInfo(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.StringField(nullable=False),
        'resource_handle': fields.ObjectField('ResourceHandle',
                                              nullable=False),
        'cp_instance_id': fields.StringField(nullable=True, default=None)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            vnf_port_link_info = super(VnfLinkPortInfo,
                                       cls).obj_from_primitive(
                                           primitive, context)
        else:
            if 'resource_handle' in primitive.keys():
                obj_data = ResourceHandle._from_dict(
                    primitive.get('resource_handle'))
                primitive.update({'resource_handle': obj_data})

            vnf_port_link_info = VnfLinkPortInfo._from_dict(primitive)

        return vnf_port_link_info

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        resource_handle = data_dict.get('resource_handle')
        cp_instance_id = data_dict.get('cp_instance_id')

        obj = cls(id=id,
                  resource_handle=resource_handle,
                  cp_instance_id=cp_instance_id)
        return obj

    def to_dict(self):
        return {
            'id': self.id,
            'resource_handle': self.resource_handle.to_dict(),
            'cp_instance_id': self.cp_instance_id
        }
class HealVnfRequest(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'cause': fields.StringField(),
        'additional_params':
        fields.ListOfObjectsField('HealVnfAdditionalParams')
    }
示例#24
0
class ExtManagedVirtualLinkData(base.TackerObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.StringField(nullable=False),
        'vnf_virtual_link_desc_id': fields.StringField(nullable=False),
        'resource_id': fields.StringField(nullable=False),
    }

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        vnf_virtual_link_desc_id = data_dict.get(
            'vnf_virtual_link_desc_id')
        resource_id = data_dict.get('resource_id')
        obj = cls(id=id, vnf_virtual_link_desc_id=vnf_virtual_link_desc_id,
                  resource_id=resource_id)
        return obj
示例#25
0
class VnfExtCpConfig(base.TackerObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'cp_instance_id':
        fields.StringField(nullable=True, default=None),
        'link_port_id':
        fields.StringField(nullable=True, default=None),
        'cp_protocol_data':
        fields.ListOfObjectsField('CpProtocolData', nullable=True, default=[]),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_ext_cp_config = super(VnfExtCpConfig, cls).obj_from_primitive(
                primitive, context)
        else:
            if 'cp_protocol_data' in primitive.keys():
                obj_data = [
                    CpProtocolData.obj_from_primitive(cp_protocol, context)
                    for cp_protocol in primitive.get('cp_protocol_data', [])
                ]
                primitive.update({'cp_protocol_data': obj_data})

            obj_ext_cp_config = VnfExtCpConfig._from_dict(primitive)

        return obj_ext_cp_config

    @classmethod
    def _from_dict(cls, data_dict):
        cp_instance_id = data_dict.get('cp_instance_id')
        link_port_id = data_dict.get('link_port_id')
        cp_protocol_data = data_dict.get('cp_protocol_data', [])

        obj = cls(cp_instance_id=cp_instance_id,
                  link_port_id=link_port_id,
                  cp_protocol_data=cp_protocol_data)
        return obj
示例#26
0
class HealVnfRequest(base.TackerObject):

    # Version 1.0: Initial version
    # Version 1.1: Added vnf_instance_id
    # Version 1.2: Added stack_id for nested heat-template
    VERSION = '1.2'

    fields = {
        'vnfc_instance_id': fields.ListOfStringsField(nullable=True,
                                                      default=[]),
        'stack_id': fields.StringField(nullable=True, default=''),
        'cause': fields.StringField(nullable=True, default=None),
        'additional_params': fields.ListOfObjectsField(
            'HealVnfAdditionalParams', default=[])
    }

    def obj_make_compatible(self, primitive, target_version):
        super(HealVnfRequest, self).obj_make_compatible(primitive,
                                                        target_version)
        target_version = versionutils.convert_version_to_tuple(target_version)
        if target_version < (1, 1) and 'vnfc_instance_id' in primitive:
            del primitive['vnfc_instance_id']
示例#27
0
class ConstraintResourceRef(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id_type': fields.StringField(nullable=False),
        'resource_id': fields.StringField(nullable=False),
        'vim_connection_id': fields.StringField(nullable=True, default=None),
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_placement_constraint = super(ConstraintResourceRef,
                                             cls).obj_from_primitive(
                                                 primitive, context)
        else:
            obj_placement_constraint = ConstraintResourceRef._from_dict(
                primitive)

        return obj_placement_constraint

    @classmethod
    def _from_dict(cls, data_dict):
        id_type = data_dict.get('id_type')
        resource_id = data_dict.get('resource_id')
        vim_connection_id = data_dict.get('vim_connection_id')

        obj = cls(id_type=id_type,
                  resource_id=resource_id,
                  vim_connection_id=vim_connection_id)
        return obj

    def to_dict(self):
        data = {'id_type': self.id_type, 'resource_id': self.resource_id}
        if self.vim_connection_id:
            data.update({'vim_connection_id': self.vim_connection_id})
        return data
示例#28
0
class ProblemDetails(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'title': fields.StringField(nullable=True, default=''),
        'status': fields.IntegerField(nullable=False),
        'detail': fields.StringField(nullable=False)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            problem_detail = super(ProblemDetails,
                                   cls).obj_from_primitive(primitive, context)
        else:
            p_dict = jsonutils.loads(primitive)
            problem_detail = ProblemDetails._from_dict(p_dict)

        return problem_detail

    @classmethod
    def _from_dict(cls, data_dict):
        title = data_dict.get('title')
        status = data_dict.get('status')
        detail = data_dict.get('detail')

        obj = cls(title=title, status=status, detail=detail)

        return obj

    def to_dict(self):
        return {
            'title': self.title,
            'status': self.status,
            'detail': self.detail
        }
示例#29
0
class VnfcInfo(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id': fields.StringField(nullable=False),
        'vdu_id': fields.StringField(nullable=False),
        'vnfc_state': fields.StringField(nullable=False)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            obj_vnfc_info = super(VnfcInfo,
                                  cls).obj_from_primitive(primitive, context)
        else:
            obj_vnfc_info = VnfcInfo._from_dict(primitive)

        return obj_vnfc_info

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        vdu_id = data_dict.get('vdu_id')
        vnfc_state = data_dict.get('vnfc_state')

        obj = cls(id=id, vdu_id=vdu_id, vnfc_state=vnfc_state)

        return obj

    def to_dict(self):
        return {
            'id': self.id,
            'vdu_id': self.vdu_id,
            'vnfc_state': self.vnfc_state
        }
示例#30
0
class IpAddress(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'type': fields.IpAddressTypeField(nullable=False),
        'subnet_id': fields.StringField(nullable=True, default=None),
        'fixed_addresses': fields.ListOfStringsField(nullable=True,
            default=[])
    }

    @classmethod
    def _from_dict(cls, data_dict):
        type = data_dict.get('type')
        subnet_id = data_dict.get('subnet_id')
        fixed_addresses = data_dict.get('fixed_addresses', [])

        obj = cls(type=type, subnet_id=subnet_id,
                fixed_addresses=fixed_addresses)

        return obj