Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Neil Hanlon
Efs Utils
Commits
c7a4b968
Commit
c7a4b968
authored
Dec 05, 2019
by
maxbecke
Browse files
Revert "Support Python 3"
This reverts the commits:
880da73a
b6b0d993
parent
880da73a
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/mount_efs/__init__.py
View file @
c7a4b968
...
...
@@ -44,11 +44,6 @@ import threading
from
contextlib
import
contextmanager
from
logging.handlers
import
RotatingFileHandler
try
:
from
ConfigParser
import
NoOptionError
except
Exception
:
from
configparser
import
NoOptionError
try
:
import
ConfigParser
except
ImportError
:
...
...
@@ -79,11 +74,11 @@ DEFAULT_STUNNEL_VERIFY_LEVEL = 2
DEFAULT_STUNNEL_CAFILE
=
'/etc/amazon/efs/efs-utils.crt'
EFS_ONLY_OPTIONS
=
[
'noocsp'
,
'ocsp'
,
'tls'
,
'tlsport'
,
'verify'
'verify'
,
'ocsp'
,
'noocsp'
]
UNSUPPORTED_OPTIONS
=
[
...
...
@@ -442,7 +437,7 @@ def create_state_file_dir(config, state_file_dir):
mode
=
int
(
mode_str
,
8
)
except
ValueError
:
logging
.
warn
(
'Bad state_file_dir_mode "%s" in config file "%s"'
,
mode_str
,
CONFIG_FILE
)
except
NoOptionError
:
except
ConfigParser
.
NoOptionError
:
pass
try
:
...
...
@@ -590,10 +585,7 @@ def assert_root():
def
read_config
(
config_file
=
CONFIG_FILE
):
try
:
p
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
p
=
ConfigParser
()
p
=
ConfigParser
.
SafeConfigParser
()
p
.
read
(
config_file
)
return
p
...
...
@@ -673,7 +665,7 @@ def match_device(config, device):
try
:
primary
,
secondaries
,
_
=
socket
.
gethostbyname_ex
(
remote
)
hostnames
=
list
(
filter
(
lambda
e
:
e
is
not
None
,
[
primary
]
+
secondaries
)
)
hostnames
=
filter
(
lambda
e
:
e
is
not
None
,
[
primary
]
+
secondaries
)
except
socket
.
gaierror
:
fatal_error
(
'Failed to resolve "%s" - check that the specified DNS name is a CNAME record resolving to a valid EFS DNS '
...
...
@@ -706,7 +698,6 @@ def mount_tls(config, init_system, dns_name, path, fs_id, mountpoint, options):
with
bootstrap_tls
(
config
,
init_system
,
dns_name
,
fs_id
,
mountpoint
,
options
)
as
tunnel_proc
:
mount_completed
=
threading
.
Event
()
t
=
threading
.
Thread
(
target
=
poll_tunnel_process
,
args
=
(
tunnel_proc
,
fs_id
,
mount_completed
))
t
.
daemon
=
True
t
.
start
()
mount_nfs
(
dns_name
,
path
,
mountpoint
,
options
)
mount_completed
.
set
()
...
...
src/watchdog/__init__.py
View file @
c7a4b968
...
...
@@ -280,10 +280,7 @@ def assert_root():
def
read_config
(
config_file
=
CONFIG_FILE
):
try
:
p
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
p
=
ConfigParser
()
p
=
ConfigParser
.
SafeConfigParser
()
p
.
read
(
config_file
)
return
p
...
...
test/mount_efs_test/test_bootstrap_tls.py
View file @
c7a4b968
...
...
@@ -30,7 +30,7 @@ def setup_mocks(mocker):
mocker
.
patch
(
'mount_efs.start_watchdog'
)
mocker
.
patch
(
'mount_efs.get_tls_port_range'
,
return_value
=
(
DEFAULT_TLS_PORT
,
DEFAULT_TLS_PORT
+
10
))
mocker
.
patch
(
'socket.socket'
,
return_value
=
MagicMock
())
mocker
.
patch
(
'mount_efs.write_tls_tunnel_state_file'
,
return_value
=
"~mocktempfile"
)
mocker
.
patch
(
'mount_efs.write_tls_tunnel_state_file'
)
mocker
.
patch
(
'os.rename'
)
mocker
.
patch
(
'os.kill'
)
...
...
test/mount_efs_test/test_choose_tls_port.py
View file @
c7a4b968
...
...
@@ -7,26 +7,19 @@
#
import
mount_efs
import
ConfigParser
import
socket
import
pytest
from
mock
import
MagicMock
try
:
import
ConfigParser
except
ImportError
:
from
configparser
import
ConfigParser
DEFAULT_TLS_PORT_RANGE_LOW
=
20049
DEFAULT_TLS_PORT_RANGE_HIGH
=
20449
def
_get_config
():
try
:
config
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
config
=
ConfigParser
()
config
=
ConfigParser
.
SafeConfigParser
()
config
.
add_section
(
mount_efs
.
CONFIG_SECTION
)
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'port_range_lower_bound'
,
str
(
DEFAULT_TLS_PORT_RANGE_LOW
))
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'port_range_upper_bound'
,
str
(
DEFAULT_TLS_PORT_RANGE_HIGH
))
...
...
test/mount_efs_test/test_get_dns_name.py
View file @
c7a4b968
...
...
@@ -63,7 +63,7 @@ def test_get_dns_name_bad_format_wrong_specifiers(mocker):
with
pytest
.
raises
(
ValueError
)
as
ex
:
mount_efs
.
get_dns_name
(
config
,
FS_ID
)
assert
'must include'
in
str
(
ex
)
assert
'must include'
in
ex
.
value
.
message
def
test_get_dns_name_bad_format_too_many_specifiers_1
(
mocker
):
...
...
@@ -72,7 +72,7 @@ def test_get_dns_name_bad_format_too_many_specifiers_1(mocker):
with
pytest
.
raises
(
ValueError
)
as
ex
:
mount_efs
.
get_dns_name
(
config
,
FS_ID
)
assert
'incorrect number'
in
str
(
ex
)
assert
'incorrect number'
in
ex
.
value
.
message
def
test_get_dns_name_bad_format_too_many_specifiers_2
(
mocker
):
...
...
@@ -81,7 +81,7 @@ def test_get_dns_name_bad_format_too_many_specifiers_2(mocker):
with
pytest
.
raises
(
ValueError
)
as
ex
:
mount_efs
.
get_dns_name
(
config
,
FS_ID
)
assert
'incorrect number'
in
str
(
ex
)
assert
'incorrect number'
in
ex
.
value
.
message
def
test_get_dns_name_unresolvable
(
mocker
,
capsys
):
...
...
test/mount_efs_test/test_get_region.py
View file @
c7a4b968
...
...
@@ -11,10 +11,7 @@ import json
import
pytest
try
:
from
urllib2
import
URLError
except
ImportError
:
from
urllib.error
import
URLError
from
urllib2
import
URLError
INSTANCE_DATA
=
{
'devpayProductCodes'
:
None
,
...
...
test/mount_efs_test/test_is_ocsp_enabled.py
View file @
c7a4b968
...
...
@@ -7,19 +7,13 @@
#
import
mount_efs
import
ConfigParser
import
pytest
try
:
import
ConfigParser
except
ImportError
:
from
configparser
import
ConfigParser
def
_get_config
(
stunnel_check_cert_validity
):
try
:
config
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
config
=
ConfigParser
()
config
=
ConfigParser
.
SafeConfigParser
()
config
.
add_section
(
mount_efs
.
CONFIG_SECTION
)
if
stunnel_check_cert_validity
is
not
None
:
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'stunnel_check_cert_validity'
,
str
(
stunnel_check_cert_validity
))
...
...
test/mount_efs_test/test_write_stunnel_config_file.py
View file @
c7a4b968
...
...
@@ -7,15 +7,11 @@
#
import
mount_efs
import
ConfigParser
import
os
import
pytest
try
:
import
ConfigParser
except
ImportError
:
from
configparser
import
ConfigParser
FS_ID
=
'fs-deadbeef'
DNS_NAME
=
'fs-deadbeef.com'
MOUNT_POINT
=
'/mnt'
...
...
@@ -37,10 +33,7 @@ def _get_config(mocker, stunnel_debug_enabled=False, stunnel_check_cert_hostname
if
stunnel_check_cert_validity
is
None
:
stunnel_check_cert_validity
=
stunnel_check_cert_validity_supported
try
:
config
=
ConfigParser
.
SafeConfigParser
()
except
AttributeError
:
config
=
ConfigParser
()
config
=
ConfigParser
.
SafeConfigParser
()
config
.
add_section
(
mount_efs
.
CONFIG_SECTION
)
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'stunnel_debug_enabled'
,
str
(
stunnel_debug_enabled
))
config
.
set
(
mount_efs
.
CONFIG_SECTION
,
'stunnel_check_cert_hostname'
,
str
(
stunnel_check_cert_hostname
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment