Cesar77RR's picture
download
raw
2.41 kB
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api import validators
from neutron_lib.utils import net
from oslo_log import log as logging
from neutron.db import common_db_mixin
from neutron.db import portsecurity_db_common as ps_db_common
from neutron.plugins.ml2 import driver_api as api
LOG = logging.getLogger(__name__)
class PortSecurityExtensionDriver(api.ExtensionDriver, ps_db_common.PortSecurityDbCommon, common_db_mixin.CommonDbMixin, ):
_supported_extension_alias = 'port-security'
def initialize(self):
LOG.info('PortSecurityExtensionDriver initialization complete')
@property
def extension_alias(self):
return self._supported_extension_alias
def process_create_network(self, context, data, result):
if (psec.PORTSECURITY not in data):
data[psec.PORTSECURITY] = psec.DEFAULT_PORT_SECURITY
self._process_network_port_security_create(context, data, result)
def process_update_network(self, context, data, result):
if (psec.PORTSECURITY in data):
self._process_network_port_security_update(context, data, result)
def process_create_port(self, context, data, result):
data[psec.PORTSECURITY] = self._determine_port_security(context, data)
self._process_port_port_security_create(context, data, result)
def process_update_port(self, context, data, result):
if (psec.PORTSECURITY in data):
self._process_port_port_security_update(context, data, result)
def extend_network_dict(self, session, db_data, result):
self._extend_port_security_dict(result, db_data)
def extend_port_dict(self, session, db_data, result):
self._extend_port_security_dict(result, db_data)
def _determine_port_security(self, context, port):
'Returns a boolean (port_security_enabled).\n\n Port_security is the value associated with the port if one is present\n otherwise the value associated with the network is returned.\n '
if (port.get('device_owner') and net.is_port_trusted(port)):
return False
if validators.is_attr_set(port.get(psec.PORTSECURITY)):
port_security_enabled = port[psec.PORTSECURITY]
else:
port_security_enabled = self._get_network_security_binding(context, port['network_id'])
return port_security_enabled

Xet Storage Details

Size:
2.41 kB
·
Xet hash:
02819a68a7b1dd585eb5759b2557aa164177e99d8893382795e6410338578a99

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.