from osmclient.common.exceptions import ClientException
from osmclient.common import utils
import json
+import logging
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'
self._apiVersion, self._apiResource)
def list(self, filter=None):
+ self._logger.debug("")
self._client.get_token()
filter_string = ''
if filter:
return list()
def get(self, name):
+ self._logger.debug("")
self._client.get_token()
if utils.validate_uuid4(name):
for pdud in self.list():
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
raise NotFound("pdu {} not found".format(name))
def delete(self, name, force=False):
+ self._logger.debug("")
pdud = self.get(name)
querystring = ''
if force:
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'
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)