Beispiel #1
0
 def get_by_id(cls, context, id):
     db_obj = db_api.get_object(context, cls.db_model,
                                **{cls.primary_key: id})
     if db_obj:
         obj = cls(context, **db_obj)
         obj.obj_reset_changes()
         return obj
Beispiel #2
0
 def get_by_id(cls, context, id):
     db_obj = db_api.get_object(context, cls.db_model,
                                **{cls.primary_key: id})
     if db_obj:
         obj = cls(context, **db_obj)
         obj.obj_reset_changes()
         return obj
Beispiel #3
0
    def delete(self):
        models = (("network", self.network_binding_model), ("port", self.port_binding_model))
        with db_api.autonested_transaction(self._context.session):
            for object_type, model in models:
                binding_db_obj = db_api.get_object(self._context, model, policy_id=self.id)
                if binding_db_obj:
                    raise exceptions.QosPolicyInUse(
                        policy_id=self.id, object_type=object_type, object_id=binding_db_obj["%s_id" % object_type]
                    )

            super(QosPolicy, self).delete()
Beispiel #4
0
    def delete(self):
        models = (('network', self.network_binding_model),
                  ('port', self.port_binding_model))
        with db_api.autonested_transaction(self._context.session):
            for object_type, model in models:
                binding_db_obj = db_api.get_object(self._context,
                                                   model,
                                                   policy_id=self.id)
                if binding_db_obj:
                    raise exceptions.QosPolicyInUse(
                        policy_id=self.id,
                        object_type=object_type,
                        object_id=binding_db_obj['%s_id' % object_type])

            super(QosPolicy, self).delete()
Beispiel #5
0
 def get_by_id(cls, context, id):
     db_obj = db_api.get_object(context, cls.db_model, id=id)
     if db_obj:
         obj = cls(context, **db_obj)
         obj.obj_reset_changes()
         return obj
Beispiel #6
0
 def _get_object_policy(cls, context, model, **kwargs):
     with db_api.autonested_transaction(context.session):
         binding_db_obj = db_api.get_object(context, model, **kwargs)
         if binding_db_obj:
             return cls.get_by_id(context, binding_db_obj['policy_id'])
Beispiel #7
0
 def _get_object_policy(cls, context, model, **kwargs):
     with db_api.autonested_transaction(context.session):
         binding_db_obj = db_api.get_object(context, model, **kwargs)
         if binding_db_obj:
             return cls.get_by_id(context, binding_db_obj["policy_id"])
Beispiel #8
0
 def get_by_id(cls, context, id):
     db_obj = db_api.get_object(context, cls.db_model, id=id)
     if db_obj:
         obj = cls(context, **db_obj)
         obj.obj_reset_changes()
         return obj