]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
portsecurity_db_common: Access db columns in a consistent way
authorYAMAMOTO Takashi <yamamoto@midokura.com>
Thu, 2 Jul 2015 08:33:24 +0000 (17:33 +0900)
committerYAMAMOTO Takashi <yamamoto@midokura.com>
Mon, 6 Jul 2015 02:22:18 +0000 (11:22 +0900)
While db columns and api attribute happen to have same name here,
it's still better to distinguish them.

Change-Id: I6d6e649925a41d89fd74ca5e64290737c9baed9a

neutron/db/portsecurity_db_common.py

index 3fad11152b59d190d623898b9128d9ae01762f61..e348f81b19c51d670ed2cbc09ce7daa3c7025971 100644 (file)
@@ -83,7 +83,7 @@ class PortSecurityDbCommon(object):
                 NetworkSecurityBinding.network_id == network_id).one()
         except exc.NoResultFound:
             raise psec.PortSecurityBindingNotFound()
-        return binding[psec.PORTSECURITY]
+        return binding.port_security_enabled
 
     def _get_port_security_binding(self, context, port_id):
         try:
@@ -92,7 +92,7 @@ class PortSecurityDbCommon(object):
                 PortSecurityBinding.port_id == port_id).one()
         except exc.NoResultFound:
             raise psec.PortSecurityBindingNotFound()
-        return binding[psec.PORTSECURITY]
+        return binding.port_security_enabled
 
     def _process_port_port_security_update(
         self, context, port_req, port_res):
@@ -130,10 +130,10 @@ class PortSecurityDbCommon(object):
 
     def _make_network_port_security_dict(self, port_security, fields=None):
         res = {'network_id': port_security['network_id'],
-               psec.PORTSECURITY: port_security[psec.PORTSECURITY]}
+               psec.PORTSECURITY: port_security.port_security_enabled}
         return self._fields(res, fields)
 
     def _make_port_security_dict(self, port, fields=None):
         res = {'port_id': port['port_id'],
-               psec.PORTSECURITY: port[psec.PORTSECURITY]}
+               psec.PORTSECURITY: port.port_security_enabled}
         return self._fields(res, fields)