| 1 |
# Copyright (C) 2016 Midokura SARL. |
| 2 |
# Copyright (C) 2015 Ericsson AB |
| 3 |
# Copyright (c) 2015 Gigamon |
| 4 |
# |
| 5 |
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 |
# not use this file except in compliance with the License. You may obtain |
| 7 |
# a copy of the License at |
| 8 |
# |
| 9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
# |
| 11 |
# Unless required by applicable law or agreed to in writing, software |
| 12 |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 |
# License for the specific language governing permissions and limitations |
| 15 |
# under the License. |
| 16 |
|
| 17 |
from neutron_lib import rpc as n_rpc |
| 18 |
from oslo_log import helpers as log_helpers |
| 19 |
from oslo_log import log as logging |
| 20 |
import oslo_messaging as messaging |
| 21 |
|
| 22 |
LOG = logging.getLogger(__name__) |
| 23 |
|
| 24 |
|
| 25 |
class TaasAgentApi: |
| 26 |
"""RPC calls to agent APIs""" |
| 27 |
|
| 28 |
def __init__(self, topic, host): |
| 29 |
self.host = host |
| 30 |
target = messaging.Target(topic=topic, version='1.0') |
| 31 |
self.client = n_rpc.get_client(target) |
| 32 |
|
| 33 |
def create_tap_service(self, context, tap_service_msg, host): |
| 34 |
LOG.debug("In RPC Call for Create Tap Service: Host=%s, MSG=%s", |
| 35 |
host, tap_service_msg) |
| 36 |
|
| 37 |
cctxt = self.client.prepare(fanout=True) |
| 38 |
cctxt.cast(context, 'create_tap_service', |
| 39 |
tap_service_msg=tap_service_msg, host=host) |
| 40 |
|
| 41 |
def create_tap_flow(self, context, tap_flow_msg, host): |
| 42 |
LOG.debug("In RPC Call for Create Tap Flow: Host=%s, MSG=%s", |
| 43 |
host, tap_flow_msg) |
| 44 |
|
| 45 |
cctxt = self.client.prepare(fanout=True) |
| 46 |
cctxt.cast(context, 'create_tap_flow', tap_flow_msg=tap_flow_msg, |
| 47 |
host=host) |
| 48 |
|
| 49 |
def delete_tap_service(self, context, tap_service_msg, host): |
| 50 |
LOG.debug("In RPC Call for Delete Tap Service: Host=%s, MSG=%s", |
| 51 |
host, tap_service_msg) |
| 52 |
|
| 53 |
cctxt = self.client.prepare(fanout=True) |
| 54 |
cctxt.cast(context, 'delete_tap_service', |
| 55 |
tap_service_msg=tap_service_msg, host=host) |
| 56 |
|
| 57 |
def delete_tap_flow(self, context, tap_flow_msg, host): |
| 58 |
LOG.debug("In RPC Call for Delete Tap Flow: Host=%s, MSG=%s", |
| 59 |
host, tap_flow_msg) |
| 60 |
|
| 61 |
cctxt = self.client.prepare(fanout=True) |
| 62 |
cctxt.cast(context, 'delete_tap_flow', tap_flow_msg=tap_flow_msg, |
| 63 |
host=host) |
| 64 |
|
| 65 |
@log_helpers.log_method_call |
| 66 |
def create_tap_mirror(self, context, tap_mirror_msg, host): |
| 67 |
cctxt = self.client.prepare(fanout=True) |
| 68 |
cctxt.cast(context, 'create_tap_mirror', tap_mirror_msg=tap_mirror_msg, |
| 69 |
host=host) |
| 70 |
|
| 71 |
@log_helpers.log_method_call |
| 72 |
def delete_tap_mirror(self, context, tap_mirror_msg, host): |
| 73 |
cctxt = self.client.prepare(fanout=True) |
| 74 |
cctxt.cast(context, 'delete_tap_mirror', tap_mirror_msg=tap_mirror_msg, |
| 75 |
host=host) |