aboutsummaryrefslogtreecommitdiffstats
path: root/docker/vnf/cloudify-rest-client-py3.patch
blob: ef47e1aa3689084a388415c781da0fdedce643ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
diff --git a/cloudify_rest_client/aria/mapi/mapi.py b/cloudify_rest_client/aria/mapi/mapi.py
index 401c9de..5c4fa76 100644
--- a/cloudify_rest_client/aria/mapi/mapi.py
+++ b/cloudify_rest_client/aria/mapi/mapi.py
@@ -88,7 +88,7 @@ class RESTMAPI(api.ModelAPI):
             wrapper = wrappers.DictWrapper
             kw = dict(
                     (key, self._wrap(value, '/'.join([attribute_path, key])))
-                    for key, value in value.items()
+                    for key, value in list(value.items())
                 )
         elif isinstance(value, list):
             wrapper = wrappers.ListWrapper
diff --git a/cloudify_rest_client/aria/mapi/wrappers.py b/cloudify_rest_client/aria/mapi/wrappers.py
index bdee6de..13af062 100644
--- a/cloudify_rest_client/aria/mapi/wrappers.py
+++ b/cloudify_rest_client/aria/mapi/wrappers.py
@@ -71,7 +71,7 @@ class DictWrapper(dict, WrapperBase):
         )
 
     def itervalues(self):
-        return iter(self.values())
+        return iter(list(self.values()))
 
     def items(self):
         return [
@@ -81,7 +81,7 @@ class DictWrapper(dict, WrapperBase):
         ]
 
     def iteritems(self):
-        return iter(self.items())
+        return iter(list(self.items()))
 
     def keys(self):
         return [
@@ -91,10 +91,10 @@ class DictWrapper(dict, WrapperBase):
         ]
 
     def iterkeys(self):
-        return iter(self.keys())
+        return iter(list(self.keys()))
 
     def __iter__(self):
-        return self.iterkeys()
+        return iter(self.keys())
 
 
 class ListWrapper(list, WrapperBase):
diff --git a/cloudify_rest_client/aria/service_templates.py b/cloudify_rest_client/aria/service_templates.py
index 05b86df..d49a91f 100644
--- a/cloudify_rest_client/aria/service_templates.py
+++ b/cloudify_rest_client/aria/service_templates.py
@@ -14,8 +14,8 @@
 #    * limitations under the License.
 
 import os
-import urllib
-import urlparse
+import urllib.request, urllib.parse, urllib.error
+import urllib.parse
 from functools import partial
 
 from .. import bytes_stream_utils
@@ -41,14 +41,14 @@ class ServiceTemplateClient(BlueprintsClient):
 
         if application_file_name is not None:
             query_params['application_file_name'] = \
-                urllib.quote(application_file_name)
+                urllib.parse.quote(application_file_name)
 
         uri = '/{self._uri_prefix}/{id}'.format(self=self,
                                                 id=service_template_id)
 
         # For a Windows path (e.g. "C:\aaa\bbb.zip") scheme is the
         # drive letter and therefore the 2nd condition is present
-        if urlparse.urlparse(archive_location).scheme and \
+        if urllib.parse.urlparse(archive_location).scheme and \
                 not os.path.exists(archive_location):
             # archive location is URL
             query_params['service_template_csar_url'] = archive_location
diff --git a/cloudify_rest_client/blueprints.py b/cloudify_rest_client/blueprints.py
index 5d19325..5f533cc 100644
--- a/cloudify_rest_client/blueprints.py
+++ b/cloudify_rest_client/blueprints.py
@@ -16,8 +16,8 @@
 import os
 import tempfile
 import shutil
-import urllib
-import urlparse
+import urllib.request, urllib.parse, urllib.error
+import urllib.parse
 import contextlib
 
 from cloudify_rest_client import utils
@@ -95,13 +95,13 @@ class BlueprintsClient(object):
         query_params = {'visibility': visibility}
         if application_file_name is not None:
             query_params['application_file_name'] = \
-                urllib.quote(application_file_name)
+                urllib.parse.quote(application_file_name)
 
         uri = '/{self._uri_prefix}/{id}'.format(self=self, id=blueprint_id)
 
         # For a Windows path (e.g. "C:\aaa\bbb.zip") scheme is the
         # drive letter and therefore the 2nd condition is present
-        if urlparse.urlparse(archive_location).scheme and \
+        if urllib.parse.urlparse(archive_location).scheme and \
                 not os.path.exists(archive_location):
             # archive location is URL
             query_params['blueprint_archive_url'] = archive_location
diff --git a/cloudify_rest_client/client.py b/cloudify_rest_client/client.py
index 84641d2..0528e66 100644
--- a/cloudify_rest_client/client.py
+++ b/cloudify_rest_client/client.py
@@ -144,13 +144,13 @@ class HTTPClient(object):
                                    verify=verify,
                                    timeout=timeout or self.default_timeout_sec)
         if self.logger.isEnabledFor(logging.DEBUG):
-            for hdr, hdr_content in response.request.headers.iteritems():
+            for hdr, hdr_content in response.request.headers.items():
                 self.logger.debug('request header:  %s: %s'
                                   % (hdr, hdr_content))
             self.logger.debug('reply:  "%s %s" %s'
                               % (response.status_code,
                                  response.reason, response.content))
-            for hdr, hdr_content in response.headers.iteritems():
+            for hdr, hdr_content in response.headers.items():
                 self.logger.debug('response header:  %s: %s'
                                   % (hdr, hdr_content))
 
@@ -209,7 +209,7 @@ class HTTPClient(object):
         body = json.dumps(data) if is_dict_data else data
         if self.logger.isEnabledFor(logging.DEBUG):
             log_message = 'Sending request: {0} {1}'.format(
-                requests_method.func_name.upper(),
+                requests_method.__name__.upper(),
                 request_url)
             if is_dict_data:
                 log_message += '; body: {0}'.format(body)
@@ -299,8 +299,8 @@ class HTTPClient(object):
         if not username or not password:
             return None
         credentials = '{0}:{1}'.format(username, password)
-        encoded_credentials = urlsafe_b64encode(credentials)
-        return BASIC_AUTH_PREFIX + ' ' + encoded_credentials
+        encoded_credentials = urlsafe_b64encode(credentials.encode("utf-8"))
+        return BASIC_AUTH_PREFIX + ' ' + str(encoded_credentials, "utf-8")
 
     def _set_header(self, key, value, log_value=True):
         if not value:
diff --git a/cloudify_rest_client/deployment_updates.py b/cloudify_rest_client/deployment_updates.py
index 5010d86..d7db897 100644
--- a/cloudify_rest_client/deployment_updates.py
+++ b/cloudify_rest_client/deployment_updates.py
@@ -14,9 +14,9 @@
 #    * limitations under the License.
 import os
 import json
-import urllib
+import urllib.request, urllib.parse, urllib.error
 import shutil
-import urlparse
+import urllib.parse
 import tempfile
 from mimetypes import MimeTypes
 
@@ -129,11 +129,11 @@ class DeploymentUpdatesClient(object):
 
         if application_file_name:
             params['application_file_name'] = \
-                urllib.quote(application_file_name)
+                urllib.parse.quote(application_file_name)
 
         # For a Windows path (e.g. "C:\aaa\bbb.zip") scheme is the
         # drive letter and therefore the 2nd condition is present
-        if all([urlparse.urlparse(archive_path).scheme,
+        if all([urllib.parse.urlparse(archive_path).scheme,
                 not os.path.exists(archive_path)]):
             # archive location is URL
             params['blueprint_archive_url'] = archive_path
@@ -142,7 +142,7 @@ class DeploymentUpdatesClient(object):
                 os.path.basename(archive_path),
                 open(archive_path, 'rb'),
                 # Guess the archive mime type
-                mime_types.guess_type(urllib.pathname2url(archive_path)))
+                mime_types.guess_type(urllib.request.pathname2url(archive_path)))
 
         return data_form, params
 
diff --git a/cloudify_rest_client/plugins.py b/cloudify_rest_client/plugins.py
index 76171b4..32e3e47 100644
--- a/cloudify_rest_client/plugins.py
+++ b/cloudify_rest_client/plugins.py
@@ -14,7 +14,7 @@
 #    * limitations under the License.
 
 import os
-import urlparse
+import urllib.parse
 import contextlib
 
 from cloudify_rest_client import bytes_stream_utils
@@ -222,7 +222,7 @@ class PluginsClient(object):
         assert plugin_path
         query_params = {'visibility': visibility}
         timeout = self.api.default_timeout_sec
-        if urlparse.urlparse(plugin_path).scheme and \
+        if urllib.parse.urlparse(plugin_path).scheme and \
                 not os.path.exists(plugin_path):
             query_params['plugin_archive_url'] = plugin_path
             data = None
diff --git a/cloudify_rest_client/snapshots.py b/cloudify_rest_client/snapshots.py
index 851c3a3..0c40ceb 100644
--- a/cloudify_rest_client/snapshots.py
+++ b/cloudify_rest_client/snapshots.py
@@ -14,7 +14,7 @@
 #    * limitations under the License.
 
 import os
-import urlparse
+import urllib.parse
 import contextlib
 
 from cloudify_rest_client import bytes_stream_utils
@@ -192,7 +192,7 @@ class SnapshotsClient(object):
         uri = '/snapshots/{0}/archive'.format(snapshot_id)
         query_params = {}
 
-        if urlparse.urlparse(snapshot_path).scheme and \
+        if urllib.parse.urlparse(snapshot_path).scheme and \
                 not os.path.exists(snapshot_path):
             query_params['snapshot_archive_url'] = snapshot_path
             data = None