Adding logging capabilities to osmclient
[osm/osmclient.git] / osmclient / sol005 / pdud.py
index 22ca8bc..42fe40d 100644 (file)
@@ -22,6 +22,7 @@ from osmclient.common.exceptions import NotFound
 from osmclient.common.exceptions import ClientException
 from osmclient.common import utils
 import json
+import logging
 
 
 class Pdu(object):
@@ -29,6 +30,7 @@ class Pdu(object):
     def __init__(self, http=None, client=None):
         self._http = http
         self._client = client
+        self._logger = logging.getLogger('osmclient')
         self._apiName = '/pdu'
         self._apiVersion = '/v1'
         self._apiResource = '/pdu_descriptors'
@@ -36,6 +38,7 @@ class Pdu(object):
                                         self._apiVersion, self._apiResource)
 
     def list(self, filter=None):
+        self._logger.debug("")
         self._client.get_token()
         filter_string = ''
         if filter:
@@ -46,6 +49,7 @@ class Pdu(object):
         return list()
 
     def get(self, name):
+        self._logger.debug("")
         self._client.get_token()
         if utils.validate_uuid4(name):
             for pdud in self.list():
@@ -58,6 +62,7 @@ class Pdu(object):
         raise NotFound("pdud {} not found".format(name))
 
     def get_individual(self, name):
+        self._logger.debug("")
         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
@@ -68,6 +73,7 @@ class Pdu(object):
         raise NotFound("pdu {} not found".format(name))
 
     def delete(self, name, force=False):
+        self._logger.debug("")
         pdud = self.get(name)
         querystring = ''
         if force:
@@ -90,6 +96,7 @@ class Pdu(object):
             raise ClientException("failed to delete pdu {} - {}".format(name, msg))
 
     def create(self, pdu, update_endpoint=None):
+        self._logger.debug("")
         self._client.get_token()
         headers= self._client._headers
         headers['Content-Type'] = 'application/yaml'
@@ -121,6 +128,7 @@ class Pdu(object):
             raise ClientException("failed to create/update pdu - {}".format(msg))
 
     def update(self, name, filename):
+        self._logger.debug("")
         pdud = self.get(name)
         endpoint = '{}/{}'.format(self._apiBase, pdud['_id'])
         self.create(filename=filename, update_endpoint=endpoint)