fix SDN: port mapping, switch_id, sdnconn logging
[osm/RO.git] / RO-SDN-onos_openflow / osm_rosdn_onosof / sdnconn_onosof.py
1 ##
2 # Copyright 2019 Telefonica Investigacion y Desarrollo, S.A.U.
3 # All Rights Reserved.
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
14 # implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 ##
19 """The SdnConnectorOnosOf connector is responsible for creating services using pro active operflow rules.
20 """
21
22 import logging
23 from osm_ro.wim.openflow_conn import SdnConnectorOpenFlow
24 from .onos_of import OfConnOnos
25
26
27 class SdnConnectorOnosOf(SdnConnectorOpenFlow):
28
29 def __init__(self, wim, wim_account, config=None, logger=None):
30 """Creates a connectivity based on pro-active openflow rules
31 """
32 self.logger = logging.getLogger('openmano.sdnconn.onosof')
33 super().__init__(wim, wim_account, config, logger)
34 of_params = {
35 "of_url": wim["wim_url"],
36 "of_dpid": config.get("dpid") or config.get("switch_id"),
37 "of_user": wim_account["user"],
38 "of_password": wim_account["password"],
39 }
40 self.openflow_conn = OfConnOnos(of_params)
41 super().__init__(wim, wim_account, config, logger, self.openflow_conn)
42 self.logger.debug("Init sdn plugin '{}' dpid={} user={}".format(of_params["of_url"], of_params["of_dpid"],
43 of_params["of_user"]))