"""
def __init__(self, params):
""" Constructor.
- Params: dictionary with the following keys:
+ :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/
+ 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
url = url + "/"
self.url = url + "onos/v1/"
- #internal variables
+ # internal variables
self.name = "onosof"
self.headers = {'content-type':'application/json','accept':'application/json',}
self.auth = self.auth.decode()
self.headers['authorization'] = 'Basic ' + self.auth
- self.logger = logging.getLogger('vim.OF.onos')
- self.logger.setLevel( getattr(logging, params.get("of_debug", "ERROR")) )
+ self.logger = logging.getLogger('openmano.sdn.onosof')
+ #self.logger.setLevel( getattr(logging, params.get("of_debug", "ERROR")) )
+ self.logger.debug("onosof plugin initialized")
self.ip_address = None
def get_of_switches(self):
"""
try:
+ self.logger.debug("del_flow: delete flow name {}".format(flow_name))
self.headers['content-type'] = None
of_response = requests.delete(self.url + "flows/" + self.id + "/" + flow_name, 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 != 204:
self.logger.warning("del_flow " + error_text)
raise OpenflowConnUnexpectedResponse(error_text)
- self.logger.debug("del_flow OK " + error_text)
+ self.logger.debug("del_flow: {} OK,: {} ".format(flow_name, error_text))
return None
except requests.exceptions.RequestException as e:
:return: Raise a openflowconnUnexpectedResponse expection in case of failure
"""
try:
+ self.logger.debug("new_flow data: {}".format(data))
if len(self.pp2ofi) == 0:
self.obtain_port_correspondence()
self.headers['content-type'] = 'application/json'
path = self.url + "flows/" + self.id
+ self.logger.debug("new_flow post: {}".format(flow))
of_response = requests.post(path, headers=self.headers, data=json.dumps(flow) )
- 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 != 201:
self.logger.warning("new_flow " + error_text)
raise OpenflowConnUnexpectedResponse(error_text)
data['name'] = flowId
- self.logger.debug("new_flow OK " + error_text)
+ self.logger.debug("new_flow id: {},: {} ".format(flowId, error_text))
return None
except requests.exceptions.RequestException as e: