]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: import py3 compatible modules using six
authorKefu Chai <kchai@redhat.com>
Tue, 24 Mar 2020 08:33:57 +0000 (16:33 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 14 Jun 2020 08:34:53 +0000 (16:34 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 80b71ef461043bfa274b2c73fb0697a0e75759cd)

qa/tasks/barbican.py
qa/tasks/radosgw_admin.py
qa/tasks/tests/test_radosgw_admin.py
qa/tasks/vault.py
src/powerdns/pdns-backend-rgw.py
src/test/rgw/rgw_multi/tests_ps.py
src/test/rgw/rgw_multi/zone_ps.py

index e191476c4329395e2e54de9ecb538416a72fc627..51a9af1f9ebb3f31e38ce23fbf638aabc6761902 100644 (file)
@@ -4,8 +4,8 @@ Deploy and configure Barbican for Teuthology
 import argparse
 import contextlib
 import logging
-import httplib
-from urlparse import urlparse
+from six.moves import http_client
+from six.moves.urllib.parse import urlparse
 import json
 
 from teuthology import misc as teuthology
@@ -250,7 +250,7 @@ def create_secrets(ctx, config):
                                                  port=barbican_port)
     log.info("barbican_url=%s", barbican_url)
     #fetching user_id of user that gets secrets for radosgw
-    token_req = httplib.HTTPConnection(keystone_host, keystone_port, timeout=30)
+    token_req = http_client.HTTPConnection(keystone_host, keystone_port, timeout=30)
     token_req.request(
         'POST',
         '/v2.0/tokens',
@@ -287,7 +287,7 @@ def create_secrets(ctx, config):
             if 'password' not in secret:
                 raise ConfigError('barbican.secrets must have "password" field')
 
-            token_req = httplib.HTTPConnection(keystone_host, keystone_port, timeout=30)
+            token_req = http_client.HTTPConnection(keystone_host, keystone_port, timeout=30)
             token_req.request(
                 'POST',
                 '/v2.0/tokens',
@@ -324,7 +324,7 @@ def create_secrets(ctx, config):
                     "payload_content_encoding": "base64"
                 })
 
-            sec_req = httplib.HTTPConnection(barbican_host, barbican_port, timeout=30)
+            sec_req = http_client.HTTPConnection(barbican_host, barbican_port, timeout=30)
             try:
                 sec_req.request(
                     'POST',
@@ -355,7 +355,7 @@ def create_secrets(ctx, config):
                         "project-access": True
                     }
                 })
-            acl_req = httplib.HTTPConnection(secret_url_parsed.netloc, timeout=30)
+            acl_req = http_client.HTTPConnection(secret_url_parsed.netloc, timeout=30)
             acl_req.request(
                 'PUT',
                 secret_url_parsed.path+'/acl',
index ce14e1b0d21806bed7ee924cd39bbc82a2ed4b6d..22eb6a0eaa03c55b6c06d5b174b8b207d2c8131e 100644 (file)
@@ -14,7 +14,7 @@ import json
 import logging
 import time
 import datetime
-import Queue
+from six.moves import queue
 
 import sys
 
index dbbebf8908585c2256392c1ed684f987b43a3657..2ed0ebd52e093593829f5250fa23d90fcb313e65 100644 (file)
@@ -1,4 +1,8 @@
-from mock import Mock
+import six
+if six.PY3:
+    from unittest.mock import Mock
+else:
+    from mock import Mock
 
 from tasks import radosgw_admin
 
index 1265513408bc1caef5d71e818f2ca12079920b88..6af7c074f6d99386372d7fb54834080df5d9e548 100644 (file)
@@ -6,10 +6,10 @@ import argparse
 import contextlib
 import logging
 import time
-import httplib
 import json
 from os import path
-from urlparse import urljoin
+from six.moves import http_client
+from six.moves.urllib.parse import urljoin
 
 from teuthology import misc as teuthology
 from teuthology import contextutil
@@ -155,7 +155,7 @@ def setup_vault(ctx, config):
 
 def send_req(ctx, cconfig, client, path, body, method='POST'):
     host, port = ctx.vault.endpoints[client]
-    req = httplib.HTTPConnection(host, port, timeout=30)
+    req = http_client.HTTPConnection(host, port, timeout=30)
     token = cconfig.get('root_token', 'atoken')
     log.info("Send request to Vault: %s:%s at %s with token: %s", host, port, path, token)
     headers = {'X-Vault-Token': token}
index fb60ac2ee5bd27c7b97dfed5d559bbd0c07840f8..b943ed9b421be1091fc5f8d30c13eff1923bca1d 100755 (executable)
@@ -53,7 +53,7 @@ from ConfigParser import SafeConfigParser, NoSectionError
 from flask import abort, Flask, request, Response
 from hashlib import sha1 as sha
 from time import gmtime, strftime
-from urlparse import urlparse
+from six.moves.urllib.parse import urlparse
 import argparse
 import base64
 import hmac
index 50e440c017e0e9552f68e49ff9ab30261b0337cf..7588b5f872b81e405af127e6671e7e6aa9e175df 100644 (file)
@@ -1,8 +1,7 @@
 import logging
 import json
 import tempfile
-import BaseHTTPServer
-import SocketServer
+from six.moves import BaseHTTPServer
 import random
 import threading
 import subprocess
index 69d903db4b50f8cf461651a361621e33710ff1a7..240e04f62c43080e1684b98a2b9596fcc8486e26 100644 (file)
@@ -1,12 +1,12 @@
 import logging
-import httplib
 import ssl
 import urllib
-import urlparse
 import hmac
 import hashlib
 import base64
 import xmltodict
+from six.moves import http_client
+from six.moves.urllib.parse import urlparse
 from time import gmtime, strftime
 from tasks.rgw_multi.multisite import Zone
 import boto3
@@ -88,7 +88,7 @@ def make_request(conn, method, resource, parameters=None, sign_parameters=False,
     headers = {'Authorization': 'AWS '+conn.aws_access_key_id+':'+signature,
                'Date': string_date,
                'Host': conn.host+':'+str(conn.port)}
-    http_conn = httplib.HTTPConnection(conn.host, conn.port)
+    http_conn = http_client.HTTPConnection(conn.host, conn.port)
     if log.getEffectiveLevel() <= 10:
         http_conn.set_debuglevel(5)
     http_conn.request(method, resource+url_params, NO_HTTP_BODY, headers)
@@ -227,10 +227,10 @@ class PSTopicS3:
                    'Host': self.conn.host+':'+str(self.conn.port),
                    'Content-Type': content_type}
         if self.conn.is_secure:
-            http_conn = httplib.HTTPSConnection(self.conn.host, self.conn.port, 
+            http_conn = http_client.HTTPSConnection(self.conn.host, self.conn.port,
                     context=ssl.create_default_context(cafile='./cert.pem'))
         else:
-            http_conn = httplib.HTTPConnection(self.conn.host, self.conn.port)
+            http_conn = http_client.HTTPConnection(self.conn.host, self.conn.port)
         http_conn.request(method, resource, body, headers)
         response = http_conn.getresponse()
         data = response.read()
@@ -269,10 +269,10 @@ class PSTopicS3:
                    'Host': self.conn.host+':'+str(self.conn.port),
                    'Content-Type': content_type}
         if self.conn.is_secure:
-            http_conn = httplib.HTTPSConnection(self.conn.host, self.conn.port, 
+            http_conn = http_client.HTTPSConnection(self.conn.host, self.conn.port,
                     context=ssl.create_default_context(cafile='./cert.pem'))
         else:
-            http_conn = httplib.HTTPConnection(self.conn.host, self.conn.port)
+            http_conn = http_client.HTTPConnection(self.conn.host, self.conn.port)
         http_conn.request(method, resource, body, headers)
         response = http_conn.getresponse()
         data = response.read()