X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fnsd.py;h=873be5b3a0d056b46fdd57c8b28fca3f6620ffae;hb=12ddbf356d8b97e3f4afc67ec6543814153850fa;hp=63308d6c5e63d1de0525a3bce3662f194ca1464b;hpb=119f79ff8103018c12d9f3f5083a97e5a34aecba;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/nsd.py b/osmclient/sol005/nsd.py index 63308d6..873be5b 100644 --- a/osmclient/sol005/nsd.py +++ b/osmclient/sol005/nsd.py @@ -23,8 +23,9 @@ from osmclient.common.exceptions import ClientException from osmclient.common import utils import json import magic +from os.path import basename #from os import stat -#from os.path import basename + class Nsd(object): @@ -115,7 +116,7 @@ class Nsd(object): msg = "" if resp: try: - resp = json.loads(resp) + msg = json.loads(resp) except ValueError: msg = resp raise ClientException("failed to delete nsd {} - {}".format(name, msg)) @@ -126,8 +127,9 @@ class Nsd(object): raise ClientException( "failed to guess MIME type for file '{}'".format(filename)) headers= self._client._headers - if mime_type in ['application/yaml', 'text/plain']: - headers['Content-Type'] = 'application/yaml' + headers['Content-Filename'] = basename(filename) + if mime_type in ['application/yaml', 'text/plain', 'application/json']: + headers['Content-Type'] = 'text/plain' elif mime_type in ['application/gzip', 'application/x-gzip']: headers['Content-Type'] = 'application/gzip' #headers['Content-Type'] = 'application/binary' @@ -164,6 +166,8 @@ class Nsd(object): raise ClientException('unexpected response from server - {}'.format( resp)) print(resp['id']) + elif http_code == 204: + print('Updated') else: msg = "Error {}".format(http_code) if resp: