| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
from neutron_lib import rpc as n_rpc |
| 17 |
from oslo_config import cfg |
| 18 |
import oslo_messaging |
| 19 |
|
| 20 |
from neutron_fwaas._i18n import _ |
| 21 |
|
| 22 |
|
| 23 |
FWAAS_V2 = "v2" |
| 24 |
FW_L2_NOOP_DRIVER = 'noop' |
| 25 |
|
| 26 |
FWaaSOpts = [ |
| 27 |
cfg.StrOpt( |
| 28 |
'driver', |
| 29 |
default='', |
| 30 |
help=_("Name of the FWaaS Driver")), |
| 31 |
cfg.BoolOpt( |
| 32 |
'enabled', |
| 33 |
default=False, |
| 34 |
help=_("Enable FWaaS")), |
| 35 |
cfg.StrOpt( |
| 36 |
'agent_version', |
| 37 |
default=FWAAS_V2, |
| 38 |
deprecated_for_removal=True, |
| 39 |
deprecated_reason='This option has no effect', |
| 40 |
help=_("Firewall agent class")), |
| 41 |
cfg.StrOpt( |
| 42 |
'conntrack_driver', |
| 43 |
default='conntrack', |
| 44 |
help=_("Name of the FWaaS Conntrack Driver")), |
| 45 |
cfg.StrOpt( |
| 46 |
'firewall_l2_driver', |
| 47 |
default=FW_L2_NOOP_DRIVER, |
| 48 |
help=_("Name of the firewall l2 driver") |
| 49 |
) |
| 50 |
] |
| 51 |
cfg.CONF.register_opts(FWaaSOpts, 'fwaas') |
| 52 |
|
| 53 |
|
| 54 |
class FWaaSPluginApiMixin: |
| 55 |
"""Agent side of the FWaaS agent to FWaaS Plugin RPC API.""" |
| 56 |
|
| 57 |
def __init__(self, topic, host): |
| 58 |
|
| 59 |
super().__init__() |
| 60 |
|
| 61 |
self.host = host |
| 62 |
target = oslo_messaging.Target(topic=topic, version='1.0') |
| 63 |
self.client = n_rpc.get_client(target) |
| 64 |
|
| 65 |
def set_firewall_status(self, context, firewall_id, status): |
| 66 |
"""Make a RPC to set the status of a firewall.""" |
| 67 |
cctxt = self.client.prepare() |
| 68 |
return cctxt.call(context, 'set_firewall_status', host=self.host, |
| 69 |
firewall_id=firewall_id, status=status) |
| 70 |
|
| 71 |
def firewall_deleted(self, context, firewall_id): |
| 72 |
"""Make a RPC to indicate that the firewall resources are deleted.""" |
| 73 |
cctxt = self.client.prepare() |
| 74 |
return cctxt.call(context, 'firewall_deleted', host=self.host, |
| 75 |
firewall_id=firewall_id) |
| 76 |
|
| 77 |
|
| 78 |
class FWaaSAgentRpcCallbackMixin: |
| 79 |
"""Mixin for FWaaS agent Implementations.""" |
| 80 |
|
| 81 |
def __init__(self, host): |
| 82 |
|
| 83 |
super().__init__(host) |
| 84 |
|
| 85 |
def create_firewall(self, context, firewall, host): |
| 86 |
"""Handle RPC cast from plugin to create a firewall.""" |
| 87 |
pass |
| 88 |
|
| 89 |
def update_firewall(self, context, firewall, host): |
| 90 |
"""Handle RPC cast from plugin to update a firewall.""" |
| 91 |
pass |
| 92 |
|
| 93 |
def delete_firewall(self, context, firewall, host): |
| 94 |
"""Handle RPC cast from plugin to delete a firewall.""" |
| 95 |
pass |