super().__init__(wim, wim_account, config, logger)
of_params = {
"of_url": wim["wim_url"],
- "of_dpid": config.get("dpid"),
+ "of_dpid": config.get("dpid") or config.get("switch_id"),
"of_user": wim_account["user"],
"of_password": wim_account["password"],
}
""" Constructor.
:param params: dictionary with the following keys:
of_dpid: DPID to use for this controller ?? Does a controller have a dpid?
- url: must be [http://HOST:PORT/]
+ of_url: must be [http://HOST:PORT/]
of_user: user credentials, can be missing or None
of_password: password credentials
of_debug: debug level for logging. Default to ERROR
self.auth = self.auth.decode()
self.headers['authorization'] = 'Basic ' + self.auth
- self.logger = logging.getLogger('openmano.sdn.onosof')
+ self.logger = logging.getLogger('openmano.sdnconn.onosof')
#self.logger.setLevel( getattr(logging, params.get("of_debug", "ERROR")) )
self.logger.debug("onosof plugin initialized")
self.ip_address = None
try:
self.headers['content-type'] = 'text/plain'
of_response = requests.get(self.url + "devices/" + self.id + "/ports", headers=self.headers)
- error_text = "Openflow response %d: %s" % (of_response.status_code, of_response.text)
+ error_text = "Openflow response {}: {}".format(of_response.status_code, of_response.text)
if of_response.status_code != 200:
self.logger.warning("obtain_port_correspondence " + error_text)
raise OpenflowConnUnexpectedResponse(error_text)
(vlan, None/int): for stripping/setting a vlan tag
(out, port): send to this port
switch: DPID, all
- Raise a openflowconnUnexpectedResponse expection in case of failure
+ Raise a openflowconnUnexpectedResponse exception in case of failure
"""
try:
# The configured page does not exist if there are no rules installed. In that case we return an empty dict
if of_response.status_code == 404:
- return {}
+ return []
elif of_response.status_code != 200:
self.logger.warning("get_of_rules " + error_text)
flow_list = info.get('flows')
if flow_list is None:
- return {}
-
+ return []
if type(flow_list) is not list:
self.logger.error(
"get_of_rules. Unexpected response at 'flows', not a list: %s",
raise OpenflowConnUnexpectedResponse("Unexpected response at 'flows', not a list. "
"Wrong version?")
- rules = [] # Response list
+ rules = [] # Response list
for flow in flow_list:
if not ('id' in flow and 'selector' in flow and 'treatment' in flow and \
'instructions' in flow['treatment'] and 'criteria' in \
actions: list of actions, composed by a pair tuples with these posibilities:
('vlan', None/int): for stripping/setting a vlan tag
('out', port): send to this port
- :return: Raise a openflowconnUnexpectedResponse expection in case of failure
+ :return: Raise a openflowconnUnexpectedResponse exception in case of failure
"""
try:
self.logger.debug("new_flow data: {}".format(data))
def __init__(self, wim, wim_account, config=None, logger=None):
"""Creates a connectivity based on pro-active openflow rules
"""
- self.logger = logging.getLogger('openmano.sdn.onosof')
+ self.logger = logging.getLogger('openmano.sdnconn.onosof')
super().__init__(wim, wim_account, config, logger)
of_params = {
"of_url": wim["wim_url"],
- "of_dpid": config.get("dpid"),
+ "of_dpid": config.get("dpid") or config.get("switch_id"),
"of_user": wim_account["user"],
"of_password": wim_account["password"],
}
self.openflow_conn = OfConnOnos(of_params)
super().__init__(wim, wim_account, config, logger, self.openflow_conn)
+ self.logger.debug("Init sdn plugin '{}' dpid={} user={}".format(of_params["of_url"], of_params["of_dpid"],
+ of_params["of_user"]))
"""
https://wiki.onosproject.org/display/ONOS/VPLS+User+Guide
"""
- _WIM_LOGGER = "sdn.assist.onos.vpls"
+ _WIM_LOGGER = "openmano.sdnconn.onosvpls"
def __init__(self, wim, wim_account, config=None, logger=None):
self.logger = logger or logging.getLogger(self._WIM_LOGGER)
# method before the implemented VIM connectors are called.
def _format_exception(self, exception):
- '''Transform a keystone, nova, neutron exception into a vimconn exception'''
+ """Transform a keystone, nova, neutron exception into a vimconn exception discovering the cause"""
- message_error = exception.message
+ message_error = str(exception)
if isinstance(exception, (neExceptions.NetworkNotFoundClient, nvExceptions.NotFound, ksExceptions.NotFound,
gl1Exceptions.HTTPNotFound)):
raise vimconn.vimconnNotFoundException(type(exception).__name__ + ": " + message_error)
elif isinstance(exception, (HTTPException, gl1Exceptions.HTTPException, gl1Exceptions.CommunicationError,
- ConnectionError, ksExceptions.ConnectionError, neExceptions.ConnectionFailed)):
+ ConnectionError, ksExceptions.ConnectionError, neExceptions.ConnectionFailed)):
raise vimconn.vimconnConnectionException(type(exception).__name__ + ": " + message_error)
- elif isinstance(exception, (KeyError, nvExceptions.BadRequest, ksExceptions.BadRequest)):
+ elif isinstance(exception, (KeyError, nvExceptions.BadRequest, ksExceptions.BadRequest)):
raise vimconn.vimconnException(type(exception).__name__ + ": " + message_error)
elif isinstance(exception, (nvExceptions.ClientException, ksExceptions.ClientException,
neExceptions.NeutronException)):
"log_level_console": log_level_schema,
"log_level_ovim": log_level_schema,
"log_level_sdn": log_level_schema,
+ "log_level_sdnconn": log_level_schema,
"log_file_db": path_schema,
"log_file_vim": path_schema,
"log_file_wim": path_schema,
"log_file_console": path_schema,
"log_file_ovim": path_schema,
"log_file_sdn": path_schema,
+ "log_file_sdnconn": path_schema,
"log_socket_host": nameshort_schema,
"log_socket_port": port_schema,
"log_file": path_schema,
"additionalProperties": False
}
-sdn_port_mapping_schema = {
+sdn_port_mapping_schema = {
"$schema": "http://json-schema.org/draft-04/schema#",
"title":"sdn port mapping information schema",
"type": "object",
"properties": {
"pci": {"OneOf": [null_schema, pci_extended_schema]}, # pci_schema,
"switch_port": nameshort_schema,
+ "switch_id": nameshort_schema,
+ "switch_dpid": nameshort_schema,
"switch_mac": mac_schema
},
"required": ["pci"]
#log_file_wim: /opt/openmano/logs/openmano_wimconn.log
#log_level_nfvo: DEBUG #Main engine log levels
#log_file_nfvo: /opt/openmano/logs/openmano_nfvo.log
-log_level_http: DEBUG #Main engine log levels
+#log_level_http: DEBUG #Main engine log levels
#log_file_http: /opt/openmano/logs/openmano_http.log
#log_level_console: DEBUG #proxy console log levels
#log_file_console: /opt/openmano/logs/openmano_console.log
#log_file_ovim: /opt/openmano/logs/openmano_ovim.log
#log_level_sdn: DEBUG
#log_file_sdn: /opt/openmano/logs/openmano_sdn.log
+#log_level_sdnconn: DEBUG
+#log_file_sdnconn: /opt/openmano/logs/openmano_sdnconn.log
#Uncomment to send logs via IP to an external host
#log_socket_host: localhost
logger.critical("Starting openmano server version: '%s %s' command: '%s'",
ro_version, version_date, " ".join(sys.argv))
- for log_module in ("nfvo", "http", "vim", "wim", "db", "console", "ovim","sdn"):
+ for log_module in ("nfvo", "http", "vim", "wim", "db", "console", "ovim", "sdn", "sdnconn"):
log_level_module = "log_level_" + log_module
log_file_module = "log_file_" + log_module
logger_module = logging.getLogger('openmano.' + log_module)
of_data = {x: wim_account[x] for x in ("uuid", "name", "user")}
if isinstance(wim_account["config"], str):
config = yaml.load(wim_account["config"], Loader=yaml.Loader)
- of_data["dpid"] = config.get("dpid")
+ of_data["dpid"] = config.get("switch_id") or config.get("dpid")
of_data["version"] = config.get("version")
if wim:
of_data["url"] = wim["wim_url"]
wim_id = wim_account["wim_id"]
db_wim_port_mappings = []
for map in maps:
+ _switch_dpid = map.get("switch_id") or map.get("switch_dpid") or switch_dpid
new_map = {
'wim_id': wim_id,
- 'switch_dpid': switch_dpid,
+ 'switch_dpid': _switch_dpid,
"switch_port": map.get("switch_port"),
'datacenter_id': vim_id,
"device_id": map.get("compute_node"),
- "service_endpoint_id": switch_dpid + "-" + str(uuid4())
+ "service_endpoint_id": _switch_dpid + "-" + str(uuid4())
}
if map.get("pci"):
new_map["device_interface_id"] = map["pci"].lower()
ports = self.db.get_rows(FROM='instance_interfaces', WHERE={'instance_wim_net_id': task["item_id"]})
sdn_need_update = False
+ if len(ports) != len(connected_ports):
+ sdn_need_update = True
for port in ports:
# TODO. Do not connect if already done
if port.get("compute_node") and port.get("pci"):
wim_id: (internal, do not use)
:param logger (logging.Logger): optional logger object. If none is passed 'openmano.sdn.sdnconn' is used.
"""
- self.logger = logger or logging.getLogger('openmano.sdn.sdnconn')
+ self.logger = logger or logging.getLogger('openmano.sdnconn')
self.wim = wim
self.wim_account = wim_account