Merge "Remove references to 'sys.version_info'"
This commit is contained in:
commit
48b5bf94a3
|
@ -22,7 +22,6 @@ It is used via a single directive in the .rst file
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.parsers import rst
|
from docutils.parsers import rst
|
||||||
|
@ -158,16 +157,12 @@ class FeatureMatrixDirective(rst.Directive):
|
||||||
:returns: Matrix instance
|
:returns: Matrix instance
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# SafeConfigParser was deprecated in Python 3.2
|
cfg = configparser.ConfigParser()
|
||||||
if sys.version_info >= (3, 2):
|
|
||||||
cfg = configparser.ConfigParser()
|
|
||||||
else:
|
|
||||||
cfg = configparser.SafeConfigParser()
|
|
||||||
env = self.state.document.settings.env
|
env = self.state.document.settings.env
|
||||||
filename = self.arguments[0]
|
filename = self.arguments[0]
|
||||||
rel_fpath, fpath = env.relfn2path(filename)
|
rel_fpath, fpath = env.relfn2path(filename)
|
||||||
with open(fpath) as fp:
|
with open(fpath) as fp:
|
||||||
cfg.readfp(fp)
|
cfg.read_file(fp)
|
||||||
|
|
||||||
# This ensures that the docs are rebuilt whenever the
|
# This ensures that the docs are rebuilt whenever the
|
||||||
# .ini file changes
|
# .ini file changes
|
||||||
|
|
|
@ -21,7 +21,6 @@ Leverages websockify.py by Joel Martin
|
||||||
import copy
|
import copy
|
||||||
from http import cookies as Cookie
|
from http import cookies as Cookie
|
||||||
import socket
|
import socket
|
||||||
import sys
|
|
||||||
from urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
@ -155,17 +154,9 @@ class NovaProxyRequestHandler(websockify.ProxyRequestHandler):
|
||||||
|
|
||||||
# The nova expected behavior is to have token
|
# The nova expected behavior is to have token
|
||||||
# passed to the method GET of the request
|
# passed to the method GET of the request
|
||||||
parse = urlparse.urlparse(self.path)
|
token = urlparse.parse_qs(
|
||||||
if parse.scheme not in ('http', 'https'):
|
urlparse.urlparse(self.path).query
|
||||||
# From a bug in urlparse in Python < 2.7.4 we cannot support
|
).get('token', ['']).pop()
|
||||||
# special schemes (cf: http://bugs.python.org/issue9374)
|
|
||||||
if sys.version_info < (2, 7, 4):
|
|
||||||
raise exception.NovaException(
|
|
||||||
_("We do not support scheme '%s' under Python < 2.7.4, "
|
|
||||||
"please use http or https") % parse.scheme)
|
|
||||||
|
|
||||||
query = parse.query
|
|
||||||
token = urlparse.parse_qs(query).get("token", [""]).pop()
|
|
||||||
if not token:
|
if not token:
|
||||||
# NoVNC uses it's own convention that forward token
|
# NoVNC uses it's own convention that forward token
|
||||||
# from the request to a cookie header, we should check
|
# from the request to a cookie header, we should check
|
||||||
|
|
|
@ -356,34 +356,6 @@ class NovaProxyRequestHandlerTestCase(test.NoDBTestCase):
|
||||||
mock.call(len(HTTP_RESP))])
|
mock.call(len(HTTP_RESP))])
|
||||||
self.wh.do_proxy.assert_called_with(tsock)
|
self.wh.do_proxy.assert_called_with(tsock)
|
||||||
|
|
||||||
@mock.patch.object(websocketproxy, 'sys')
|
|
||||||
@mock.patch('nova.console.websocketproxy.NovaProxyRequestHandler.'
|
|
||||||
'_check_console_port')
|
|
||||||
@mock.patch('nova.objects.ConsoleAuthToken.validate')
|
|
||||||
def test_new_websocket_client_py273_good_scheme(
|
|
||||||
self, validate, check_port, mock_sys):
|
|
||||||
mock_sys.version_info.return_value = (2, 7, 3)
|
|
||||||
params = {
|
|
||||||
'id': 1,
|
|
||||||
'token': '123-456-789',
|
|
||||||
'instance_uuid': uuids.instance,
|
|
||||||
'host': 'node1',
|
|
||||||
'port': '10000',
|
|
||||||
'console_type': 'novnc',
|
|
||||||
'access_url_base': 'https://example.net:6080'
|
|
||||||
}
|
|
||||||
validate.return_value = objects.ConsoleAuthToken(**params)
|
|
||||||
|
|
||||||
self.wh.socket.return_value = '<socket>'
|
|
||||||
self.wh.path = "http://127.0.0.1/?token=123-456-789"
|
|
||||||
self.wh.headers = self.fake_header
|
|
||||||
|
|
||||||
self.wh.new_websocket_client()
|
|
||||||
|
|
||||||
validate.assert_called_with(mock.ANY, "123-456-789")
|
|
||||||
self.wh.socket.assert_called_with('node1', 10000, connect=True)
|
|
||||||
self.wh.do_proxy.assert_called_with('<socket>')
|
|
||||||
|
|
||||||
@mock.patch('socket.getfqdn')
|
@mock.patch('socket.getfqdn')
|
||||||
def test_address_string_doesnt_do_reverse_dns_lookup(self, getfqdn):
|
def test_address_string_doesnt_do_reverse_dns_lookup(self, getfqdn):
|
||||||
request_mock = mock.MagicMock()
|
request_mock = mock.MagicMock()
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo_service import fixture as service_fixture
|
from oslo_service import fixture as service_fixture
|
||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
|
@ -28,10 +26,6 @@ from nova.virt.libvirt import guest as libvirt_guest
|
||||||
from nova.virt.libvirt import host
|
from nova.virt.libvirt import host
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info > (3,):
|
|
||||||
long = int
|
|
||||||
|
|
||||||
|
|
||||||
class GuestTestCase(test.NoDBTestCase):
|
class GuestTestCase(test.NoDBTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
Loading…
Reference in New Issue