Osmclient migration to Python3 (feature 8031) 32/8032/8
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 8 Oct 2019 16:30:46 +0000 (18:30 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 9 Oct 2019 16:36:14 +0000 (18:36 +0200)
Change-Id: I8de971f0914919ade4e8f19ed9da7ce06e775d3b
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
19 files changed:
Dockerfile
devops-stages/stage-build.sh
osmclient/common/wait.py
osmclient/scripts/osm.py
osmclient/sol005/http.py
osmclient/sol005/ns.py
osmclient/sol005/nsd.py
osmclient/sol005/nsi.py
osmclient/sol005/nst.py
osmclient/sol005/package.py
osmclient/sol005/pdud.py
osmclient/sol005/sdncontroller.py
osmclient/sol005/vim.py
osmclient/sol005/vnf.py
osmclient/sol005/vnfd.py
osmclient/sol005/wim.py
setup.py
stdeb.cfg
tox.ini

index b7a8a91..e40b8bc 100644 (file)
@@ -1,5 +1,19 @@
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+#
 FROM ubuntu:16.04
 
 RUN apt-get update && apt-get -y install git make python python3 \
     libcurl4-gnutls-dev libgnutls-dev tox python-dev python3-dev \
-    debhelper python-setuptools python-all apt-utils
+    debhelper python-setuptools python3-setuptools python-all python3-all \
+    apt-utils
index bf7602b..dd4af61 100755 (executable)
@@ -1,3 +1,17 @@
 #!/bin/sh
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 rm -rf deb_dist
-tox -e build
+tox -e build,build3
index 620e7f5..a85808c 100644 (file)
@@ -134,9 +134,9 @@ def wait_for_status(entity_label, entity_id, timeout, apiUrlStatus, http_cmd, de
             resp = ''
             if resp_unicode:
                 resp = json.loads(resp_unicode)
-            # print 'HTTP CODE: {}'.format(http_code)
-            # print 'RESP: {}'.format(resp)
-            # print 'URL: {}/{}'.format(apiUrlStatus, entity_id)
+            # print('HTTP CODE: {}'.format(http_code))
+            # print('RESP: {}'.format(resp))
+            # print('URL: {}/{}'.format(apiUrlStatus, entity_id))
             if deleteFlag and http_code == 404:
                 # In case of deletion, '404 Not Found' means successfully deleted
                 # Display 'detailed-status: Deleted' and return
@@ -173,8 +173,8 @@ def wait_for_status(entity_label, entity_id, timeout, apiUrlStatus, http_cmd, de
                         else:
                             time_to_return = True
             new_detailed_status = _get_detailed_status(resp, entity_label, detailed_status_deleted)
-            # print 'DETAILED-STATUS: {}'.format(new_detailed_status)
-            # print 'DELETE-ATTEMPTS-LEFT: {}'.format(delete_attempts_left)
+            # print('DETAILED-STATUS: {}'.format(new_detailed_status))
+            # print('DELETE-ATTEMPTS-LEFT: {}'.format(delete_attempts_left))
             if not new_detailed_status:
                 new_detailed_status = 'In progress'
             # TODO: Change LCM to provide detailed-status more up to date
index 27ac086..fe140dd 100755 (executable)
@@ -219,7 +219,7 @@ def nsd_list(ctx, filter):
         resp = ctx.obj.nsd.list(filter)
     else:
         resp = ctx.obj.nsd.list()
-    # print yaml.safe_dump(resp)
+    # print(yaml.safe_dump(resp))
     table = PrettyTable(['nsd name', 'id'])
     fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
     if fullclassname == 'osmclient.sol005.client.Client':
@@ -273,7 +273,7 @@ def vnfd_list(ctx, nf_type, filter):
         resp = ctx.obj.vnfd.list(filter)
     else:
         resp = ctx.obj.vnfd.list()
-    # print yaml.safe_dump(resp)
+    # print(yaml.safe_dump(resp))
     table = PrettyTable(['nfpkg name', 'id'])
     fullclassname = ctx.obj.__module__ + "." + ctx.obj.__class__.__name__
     if fullclassname == 'osmclient.sol005.client.Client':
@@ -520,7 +520,7 @@ def nst_list(ctx, filter):
     except ClientException as inst:
         print((inst.message))
         exit(1)
-    # print yaml.safe_dump(resp)
+    # print(yaml.safe_dump(resp))
     table = PrettyTable(['nst name', 'id'])
     for nst in resp:
         name = nst['name'] if 'name' in nst else '-'
index 867db2d..f19a098 100644 (file)
@@ -29,7 +29,7 @@ class Http(http.Http):
 
     def _get_curl_cmd(self, endpoint):
         curl_cmd = pycurl.Curl()
-        #print self._url + endpoint
+        #print(self._url + endpoint)
         curl_cmd.setopt(pycurl.URL, self._url + endpoint)
         curl_cmd.setopt(pycurl.SSL_VERIFYPEER, 0)
         curl_cmd.setopt(pycurl.SSL_VERIFYHOST, 0)
@@ -44,7 +44,7 @@ class Http(http.Http):
         curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write)
         curl_cmd.perform()
         http_code = curl_cmd.getinfo(pycurl.HTTP_CODE)
-        #print 'HTTP_CODE: {}'.format(http_code)
+        #print('HTTP_CODE: {}'.format(http_code))
         curl_cmd.close()
         # TODO 202 accepted should be returned somehow
         if data.getvalue():
index 1c45f01..a75513b 100644 (file)
@@ -83,7 +83,7 @@ class Ns(object):
                     break
         resp = self._http.get_cmd('{}/{}'.format(self._apiBase, ns_id))
         #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, ns_id))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         raise NotFound("ns {} not found".format(name))
@@ -95,8 +95,8 @@ class Ns(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                                  ns['_id'], querystring))
-        # print 'HTTP CODE: {}'.format(http_code)
-        # print 'RESP: {}'.format(resp)
+        # print('HTTP CODE: {}'.format(http_code))
+        # print('RESP: {}'.format(resp))
         if http_code == 202:
             if wait and resp:
                 resp = json.loads(resp)
@@ -203,7 +203,7 @@ class Ns(object):
                 if wim_account is not None:
                     ns['wimAccountId'] = get_wim_account_id(wim_account)
 
-        # print yaml.safe_dump(ns)
+        # print(yaml.safe_dump(ns))
         try:
             self._apiResource = '/ns_instances_content'
             self._apiBase = '{}{}{}'.format(self._apiName,
@@ -215,8 +215,8 @@ class Ns(object):
             self._http.set_http_header(http_header)
             http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=ns)
-            # print 'HTTP CODE: {}'.format(http_code)
-            # print 'RESP: {}'.format(resp)
+            # print('HTTP CODE: {}'.format(http_code))
+            # print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 if resp:
                     resp = json.loads(resp)
@@ -256,8 +256,8 @@ class Ns(object):
             http_code, resp = self._http.get2_cmd('{}?nsInstanceId={}'.format(
                                                        self._apiBase, ns['_id'],
                                                        filter_string) )
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code == 200:
                 if resp:
                     resp = json.loads(resp)
@@ -287,8 +287,8 @@ class Ns(object):
             self._apiBase = '{}{}{}'.format(self._apiName,
                                       self._apiVersion, self._apiResource)
             http_code, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, operationId))
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code == 200:
                 if resp:
                     resp = json.loads(resp)
@@ -319,11 +319,11 @@ class Ns(object):
             self._apiBase = '{}{}{}'.format(self._apiName,
                                             self._apiVersion, self._apiResource)
             endpoint = '{}/{}/{}'.format(self._apiBase, ns['_id'], op_name)
-            #print 'OP_NAME: {}'.format(op_name)
-            #print 'OP_DATA: {}'.format(json.dumps(op_data))
+            #print('OP_NAME: {}'.format(op_name))
+            #print('OP_DATA: {}'.format(json.dumps(op_data)))
             http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=op_data)
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 if resp:
                     resp = json.loads(resp)
@@ -377,8 +377,8 @@ class Ns(object):
         try:
             http_code, resp = self._http.post_cmd(endpoint='/test/message/alarm_request',
                                        postfields_dict=data)
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 #resp = json.loads(resp)
                 print('Alarm created')
@@ -405,8 +405,8 @@ class Ns(object):
         try:
             http_code, resp = self._http.post_cmd(endpoint='/test/message/alarm_request',
                                        postfields_dict=data)
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 #resp = json.loads(resp)
                 print('Alarm deleted')
@@ -431,8 +431,8 @@ class Ns(object):
         try:
             http_code, resp = self._http.post_cmd(endpoint='/test/message/metric_request',
                                        postfields_dict=data)
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 #resp = json.loads(resp)
                 return 'Metric exported'
index 873be5b..bbfed17 100644 (file)
@@ -44,7 +44,7 @@ class Nsd(object):
         if filter:
             filter_string = '?{}'.format(filter)
         resp = self._http.get_cmd('{}{}'.format(self._apiBase, filter_string))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         return list()
@@ -65,7 +65,7 @@ class Nsd(object):
         # It is redundant, since the previous one already gets the whole nsdinfo
         # The only difference is that a different primitive is exercised
         resp = self._http.get_cmd('{}/{}'.format(self._apiBase, nsd['_id']))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         raise NotFound("nsd {} not found".format(name))
@@ -75,8 +75,8 @@ class Nsd(object):
         headers = self._client._headers
         headers['Accept'] = 'application/binary'
         http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, nsd['_id'], thing))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 #store in a file
@@ -106,8 +106,8 @@ class Nsd(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          nsd['_id'], querystring))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code == 202:
             print('Deletion in progress')
         elif http_code == 204:
@@ -157,8 +157,8 @@ class Nsd(object):
                                             self._apiVersion, self._apiResource)
             endpoint = '{}{}'.format(self._apiBase,ow_string)
             http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
index 33c0b92..ab6cf0a 100644 (file)
@@ -83,7 +83,7 @@ class Nsi(object):
                     break
         resp = self._http.get_cmd('{}/{}'.format(self._apiBase, nsi_id))
         #resp = self._http.get_cmd('{}/{}/nsd_content'.format(self._apiBase, nsi_id))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         raise NotFound("nsi {} not found".format(name))
@@ -95,8 +95,8 @@ class Nsi(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          nsi['_id'], querystring))
-        # print 'HTTP CODE: {}'.format(http_code)
-        # print 'RESP: {}'.format(resp)
+        # print('HTTP CODE: {}'.format(http_code))
+        # print('RESP: {}'.format(resp))
         if http_code == 202:
             if wait and resp:
                 resp = json.loads(resp)
@@ -199,7 +199,7 @@ class Nsi(object):
                         raise ValueError("Error at --config 'additionalParamsForSubnet' items must contain "
                                          "'additionalParamsForNs' and/or 'additionalParamsForVnf'")
 
-        # print yaml.safe_dump(nsi)
+        # print(yaml.safe_dump(nsi))
         try:
             self._apiResource = '/netslice_instances_content'
             self._apiBase = '{}{}{}'.format(self._apiName,
@@ -211,8 +211,8 @@ class Nsi(object):
             self._http.set_http_header(http_header)
             http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=nsi)
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 if resp:
                     resp = json.loads(resp)
@@ -252,8 +252,8 @@ class Nsi(object):
             http_code, resp = self._http.get2_cmd('{}?netsliceInstanceId={}'.format(
                                                        self._apiBase, nsi['_id'],
                                                        filter_string) )
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code == 200:
                 if resp:
                     resp = json.loads(resp)
@@ -283,8 +283,8 @@ class Nsi(object):
             self._apiBase = '{}{}{}'.format(self._apiName,
                                       self._apiVersion, self._apiResource)
             http_code, resp = self._http.get2_cmd('{}/{}'.format(self._apiBase, operationId))
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code == 200:
                 if resp:
                     resp = json.loads(resp)
@@ -315,11 +315,11 @@ class Nsi(object):
             self._apiBase = '{}{}{}'.format(self._apiName,
                                             self._apiVersion, self._apiResource)
             endpoint = '{}/{}/{}'.format(self._apiBase, nsi['_id'], op_name)
-            #print 'OP_NAME: {}'.format(op_name)
-            #print 'OP_DATA: {}'.format(json.dumps(op_data))
+            #print('OP_NAME: {}'.format(op_name))
+            #print('OP_DATA: {}'.format(json.dumps(op_data)))
             http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=op_data)
-            #print 'HTTP CODE: {}'.format(http_code)
-            #print 'RESP: {}'.format(resp)
+            #print('HTTP CODE: {}'.format(http_code))
+            #print('RESP: {}'.format(resp))
             if http_code in (200, 201, 202, 204):
                 if resp:
                     resp = json.loads(resp)
index ca62235..bd453bf 100644 (file)
@@ -42,7 +42,7 @@ class Nst(object):
         if filter:
             filter_string = '?{}'.format(filter)
         resp = self._http.get_cmd('{}{}'.format(self._apiBase, filter_string))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         return list()
@@ -63,7 +63,7 @@ class Nst(object):
         # It is redundant, since the previous one already gets the whole nstinfo
         # The only difference is that a different primitive is exercised
         resp = self._http.get_cmd('{}/{}'.format(self._apiBase, nst['_id']))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         raise NotFound("nst {} not found".format(name))
@@ -73,8 +73,8 @@ class Nst(object):
         headers = self._client._headers
         headers['Accept'] = 'application/binary'
         http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, nst['_id'], thing))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 #store in a file
@@ -104,8 +104,8 @@ class Nst(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          nst['_id'], querystring))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code == 202:
             print('Deletion in progress')
         elif http_code == 204:
@@ -154,8 +154,8 @@ class Nst(object):
                                             self._apiVersion, self._apiResource)
             endpoint = '{}{}'.format(self._apiBase,ow_string)
             http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
index 12412e4..330df3c 100644 (file)
@@ -76,7 +76,7 @@ class Package(object):
         else:
             endpoint = '/vnfpkgm/v1/vnf_packages_content'
         #endpoint = '/nsds' if pkg_type['type'] == 'nsd' else '/vnfds'
-        #print 'Endpoint: {}'.format(endpoint)
+        #print('Endpoint: {}'.format(endpoint))
         headers = self._client._headers
         headers['Content-Type'] = 'application/gzip'
         #headers['Content-Type'] = 'application/binary'
@@ -89,8 +89,8 @@ class Package(object):
                       for (key,val) in list(headers.items())]
         self._http.set_http_header(http_header)
         http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
index e8ba9c4..a3995d6 100644 (file)
@@ -60,7 +60,7 @@ class Pdu(object):
         # 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.get_cmd('{}/{}'.format(self._apiBase, pdud['_id']))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         raise NotFound("pdu {} not found".format(name))
@@ -72,8 +72,8 @@ class Pdu(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          pdud['_id'], querystring))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code == 202:
             print('Deletion in progress')
         elif http_code == 204:
@@ -99,8 +99,8 @@ class Pdu(object):
             endpoint = self._apiBase
             #endpoint = '{}{}'.format(self._apiBase,ow_string)
             http_code, resp = self._http.post_cmd(endpoint=endpoint, postfields_dict=pdu)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
index 6f63a9a..4036dfb 100644 (file)
@@ -61,8 +61,8 @@ class SdnController(object):
     def create(self, name, sdn_controller, wait=False):
         http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=sdn_controller)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
@@ -87,8 +87,8 @@ class SdnController(object):
         sdnc_id_for_wait = self._get_id_for_wait(name)
         http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,sdnc['_id']),
                                        postfields_dict=sdn_controller)
-        # print 'HTTP CODE: {}'.format(http_code)
-        # print 'RESP: {}'.format(resp)
+        # print('HTTP CODE: {}'.format(http_code))
+        # print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if wait:
                 # In this case, 'resp' always returns None, so 'resp['id']' cannot be used.
@@ -115,8 +115,8 @@ class SdnController(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          sdn_controller['_id'], querystring))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code == 202:
             if wait:
                 # Wait for status for SDNC instance deletion
@@ -143,7 +143,7 @@ class SdnController(object):
         if filter:
             filter_string = '?{}'.format(filter)
         resp = self._http.get_cmd('{}{}'.format(self._apiBase,filter_string))
-        #print 'RESP: {}'.format(resp)
+        #print('RESP: {}'.format(resp))
         if resp:
             return resp
         return list()
index 3012ae2..ad6f9b7 100644 (file)
@@ -82,8 +82,8 @@ class Vim(object):
 
         http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=vim_account)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
@@ -124,8 +124,8 @@ class Vim(object):
         #vim_account['config'] = json.dumps(vim_config)
         http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,vim['_id']),
                                        postfields_dict=vim_account)
-        # print 'HTTP CODE: {}'.format(http_code)
-        # print 'RESP: {}'.format(resp)
+        # print('HTTP CODE: {}'.format(http_code))
+        # print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if wait:
                 # In this case, 'resp' always returns None, so 'resp['id']' cannot be used.
@@ -170,8 +170,8 @@ class Vim(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          vim_id, querystring))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code == 202:
             if wait:
                 # When deleting an account, 'resp' may be None.
index 9875d39..6da13f5 100644 (file)
@@ -46,7 +46,7 @@ class Vnf(object):
             else:
                 filter_string = '?nsr-id-ref={}'.format(ns_instance['_id'])
         resp = self._http.get_cmd('{}{}'.format(self._apiBase,filter_string))
-        #print 'RESP: {}'.format(resp)
+        #print('RESP: {}'.format(resp))
         if resp:
             return resp
         return list()
@@ -72,7 +72,7 @@ class Vnf(object):
                     vnf_id = vnf['_id']
                     break
         resp = self._http.get_cmd('{}/{}'.format(self._apiBase, vnf_id))
-        #print 'RESP: {}'.format(resp)
+        #print('RESP: {}'.format(resp))
         if resp:
             return resp
         raise NotFound("vnf {} not found".format(name))
index 965b999..8ad11c6 100644 (file)
@@ -64,7 +64,7 @@ class Vnfd(object):
         # It is redundant, since the previous one already gets the whole vnfpkginfo
         # The only difference is that a different primitive is exercised
         resp = self._http.get_cmd('{}/{}'.format(self._apiBase, vnfd['_id']))
-        #print yaml.safe_dump(resp)
+        #print(yaml.safe_dump(resp))
         if resp:
             return resp
         raise NotFound("vnfd {} not found".format(name))
@@ -74,8 +74,8 @@ class Vnfd(object):
         headers = self._client._headers
         headers['Accept'] = 'application/binary'
         http_code, resp = self._http.get2_cmd('{}/{}/{}'.format(self._apiBase, vnfd['_id'], thing))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 #store in a file
@@ -105,8 +105,8 @@ class Vnfd(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          vnfd['_id'], querystring))
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code == 202:
             print('Deletion in progress')
         elif http_code == 204:
@@ -156,8 +156,8 @@ class Vnfd(object):
                                             self._apiVersion, self._apiResource)
             endpoint = '{}{}'.format(self._apiBase,ow_string)
             http_code, resp = self._http.post_cmd(endpoint=endpoint, filename=filename)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202):
             if resp:
                 resp = json.loads(resp)
index bf10e5f..30b36e7 100644 (file)
@@ -77,8 +77,8 @@ class Wim(object):
 
         http_code, resp = self._http.post_cmd(endpoint=self._apiBase,
                                        postfields_dict=wim_account)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if resp:
                 resp = json.loads(resp)
@@ -116,8 +116,8 @@ class Wim(object):
         #wim_account['config'] = json.dumps(wim_config)
         http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,wim['_id']),
                                        postfields_dict=wim_account)
-        #print 'HTTP CODE: {}'.format(http_code)
-        #print 'RESP: {}'.format(resp)
+        #print('HTTP CODE: {}'.format(http_code))
+        #print('RESP: {}'.format(resp))
         if http_code in (200, 201, 202, 204):
             if wait:
                 # In this case, 'resp' always returns None, so 'resp['id']' cannot be used.
@@ -137,7 +137,7 @@ class Wim(object):
             raise ClientException("failed to update wim {} - {}".format(wim_name, msg))
 
     def update_wim_account_dict(self, wim_account, wim_input):
-        print (wim_input)
+        print(wim_input)
         wim_account['wim_type'] = wim_input['wim_type']
         wim_account['description'] = wim_input['description']
         wim_account['wim_url'] = wim_input['url']
@@ -163,9 +163,9 @@ class Wim(object):
             querystring = '?FORCE=True'
         http_code, resp = self._http.delete_cmd('{}/{}{}'.format(self._apiBase,
                                          wim_id, querystring))
-        # print 'HTTP CODE: {}'.format(http_code)
-        # print 'RESP: {}'.format(resp)
-        # print 'WIM_ID: {}'.format(wim_id)
+        # print('HTTP CODE: {}'.format(http_code))
+        # print('RESP: {}'.format(resp))
+        # print('WIM_ID: {}'.format(wim_id))
         if http_code == 202:
             if wait:
                 # 'resp' may be None.
index 832e2fe..32a91a2 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,16 @@
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+#
 from setuptools import setup, find_packages
 
 setup(
@@ -13,8 +26,9 @@ setup(
     ],
     setup_requires=['setuptools-version-command'],
     test_suite='nose.collector',
-    entry_points='''
-        [console_scripts]
-        osm=osmclient.scripts.osm:cli
-        ''',
+    entry_points={
+        'console_scripts': [
+            'osm = osmclient.scripts.osm:cli',
+        ],
+    },
 )
index b385524..be9860f 100644 (file)
--- a/stdeb.cfg
+++ b/stdeb.cfg
@@ -1,3 +1,17 @@
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+#
 [DEFAULT]
+Suite: xenial
 Build-Depends: dh-python
 Depends: python-setuptools, python-pycurl, python-click, python-prettytable, python-yaml
diff --git a/tox.ini b/tox.ini
index 5c85c60..f6ec0c7 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,11 +1,25 @@
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+#
 [tox]
-envlist = py27,py3,flake8,pyflakes
+envlist = py27,py35,flake8,pyflakes
 toxworkdir={homedir}/.tox
 
 [testenv]
-deps=nose
-     mock
-commands=nosetests
+deps = nose
+       mock
+commands =
+    nosetests
 
 [testenv:flake8]
 basepython = python
@@ -24,3 +38,10 @@ basepython = python
 deps = stdeb
        setuptools-version-command
 commands = python setup.py --command-packages=stdeb.command bdist_deb
+
+[testenv:build3]
+basepython = python3
+deps = stdeb
+       setuptools-version-command
+commands = python3 setup.py --command-packages=stdeb.command bdist_deb
+