projects
/
osm
/
osmclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
adding operational state to the vim-list
[osm/osmclient.git]
/
osmclient
/
sol005
/
pdud.py
diff --git
a/osmclient/sol005/pdud.py
b/osmclient/sol005/pdud.py
index
9b15ca7
..
aa4bf69
100644
(file)
--- a/
osmclient/sol005/pdud.py
+++ b/
osmclient/sol005/pdud.py
@@
-19,7
+19,7
@@
OSM pdud API handling
"""
from osmclient.common.exceptions import NotFound
"""
from osmclient.common.exceptions import NotFound
-from osmclient.common.exceptions import
OsmHttp
Exception
+from osmclient.common.exceptions import
Client
Exception
from osmclient.common import utils
import json
import logging
from osmclient.common import utils
import json
import logging
@@
-66,11
+66,14
@@
class Pdu(object):
pdud = self.get(name)
# It is redundant, since the previous one already gets the whole pdudInfo
# The only difference is that a different primitive is exercised
pdud = self.get(name)
# It is redundant, since the previous one already gets the whole pdudInfo
# The only difference is that a different primitive is exercised
- _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, pdud['_id']))
+ try:
+ _, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, pdud['_id']))
+ except NotFound:
+ raise NotFound("pdu '{}' not found".format(name))
#print(yaml.safe_dump(resp))
if resp:
return json.loads(resp)
#print(yaml.safe_dump(resp))
if resp:
return json.loads(resp)
- raise NotFound("pdu
{}
not found".format(name))
+ raise NotFound("pdu
'{}'
not found".format(name))
def delete(self, name, force=False):
self._logger.debug("")
def delete(self, name, force=False):
self._logger.debug("")
@@
-87,13
+90,13
@@
class Pdu(object):
elif http_code == 204:
print('Deleted')
else:
elif http_code == 204:
print('Deleted')
else:
- msg = ""
- if resp:
- try:
- msg = json.loads(resp)
- except ValueError:
- msg = resp
- raise
OsmHttp
Exception("failed to delete pdu {} - {}".format(name, msg))
+ msg =
resp or
""
+
#
if resp:
+
#
try:
+
#
msg = json.loads(resp)
+
#
except ValueError:
+
#
msg = resp
+ raise
Client
Exception("failed to delete pdu {} - {}".format(name, msg))
def create(self, pdu, update_endpoint=None):
self._logger.debug("")
def create(self, pdu, update_endpoint=None):
self._logger.debug("")
@@
-115,7
+118,7
@@
class Pdu(object):
if resp:
resp = json.loads(resp)
if not resp or 'id' not in resp:
if resp:
resp = json.loads(resp)
if not resp or 'id' not in resp:
- raise
OsmHttpException('unexpected response from server:
'.format(
+ raise
ClientException('unexpected response from server: {}
'.format(
resp))
print(resp['id'])
#else:
resp))
print(resp['id'])
#else: