forked from dwcarder/python-OpenDaylight
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the OpenDaylight library to work with the current version of …
…the OpenDaylight controller: variable names changed.
- Loading branch information
Nabil Maadarani
committed
Feb 27, 2014
1 parent
23c3d18
commit 401c2ea
Showing
1 changed file
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ | |
Division of Information Technology | ||
University of Wisconsin at Madison | ||
Modified & updated by: Nabil Maadarani, [email protected] | ||
Cisco Science Network | ||
Cisco Systems | ||
This material is based upon work supported by the National Science Foundation | ||
under Grant No. 1247322. | ||
""" | ||
|
@@ -103,6 +107,7 @@ def prepare_url(self, app, path): | |
|
||
# the specific path we are building | ||
self.url = self._base_url + app + '/' + self.setup['container'] + path | ||
#self.url = self._base_url + app + '/' + path + self.setup['container'] | ||
|
||
def prepare_auth(self): | ||
"""Set up the credentials for the REST connection by creating | ||
|
@@ -150,7 +155,7 @@ def __init__(self, odl): | |
odl - an OpenDaylight object | ||
""" | ||
self.odl = odl | ||
self.__app = 'flow' | ||
self.__app = 'flowprogrammer' | ||
self.request = None | ||
self.flows = None | ||
|
||
|
@@ -170,7 +175,7 @@ def get(self, node_id=None, flow_name=None): | |
del self.flows | ||
|
||
if node_id is None: | ||
self.odl.prepare(self.__app, '/') | ||
self.odl.prepare(self.__app, '/flow') | ||
elif flow_name is None: | ||
self.odl.prepare(self.__app, '/' + 'OF/' + node_id + '/') | ||
else: | ||
|
@@ -183,6 +188,7 @@ def get(self, node_id=None, flow_name=None): | |
self.flows = self.request.json() | ||
if 'flowConfig' in self.flows: | ||
self.flows = self.flows.get('flowConfig') | ||
print(self.flows) | ||
else: | ||
raise OpenDaylightError({'url':self.odl.url, | ||
'http_code':self.request.status_code, | ||
|
@@ -197,11 +203,11 @@ def add(self, flow): | |
if hasattr(self, 'request'): | ||
del self.request | ||
#print(flow) | ||
self.odl.prepare(self.__app, '/' + flow['node']['@type'] + '/' + | ||
flow['node']['@id'] + '/' + flow['name'] + '/') | ||
self.odl.prepare(self.__app, '/node/' + flow['node']['type'] + '/' + | ||
flow['node']['id'] + '/staticFlow/' + flow['name'] + '/') | ||
headers = {'Content-type': 'application/json'} | ||
body = json.dumps(flow) | ||
self.request = requests.post(url=self.odl.url, auth=self.odl.auth, | ||
self.request = requests.put(url=self.odl.url, auth=self.odl.auth, | ||
data=body, headers=headers) | ||
|
||
if self.request.status_code != 201: | ||
|
@@ -224,7 +230,7 @@ def delete(self, node_id, flow_name): | |
if hasattr(self, 'request'): | ||
del self.request | ||
|
||
self.odl.prepare(self.__app, '/' + 'OF/' + node_id + '/' + | ||
self.odl.prepare(self.__app, '/node/' + 'OF/' + node_id + '/staticFlow/' + | ||
flow_name + '/') | ||
self.request = requests.delete(url=self.odl.url, auth=self.odl.auth) | ||
|
||
|
@@ -234,7 +240,7 @@ def delete(self, node_id, flow_name): | |
#self.prepare(self.__app, '/' + flow['node']['@type'] + '/' + | ||
# flow['node']['@id'] + '/' + flow['name'] + '/') | ||
|
||
if self.request.status_code != 200: | ||
if self.request.status_code != 204: | ||
raise OpenDaylightError({'url':self.odl.url, | ||
'http_code':self.request.status_code, | ||
'msg':self.request.text}) | ||
|