Example #1
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
        }
Example #2
0
class HealVnfAdditionalParams(base.TackerObject):

    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'parameter': fields.StringField(),
        'cause': fields.ListOfStringsField()
    }
Example #3
0
class HealVnfRequest(base.TackerObject):

    # Version 1.0: Initial version
    # Version 1.1: Added vnf_instance_id
    VERSION = '1.1'

    fields = {
        'vnfc_instance_id':
        fields.ListOfStringsField(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']
Example #4
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
Example #5
0
 def setUp(self):
     super(TestListOfStrings, self).setUp()
     self.field = fields.ListOfStringsField()
Example #6
0
class VnfInfoModifications(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'vnf_instance_name':
        fields.StringField(nullable=True),
        'vnf_instance_description':
        fields.StringField(nullable=True),
        'vim_connection_info':
        fields.ListOfObjectsField('VimConnectionInfo',
                                  nullable=True,
                                  default=[]),
        'vim_connection_info_delete_ids':
        fields.ListOfStringsField(nullable=True, default=[]),
        'vnf_pkg_id':
        fields.StringField(nullable=True, default=None),
        'vnfd_id':
        fields.StringField(nullable=True),
        'vnf_provider':
        fields.StringField(nullable=True),
        'vnf_product_name':
        fields.StringField(nullable=True),
        'vnf_software_version':
        fields.StringField(nullable=True),
        'vnfd_version':
        fields.StringField(nullable=True)
    }

    @classmethod
    def obj_from_primitive(cls, primitive, context):
        if 'tacker_object.name' in primitive:
            vnf_info_modifications = super(VnfInfoModifications,
                                           cls).obj_from_primitive(
                                               primitive, context)
        else:
            if 'vim_connection_info' in primitive.keys():
                obj_data = [
                    objects.VimConnectionInfo._from_dict(vim_conn)
                    for vim_conn in primitive.get('vim_connection_info', [])
                ]
                primitive.update({'vim_connection_info': obj_data})
            vnf_info_modifications = VnfInfoModifications._from_dict(primitive)

        return vnf_info_modifications

    @classmethod
    def _from_dict(cls, data_dict):
        vnf_instance_name = data_dict.get('vnf_instance_name')
        vnf_instance_description = data_dict.get('vnf_instance_description')
        vim_connection_info = data_dict.get('vim_connection_info', [])
        vim_connection_info_delete_ids = data_dict.get(
            'vim_connection_info_delete_ids')
        vnf_pkg_id = data_dict.get('vnf_pkg_id')
        vnfd_id = data_dict.get('vnfd_id')
        vnf_provider = data_dict.get('vnf_provider')
        vnf_product_name = data_dict.get('vnf_product_name')
        vnf_software_version = data_dict.get('vnf_software_version')
        vnfd_version = data_dict.get('vnfd_version')

        obj = cls(
            vnf_instance_name=vnf_instance_name,
            vnf_instance_description=vnf_instance_description,
            vim_connection_info=vim_connection_info,
            vim_connection_info_delete_ids=vim_connection_info_delete_ids,
            vnf_pkg_id=vnf_pkg_id,
            vnfd_id=vnfd_id,
            vnf_provider=vnf_provider,
            vnf_product_name=vnf_product_name,
            vnf_software_version=vnf_software_version,
            vnfd_version=vnfd_version)

        return obj

    def to_dict(self):
        return {
            'vnf_instance_name': self.vnf_instance_name,
            'vnf_instance_description': self.vnf_instance_description,
            'vim_connection_info': self.vim_connection_info,
            'vim_connection_info_delete_ids':
            self.vim_connection_info_delete_ids,
            'vnf_pkg_id': self.vnf_pkg_id,
            'vnfd_id': self.vnfd_id,
            'vnf_provider': self.vnf_provider,
            'vnf_product_name': self.vnf_product_name,
            'vnf_software_version': self.vnf_software_version,
            'vnfd_version': self.vnfd_version
        }
Example #7
0
class AffectedVnfc(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id':
        fields.StringField(nullable=False),
        'vdu_id':
        fields.StringField(nullable=False),
        'change_type':
        fields.StringField(nullable=False),
        'compute_resource':
        fields.ObjectField('ResourceHandle', nullable=False),
        'affected_vnfc_cp_ids':
        fields.ListOfStringsField(nullable=True, default=[]),
        'added_storage_resource_ids':
        fields.ListOfStringsField(nullable=True, default=[]),
        'removed_storage_resource_ids':
        fields.ListOfStringsField(nullable=True, default=[])
    }

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

        return affected_vnfc

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        vdu_id = data_dict.get('vdu_id')
        change_type = data_dict.get('change_type')
        compute_resource = ResourceHandle._from_dict(
            data_dict.get('compute_resource'))
        affected_vnfc_cp_ids = data_dict.get('affected_vnfc_cp_ids')
        added_storage_resource_ids = data_dict.get(
            'added_storage_resource_ids')
        removed_storage_resource_ids = data_dict.get(
            'removed_storage_resource_ids')

        obj = cls(id=id,
                  vdu_id=vdu_id,
                  change_type=change_type,
                  compute_resource=compute_resource,
                  affected_vnfc_cp_ids=affected_vnfc_cp_ids,
                  added_storage_resource_ids=added_storage_resource_ids,
                  removed_storage_resource_ids=removed_storage_resource_ids)

        return obj

    def to_dict(self):
        return {
            'id': self.id,
            'vdu_id': self.vdu_id,
            'change_type': self.change_type,
            'compute_resource': self.compute_resource.to_dict(),
            'affected_vnfc_cp_ids': self.affected_vnfc_cp_ids,
            'added_storage_resource_ids': self.added_storage_resource_ids,
            'removed_storage_resource_ids': self.removed_storage_resource_ids
        }
Example #8
0
class VnfcResourceInfo(base.TackerObject, base.TackerPersistentObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'id':
        fields.StringField(nullable=False),
        'vdu_id':
        fields.StringField(nullable=False),
        'compute_resource':
        fields.ObjectField('ResourceHandle', nullable=False),
        'storage_resource_ids':
        fields.ListOfStringsField(nullable=True, default=[]),
        'vnfc_cp_info':
        fields.ListOfObjectsField('VnfcCpInfo', nullable=True, default=[]),
        'metadata':
        fields.DictOfStringsField(nullable=True, default={})
    }

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

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

            vnfc_resource_info = VnfcResourceInfo._from_dict(primitive)

        return vnfc_resource_info

    @classmethod
    def _from_dict(cls, data_dict):
        id = data_dict.get('id')
        vdu_id = data_dict.get('vdu_id')
        compute_resource = data_dict.get('compute_resource')
        storage_resource_ids = data_dict.get('storage_resource_ids', [])
        vnfc_cp_info = data_dict.get('vnfc_cp_info', [])
        metadata = data_dict.get('metadata', {})

        obj = cls(id=id,
                  vdu_id=vdu_id,
                  compute_resource=compute_resource,
                  storage_resource_ids=storage_resource_ids,
                  vnfc_cp_info=vnfc_cp_info,
                  metadata=metadata)

        return obj

    def to_dict(self):
        data = {
            'id': self.id,
            'vdu_id': self.vdu_id,
            'compute_resource': self.compute_resource.to_dict(),
            'storage_resource_ids': self.storage_resource_ids
        }

        if self.vnfc_cp_info:
            vnfc_cp_info_list = []
            for vnfc_cp_info in self.vnfc_cp_info:
                vnfc_cp_info_list.append(vnfc_cp_info.to_dict())

            data.update({'vnfc_cp_info': vnfc_cp_info_list})

        return data