Added all common modules in conductor directory
[optf/has.git] / conductor / conductor / middleware.py
1 #
2 # -------------------------------------------------------------------------
3 #   Copyright (c) 2015-2017 AT&T Intellectual Property
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain 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,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #
17 # -------------------------------------------------------------------------
18 #
19
20 """ Middleware """
21
22 # from oslo_config import cfg
23 # import oslo_messaging
24 #
25 # from conductor.agent import plugin_base
26 # from conductor import sample
27 #
28 # OPTS = [
29 #     cfg.MultiStrOpt('http_control_exchanges',
30 #                     default=[cfg.CONF.nova_control_exchange,
31 #                              cfg.CONF.glance_control_exchange,
32 #                              cfg.CONF.neutron_control_exchange,
33 #                              cfg.CONF.cinder_control_exchange],
34 #                     help="Exchanges name to listen for notifications."),
35 # ]
36 #
37 # cfg.CONF.register_opts(OPTS)
38 #
39 #
40 # class HTTPRequest(plugin_base.NotificationBase,
41 #                   plugin_base.NonMetricNotificationBase):
42 #     event_types = ['http.request']
43 #
44 #     def get_targets(self, conf):
45 #         """Return a sequence of oslo_messaging.Target
46 #         This sequence is defining the exchange and topics to be connected for
47 #         this plugin.
48 #         """
49 #         return [oslo_messaging.Target(topic=topic, exchange=exchange)
50 #                 for topic in self.get_notification_topics(conf)
51 #                 for exchange in conf.http_control_exchanges]
52 #
53 #     def process_notification(self, message):
54 #         yield sample.Sample.from_notification(
55 #             name=message['event_type'],
56 #             type=sample.TYPE_DELTA,
57 #             volume=1,
58 #             unit=message['event_type'].split('.')[1],
59 #             user_id=message['payload']['request'].get('HTTP_X_USER_ID'),
60 #             project_id=message['payload']['request'].get('HTTP_X_PROJECT_ID'),
61 #             resource_id=message['payload']['request'].get(
62 #                 'HTTP_X_SERVICE_NAME'),
63 #             message=message)
64 #
65 #
66 # class HTTPResponse(HTTPRequest):
67 #     event_types = ['http.response']