Beispiel #1
0
class IpamSubnet(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    db_model = db_models.IpamSubnet

    fields = {
        'id': common_types.UUIDField(),
        'neutron_subnet_id': common_types.UUIDField(nullable=True),
        'allocation_pools': obj_fields.ListOfObjectsField('IpamAllocationPool')
    }

    synthetic_fields = ['allocation_pools']
Beispiel #2
0
class LBaaSServiceSpec(k_obj.KuryrK8sObjectBase):
    VERSION = '1.0'

    fields = {
        'ip': obj_fields.IPAddressField(nullable=True, default=None),
        'ports': obj_fields.ListOfObjectsField(LBaaSPortSpec.__name__,
                                               default=[]),
        'project_id': obj_fields.StringField(nullable=True, default=None),
        'subnet_id': obj_fields.UUIDField(nullable=True, default=None),
        'security_groups_ids': k_fields.ListOfUUIDField(default=[]),
        'type': obj_fields.StringField(nullable=True, default=None),
        'lb_ip': obj_fields.IPAddressField(nullable=True, default=None),
    }
Beispiel #3
0
class MigrationList(base.ObjectListBase, base.GutsObject):
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('Migration'),
    }
    child_versions = {'1.0': '1.0'}

    @base.remotable_classmethod
    def get_all(cls, context, filters=None):
        migrations = db.migration_get_all(context, filters)
        return base.obj_make_list(context, cls(context), objects.Migration,
                                  migrations)
class ResourceList(ovo_base.ObjectListBase, base.OrchestratorObject):
    """DC Orchestrator resource list object."""
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('Resource'),
    }

    @classmethod
    def get_all(cls, context, resource_type=None):
        resources = db_api.resource_get_all(context, resource_type)
        return ovo_base.obj_make_list(context, cls(context), Resource,
                                      resources)
Beispiel #5
0
class SubcloudList(ovo_base.ObjectListBase, base.OrchestratorObject):
    """DC Orchestrator subcloud list object."""
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('Subcloud'),
    }

    @classmethod
    def get_all(cls, context):
        subclouds = db_api.subcloud_get_all(context)
        return ovo_base.obj_make_list(
            context, cls(context), Subcloud, subclouds)
Beispiel #6
0
class FakeNeutronObjectSyntheticField(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    db_model = FakeModel

    fields = {
        'id': obj_fields.UUIDField(),
        'obj_field': obj_fields.ListOfObjectsField(
            'FakeNeutronObjectMultipleForeignKeys')
    }

    synthetic_fields = ['obj_field']
Beispiel #7
0
class ConsistencyGroupList(base.ObjectListBase, base.CinderObject):
    # Version 1.0: Initial version
    # Version 1.1: Add pagination support to consistency group
    VERSION = '1.1'

    fields = {'objects': fields.ListOfObjectsField('ConsistencyGroup')}
    child_version = {
        '1.0': '1.0',
        '1.1': '1.1',
    }

    @base.remotable_classmethod
    def get_all(cls,
                context,
                filters=None,
                marker=None,
                limit=None,
                offset=None,
                sort_keys=None,
                sort_dirs=None):
        consistencygroups = db.consistencygroup_get_all(context,
                                                        filters=filters,
                                                        marker=marker,
                                                        limit=limit,
                                                        offset=offset,
                                                        sort_keys=sort_keys,
                                                        sort_dirs=sort_dirs)
        return base.obj_make_list(context, cls(context),
                                  objects.ConsistencyGroup, consistencygroups)

    @base.remotable_classmethod
    def get_all_by_project(cls,
                           context,
                           project_id,
                           filters=None,
                           marker=None,
                           limit=None,
                           offset=None,
                           sort_keys=None,
                           sort_dirs=None):
        consistencygroups = db.consistencygroup_get_all_by_project(
            context,
            project_id,
            filters=filters,
            marker=marker,
            limit=limit,
            offset=offset,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs)
        return base.obj_make_list(context, cls(context),
                                  objects.ConsistencyGroup, consistencygroups)
Beispiel #8
0
class VolumeTypeList(base.ObjectListBase, base.CinderObject):
    # Version 1.0: Initial version
    # Version 1.1: Add pagination support to volume type
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('VolumeType'),
    }

    @classmethod
    def get_all(cls,
                context,
                inactive=0,
                filters=None,
                marker=None,
                limit=None,
                sort_keys=None,
                sort_dirs=None,
                offset=None):
        types = volume_types.get_all_types(context,
                                           inactive,
                                           filters,
                                           marker=marker,
                                           limit=limit,
                                           sort_keys=sort_keys,
                                           sort_dirs=sort_dirs,
                                           offset=offset)
        expected_attrs = VolumeType._get_expected_attrs(context)
        return base.obj_make_list(context,
                                  cls(context),
                                  objects.VolumeType,
                                  types.values(),
                                  expected_attrs=expected_attrs)

    @classmethod
    def get_all_types_for_qos(cls, context, qos_id):
        types = db.qos_specs_associations_get(context, qos_id)
        return base.obj_make_list(context, cls(context), objects.VolumeType,
                                  types)

    @classmethod
    def get_all_by_group(cls, context, group_id):
        # Generic volume group
        types = volume_types.get_all_types_by_group(context.elevated(),
                                                    group_id)
        expected_attrs = VolumeType._get_expected_attrs(context)
        return base.obj_make_list(context,
                                  cls(context),
                                  objects.VolumeType,
                                  types,
                                  expected_attrs=expected_attrs)
Beispiel #9
0
class BGPVPNPortAssociation(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    new_facade = True
    db_model = bgpvpn_db.BGPVPNPortAssociation

    fields = {
        'id': common_types.UUIDField(),
        'project_id': obj_fields.StringField(),
        'bgpvpn_id': obj_fields.StringField(),
        'bgpvpn': obj_fields.ObjectField('BGPVPN'),
        'port_id': obj_fields.StringField(),
        'subnets': common_types.ListOfDictOfMiscValuesField(nullable=True),
        'routes': obj_fields.ListOfObjectsField('BGPVPNPortAssociationRoute'),
        'advertise_fixed_ips': obj_fields.BooleanField(default=True)
    }

    fields_no_update = ['id', 'project_id', 'bgpvpn_id', 'port_id']

    synthetic_fields = ['bgpvpn', 'subnets', 'routes']

    def __init__(self, context=None, **kwargs):
        super(BGPVPNPortAssociation, self).__init__(context, **kwargs)

    def create(self):
        with self.db_context_writer(self.obj_context):
            super(BGPVPNPortAssociation, self).create()
            self.obj_load_attr('subnets')

    def obj_load_attr(self, attrname):
        if attrname == 'subnets':
            self._load_subnets()
        else:
            super(BGPVPNPortAssociation, self).obj_load_attr(attrname)

    def _load_subnets(self, db_obj=None):
        # pylint: disable=no-member
        port = Port.get_object(self.obj_context, id=self.port_id)
        subnets_info = _get_subnets_info(self.obj_context, port.network_id)
        setattr(self, 'subnets', subnets_info)
        self.obj_reset_changes(['subnets'])

    def from_db_object(self, obj):
        super(BGPVPNPortAssociation, self).from_db_object(obj)
        self._load_subnets(obj)

    def all_subnets(self, network_id):
        # pylint: disable=no-member
        return self.subnets
Beispiel #10
0
class SubcloudResourceList(ovo_base.ObjectListBase, base.OrchestratorObject):
    """DC Orchestrator subcloud list object."""
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('SubcloudResource'),
    }

    @classmethod
    def get_by_resource_id(cls, context, resource_id):
        subcloud_resources = db_api.subcloud_resources_get_by_resource(
            context, resource_id)
        return ovo_base.obj_make_list(context, cls(context), SubcloudResource,
                                      subcloud_resources)
Beispiel #11
0
class Capsule(ContainerBase):
    # Version 1.0: Initial version
    VERSION = '1.0'

    container_type = consts.TYPE_CAPSULE

    fields = {
        'containers': fields.ListOfObjectsField('CapsuleContainer',
                                                nullable=True),
        'init_containers': fields.ListOfObjectsField('CapsuleInitContainer',
                                                     nullable=True),
    }

    def as_dict(self):
        capsule_dict = super(Capsule, self).as_dict()
        capsule_dict['containers'] = [c.as_dict() for c in self.containers]
        capsule_dict['init_containers'] = [c.as_dict()
                                           for c in self.init_containers]
        return capsule_dict

    def obj_load_attr(self, attrname):
        if attrname == 'containers':
            self._load_capsule_containers()
            self.obj_reset_changes([attrname])
        elif attrname == 'init_containers':
            self._load_capsule_init_containers()
            self.obj_reset_changes([attrname])
        else:
            super(Capsule, self).obj_load_attr(attrname)

    def _load_capsule_containers(self):
        self.containers = CapsuleContainer.list_by_capsule_id(
            self._context, self.id)

    def _load_capsule_init_containers(self):
        self.init_containers = CapsuleInitContainer.list_by_capsule_id(
            self._context, self.id)
Beispiel #12
0
class BackupList(base.ObjectListBase, base.CinderObject):
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('Backup'),
    }
    child_versions = {'1.0': '1.0'}

    @base.remotable_classmethod
    def get_all(cls,
                context,
                filters=None,
                marker=None,
                limit=None,
                offset=None,
                sort_keys=None,
                sort_dirs=None):
        backups = db.backup_get_all(context, filters, marker, limit, offset,
                                    sort_keys, sort_dirs)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups)

    @base.remotable_classmethod
    def get_all_by_host(cls, context, host):
        backups = db.backup_get_all_by_host(context, host)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups)

    @base.remotable_classmethod
    def get_all_by_project(cls,
                           context,
                           project_id,
                           filters=None,
                           marker=None,
                           limit=None,
                           offset=None,
                           sort_keys=None,
                           sort_dirs=None):
        backups = db.backup_get_all_by_project(context, project_id, filters,
                                               marker, limit, offset,
                                               sort_keys, sort_dirs)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups)

    @base.remotable_classmethod
    def get_all_by_volume(cls, context, volume_id, filters=None):
        backups = db.backup_get_all_by_volume(context, volume_id, filters)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups)
Beispiel #13
0
class BackupList(base.ObjectListBase, base.CinderObject):
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('Backup'),
    }

    @classmethod
    def get_all(cls, context, filters=None, marker=None, limit=None,
                offset=None, sort_keys=None, sort_dirs=None):
        backups = db.backup_get_all(context, filters, marker, limit, offset,
                                    sort_keys, sort_dirs)
        expected_attrs = Backup._get_expected_attrs(context)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups, expected_attrs=expected_attrs)

    @classmethod
    def get_all_by_host(cls, context, host):
        backups = db.backup_get_all_by_host(context, host)
        expected_attrs = Backup._get_expected_attrs(context)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups, expected_attrs=expected_attrs)

    @classmethod
    def get_all_by_project(cls, context, project_id, filters=None,
                           marker=None, limit=None, offset=None,
                           sort_keys=None, sort_dirs=None):
        backups = db.backup_get_all_by_project(context, project_id, filters,
                                               marker, limit, offset,
                                               sort_keys, sort_dirs)
        expected_attrs = Backup._get_expected_attrs(context)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups, expected_attrs=expected_attrs)

    @classmethod
    def get_all_by_volume(
            cls, context, volume_id, vol_project_id, filters=None):
        backups = db.backup_get_all_by_volume(
            context, volume_id, vol_project_id, filters)
        expected_attrs = Backup._get_expected_attrs(context)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups, expected_attrs=expected_attrs)

    @classmethod
    def get_all_active_by_window(cls, context, begin, end):
        backups = db.backup_get_all_active_by_window(context, begin, end)
        expected_attrs = Backup._get_expected_attrs(context)
        return base.obj_make_list(context, cls(context), objects.Backup,
                                  backups, expected_attrs=expected_attrs)
Beispiel #14
0
class QosRuleType(base.NeutronObject):
    # Version 1.0: Initial version
    # Version 1.1: Added QosDscpMarkingRule
    # Version 1.2: Added QosMinimumBandwidthRule
    # Version 1.3: Added drivers field
    VERSION = '1.3'

    fields = {
        'type': RuleTypeField(),
        'drivers': obj_fields.ListOfObjectsField(
            'QosRuleTypeDriver', nullable=True)
    }

    synthetic_fields = ['drivers']

    # we don't receive context because we don't need db access at all
    @classmethod
    def get_object(cls, rule_type_name, **kwargs):
        plugin = directory.get_plugin(alias=constants.QOS)
        drivers = plugin.supported_rule_type_details(rule_type_name)
        drivers_obj = [QosRuleTypeDriver(
            name=driver['name'],
            supported_parameters=driver['supported_parameters'])
            for driver in drivers]

        return cls(type=rule_type_name, drivers=drivers_obj)

    # we don't receive context because we don't need db access at all
    @classmethod
    def get_objects(cls, validate_filters=True, **kwargs):
        if validate_filters:
            cls.validate_filters(**kwargs)

        rule_types = (
            directory.get_plugin(alias=constants.QOS).supported_rule_types)

        # TODO(ihrachys): apply filters to returned result
        return [cls(type=type_) for type_ in rule_types]

    # we don't receive context because we don't need db access at all
    @classmethod
    def get_values(cls, field, **kwargs):
        return [getattr(obj, field) for obj in cls.get_objects(**kwargs)]

    def obj_make_compatible(self, primitive, target_version):
        _target_version = versionutils.convert_version_to_tuple(target_version)
        if _target_version < (1, 3):
            raise exception.IncompatibleObjectVersion(
                objver=target_version, objtype=self.__class__.__name__)
Beispiel #15
0
class QosRuleType(base.NeutronObject):
    # Version 1.0: Initial version
    # Version 1.1: Added QosDscpMarkingRule
    # Version 1.2: Added QosMinimumBandwidthRule
    # Version 1.3: Added drivers field
    # Version 1.4: Added QosPacketRateLimitRule
    # Version 1.5: Added QosMinimumPacketRateRule
    VERSION = '1.5'

    fields = {
        'type':
        RuleTypeField(),
        'drivers':
        obj_fields.ListOfObjectsField('QosRuleTypeDriver', nullable=True)
    }

    synthetic_fields = ['drivers']

    # we don't receive context because we don't need db access at all
    @classmethod
    def get_object(cls, rule_type_name, **kwargs):
        plugin = directory.get_plugin(alias=constants.QOS)
        drivers = plugin.supported_rule_type_details(rule_type_name)
        drivers_obj = [
            QosRuleTypeDriver(
                name=driver['name'],
                supported_parameters=driver['supported_parameters'])
            for driver in drivers
        ]

        return cls(type=rule_type_name, drivers=drivers_obj)

    # we don't receive context because we don't need db access at all
    @classmethod
    def get_objects(cls, validate_filters=True, **kwargs):
        all_supported = kwargs.pop('all_supported', None)
        all_rules = kwargs.pop('all_rules', None)
        if validate_filters:
            cls.validate_filters(**kwargs)

        rule_types = directory.get_plugin(
            alias=constants.QOS).supported_rule_types(
                all_supported=all_supported, all_rules=all_rules)
        return [cls(type=type_) for type_ in rule_types]

    # we don't receive context because we don't need db access at all
    @classmethod
    def get_values(cls, field, **kwargs):
        return [getattr(obj, field) for obj in cls.get_objects(**kwargs)]
Beispiel #16
0
class ConsistencyGroupList(base.ObjectListBase, base.CinderObject):
    # Version 1.0: Initial version
    # Version 1.1: Add pagination support to consistency group
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('ConsistencyGroup')
    }

    @staticmethod
    def include_in_cluster(context, cluster, partial_rename=True, **filters):
        """Include all consistency groups matching the filters into a cluster.

        When partial_rename is set we will not set the cluster_name with
        cluster parameter value directly, we'll replace provided cluster_name
        or host filter value with cluster instead.

        This is useful when we want to replace just the cluster name but leave
        the backend and pool information as it is.  If we are using
        cluster_name to filter, we'll use that same DB field to replace the
        cluster value and leave the rest as it is.  Likewise if we use the host
        to filter.

        Returns the number of consistency groups that have been changed.
        """
        return db.consistencygroup_include_in_cluster(context, cluster,
                                                      partial_rename,
                                                      **filters)

    @classmethod
    def get_all(cls, context, filters=None, marker=None, limit=None,
                offset=None, sort_keys=None, sort_dirs=None):
        consistencygroups = db.consistencygroup_get_all(
            context, filters=filters, marker=marker, limit=limit,
            offset=offset, sort_keys=sort_keys, sort_dirs=sort_dirs)
        return base.obj_make_list(context, cls(context),
                                  objects.ConsistencyGroup,
                                  consistencygroups)

    @classmethod
    def get_all_by_project(cls, context, project_id, filters=None, marker=None,
                           limit=None, offset=None, sort_keys=None,
                           sort_dirs=None):
        consistencygroups = db.consistencygroup_get_all_by_project(
            context, project_id, filters=filters, marker=marker, limit=limit,
            offset=offset, sort_keys=sort_keys, sort_dirs=sort_dirs)
        return base.obj_make_list(context, cls(context),
                                  objects.ConsistencyGroup,
                                  consistencygroups)
Beispiel #17
0
class FakeNeutronObjectCompositePrimaryKeyWithId(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    db_model = FakeModel

    primary_keys = ['id', 'field1']

    fields = {
        'id': obj_fields.UUIDField(),
        'field1': obj_fields.StringField(),
        'obj_field': obj_fields.ListOfObjectsField('FakeSmallNeutronObject')
    }

    synthetic_fields = ['obj_field']
Beispiel #18
0
class QualityOfServiceSpecsList(base.ObjectListBase, base.CinderObject):
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('QualityOfServiceSpecs'),
    }
    child_versions = {
        '1.0': '1.0',
    }

    @classmethod
    def get_all(cls, context, *args, **kwargs):
        specs = db.qos_specs_get_all(context, *args, **kwargs)
        return base.obj_make_list(context, cls(context),
                                  objects.QualityOfServiceSpecs, specs)
Beispiel #19
0
class Trunk(base.NeutronDbObject):
    # Version 1.0: Initial version
    # Version 1.1: Changed tenant_id to project_id
    VERSION = '1.1'

    db_model = models.Trunk

    fields = {
        'admin_state_up': obj_fields.BooleanField(),
        'id': common_types.UUIDField(),
        'project_id': obj_fields.StringField(),
        'name': obj_fields.StringField(),
        'port_id': common_types.UUIDField(),
        'status': obj_fields.StringField(),
        'sub_ports': obj_fields.ListOfObjectsField(SubPort.__name__),
    }

    fields_no_update = ['project_id', 'port_id']

    synthetic_fields = ['sub_ports']

    def create(self):
        with db_api.autonested_transaction(self.obj_context.session):
            sub_ports = []
            if self.obj_attr_is_set('sub_ports'):
                sub_ports = self.sub_ports

            try:
                super(Trunk, self).create()
            except o_db_exc.DBReferenceError:
                raise n_exc.PortNotFound(port_id=self.port_id)

            if sub_ports:
                for sub_port in sub_ports:
                    sub_port.trunk_id = self.id
                    sub_port.create()
                    self.sub_ports.append(sub_port)
                self.obj_reset_changes(['sub_ports'])

    def update(self, **kwargs):
        self.update_fields(kwargs)
        super(Trunk, self).update()

    def obj_make_compatible(self, primitive, target_version):
        _target_version = versionutils.convert_version_to_tuple(target_version)

        if _target_version < (1, 1):
            primitive['tenant_id'] = primitive.pop('project_id')
Beispiel #20
0
class FakeParent(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    db_model = ObjectFieldsModel

    primary_keys = ['field1', 'field2']

    fields = {
        'id': obj_fields.UUIDField(),
        'children': obj_fields.ListOfObjectsField(
            'FakeSmallNeutronObjectWithMultipleParents',
            nullable=True)
    }

    synthetic_fields = ['children']
Beispiel #21
0
class PromenadeConfigList(base.DrydockObjectListBase, base.DrydockObject):

    VERSION = '1.0'

    fields = {
        'objects': ovo_fields.ListOfObjectsField('PromenadeConfig'),
    }

    def select_for_target(self, target):
        """
        Select all promenade configs destined for the target

        :param string target: Target to search documents for
        """

        return [x for x in self.objects if x.target == target]
class OrchRequestList(ovo_base.ObjectListBase, base.OrchestratorObject):
    """DC Orchestrator orchestration request list object."""
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('OrchRequest'),
    }

    @classmethod
    def get_by_attrs(cls, context, endpoint_type, resource_type=None,
                     target_region_name=None, states=None):
        orch_reqs = db_api.orch_request_get_by_attrs(
            context, endpoint_type, resource_type=resource_type,
            target_region_name=target_region_name, states=states)
        return ovo_base.obj_make_list(
            context, cls(context), OrchRequest, orch_reqs)
Beispiel #23
0
class Trunk(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    db_model = models.Trunk

    fields = {
        'id': obj_fields.UUIDField(),
        'tenant_id': obj_fields.UUIDField(),
        'port_id': obj_fields.UUIDField(),
        'sub_ports': obj_fields.ListOfObjectsField(SubPort.__name__),
    }

    fields_no_update = ['tenant_id', 'port_id']

    synthetic_fields = ['sub_ports']
Beispiel #24
0
class HostVolumeGroupList(base.DrydockObjectListBase, base.DrydockObject):

    VERSION = '1.0'

    fields = {'objects': obj_fields.ListOfObjectsField('HostVolumeGroup')}

    def add_device_to_vg(self, vg_name, device_name):
        for vg in self.objects:
            if vg.name == vg_name:
                vg.add_pv(device_name)
                return

        vg = objects.HostVolumeGroup(name=vg_name)
        vg.add_pv(device_name)
        self.objects.append(vg)
        return
Beispiel #25
0
class MeteringLabel(base.NeutronDbObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    db_model = metering_models.MeteringLabel
    synthetic_fields = ['rules']

    fields = {
        'id': common_types.UUIDField(),
        'project_id': obj_fields.StringField(nullable=True),
        'name': obj_fields.StringField(),
        'description': obj_fields.StringField(),
        'rules': obj_fields.ListOfObjectsField('MeteringLabelRule',
                                               nullable=True),
        'shared': obj_fields.BooleanField(default=False),
    }
Beispiel #26
0
class OperationLogList(base.ObjectListBase, base.SmaugObject):
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('OperationLog'),
    }

    @base.remotable_classmethod
    def get_all(cls,
                context,
                marker,
                limit,
                sort_keys=None,
                sort_dirs=None,
                filters=None,
                offset=None):
        operation_logs = db.operation_log_get_all(context,
                                                  marker,
                                                  limit,
                                                  sort_keys=sort_keys,
                                                  sort_dirs=sort_dirs,
                                                  filters=filters,
                                                  offset=offset)
        return base.obj_make_list(context, cls(context), objects.OperationLog,
                                  operation_logs)

    @base.remotable_classmethod
    def get_all_by_project(cls,
                           context,
                           project_id,
                           marker,
                           limit,
                           sort_keys=None,
                           sort_dirs=None,
                           filters=None,
                           offset=None):
        operation_logs = db.operation_log_get_all_by_project(
            context,
            project_id,
            marker,
            limit,
            sort_keys=sort_keys,
            sort_dirs=sort_dirs,
            filters=filters,
            offset=offset)
        return base.obj_make_list(context, cls(context), objects.OperationLog,
                                  operation_logs)
Beispiel #27
0
class VolumeList(base.ObjectListBase, base.CinderObject):
    VERSION = '1.1'

    fields = {
        'objects': fields.ListOfObjectsField('Volume'),
    }

    child_versions = {
        '1.0': '1.0',
        '1.1': '1.1',
    }

    @base.remotable_classmethod
    def get_all(cls, context, marker, limit, sort_keys=None, sort_dirs=None,
                filters=None, offset=None):
        volumes = db.volume_get_all(context, marker, limit,
                                    sort_keys=sort_keys, sort_dirs=sort_dirs,
                                    filters=filters, offset=offset)
        expected_attrs = ['admin_metadata', 'metadata']
        return base.obj_make_list(context, cls(context), objects.Volume,
                                  volumes, expected_attrs=expected_attrs)

    @base.remotable_classmethod
    def get_all_by_host(cls, context, host, filters=None):
        volumes = db.volume_get_all_by_host(context, host, filters)
        expected_attrs = ['admin_metadata', 'metadata']
        return base.obj_make_list(context, cls(context), objects.Volume,
                                  volumes, expected_attrs=expected_attrs)

    @base.remotable_classmethod
    def get_all_by_group(cls, context, group_id, filters=None):
        volumes = db.volume_get_all_by_group(context, group_id, filters)
        expected_attrs = ['admin_metadata', 'metadata']
        return base.obj_make_list(context, cls(context), objects.Volume,
                                  volumes, expected_attrs=expected_attrs)

    @base.remotable_classmethod
    def get_all_by_project(cls, context, project_id, marker, limit,
                           sort_keys=None, sort_dirs=None, filters=None,
                           offset=None):
        volumes = db.volume_get_all_by_project(context, project_id, marker,
                                               limit, sort_keys=sort_keys,
                                               sort_dirs=sort_dirs,
                                               filters=filters, offset=offset)
        expected_attrs = ['admin_metadata', 'metadata']
        return base.obj_make_list(context, cls(context), objects.Volume,
                                  volumes, expected_attrs=expected_attrs)
Beispiel #28
0
class Trunk(base.NeutronDbObject):
    # Version 1.0: Initial version
    # Version 1.1: Changed tenant_id to project_id
    VERSION = '1.1'

    db_model = models.Trunk

    fields = {
        'admin_state_up': obj_fields.BooleanField(),
        'id': common_types.UUIDField(),
        'project_id': obj_fields.StringField(),
        'name': obj_fields.StringField(),
        'port_id': common_types.UUIDField(),
        'status': obj_fields.StringField(),
        'sub_ports': obj_fields.ListOfObjectsField(SubPort.__name__),
    }

    fields_no_update = ['project_id', 'port_id']

    synthetic_fields = ['sub_ports']

    def create(self):
        with self.db_context_writer(self.obj_context):
            sub_ports = []
            if self.obj_attr_is_set('sub_ports'):
                sub_ports = self.sub_ports

            try:
                super(Trunk, self).create()
            except o_db_exc.DBReferenceError:
                raise n_exc.PortNotFound(port_id=self.port_id)

            if sub_ports:
                for sub_port in sub_ports:
                    sub_port.trunk_id = self.id
                    sub_port.create()
                    self.sub_ports.append(sub_port)
                self.obj_reset_changes(['sub_ports'])

    def update(self, **kwargs):
        self.update_fields(kwargs)
        super(Trunk, self).update()

    def to_dict(self):
        _dict = super(Trunk, self).to_dict()
        resource_extend.apply_funcs(trunk_def.TRUNKS, _dict, self.db_obj)
        return _dict
Beispiel #29
0
class RestoreList(base.ObjectListBase, base.KarborObject):
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('Restore'),
    }

    @base.remotable_classmethod
    def get_all(cls,
                context,
                marker,
                limit,
                sort_keys=None,
                sort_dirs=None,
                filters=None,
                offset=None):
        restores = db.restore_get_all(context,
                                      marker,
                                      limit,
                                      sort_keys=sort_keys,
                                      sort_dirs=sort_dirs,
                                      filters=filters,
                                      offset=offset)
        return base.obj_make_list(context, cls(context), objects.Restore,
                                  restores)

    @base.remotable_classmethod
    def get_all_by_project(cls,
                           context,
                           project_id,
                           marker,
                           limit,
                           sort_keys=None,
                           sort_dirs=None,
                           filters=None,
                           offset=None):
        restores = db.restore_get_all_by_project(context,
                                                 project_id,
                                                 marker,
                                                 limit,
                                                 sort_keys=sort_keys,
                                                 sort_dirs=sort_dirs,
                                                 filters=filters,
                                                 offset=offset)
        return base.obj_make_list(context, cls(context), objects.Restore,
                                  restores)
Beispiel #30
0
class ManageableSnapshotList(base.ObjectListBase, base.CinderObject):
    # Version 1.0: Initial version
    VERSION = '1.0'

    fields = {
        'objects': fields.ListOfObjectsField('ManageableSnapshot'),
    }

    @classmethod
    def from_primitives(cls, context, data):
        ManageableSnapshotList.objects = []

        for item in data:
            manage_snap_obj = ManageableSnapshot.from_primitives(context, item)
            ManageableSnapshotList.objects.append(manage_snap_obj)
        ManageableSnapshotList._context = context
        return ManageableSnapshotList.objects