Skip to content

Commit b3c604a

Browse files
Merge pull request #359 from cloudify-cosmo/CY-2555-Port-OSv2-To-Python3
CY-2555-Port-OS-v2-to-python3
2 parents 848e103 + 91490b8 commit b3c604a

27 files changed

+176
-65
lines changed

.circleci/config.yml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ executors:
2929

3030

3131
commands:
32-
run_unittest:
32+
run_unittests_py27:
3333
steps:
3434
- checkout
3535
- run:
@@ -44,12 +44,14 @@ commands:
4444

4545
check_py3_compat:
4646
steps:
47+
- checkout
4748
- run:
4849
name: install futurize
4950
command: pip install future --user
5051
- run:
51-
name: remove compat module
52-
command: rm openstack_sdk/_compat.py
52+
name: remove python3 incompatible modules
53+
command: |
54+
rm openstack_plugin_common/_compat.py
5355
- run:
5456
name: find python3-incompatible code
5557
command: |
@@ -69,6 +71,27 @@ commands:
6971
exit 1
7072
fi
7173
74+
run_unittests_py36:
75+
steps:
76+
- checkout
77+
- run:
78+
name: Download pip
79+
command: curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
80+
- run:
81+
name: Install pip
82+
command: sudo python get-pip.py
83+
- run:
84+
name: Install virtualenv
85+
command: pip install --user virtualenv
86+
- run:
87+
name: Init virtualenv
88+
command: virtualenv env
89+
- run:
90+
name: install tox
91+
command: pip install --user tox
92+
- run: /home/circleci/.local/bin/tox -e flake8
93+
- run: /home/circleci/.local/bin/tox -e nosetests
94+
7295
generate_py27_wagon:
7396
steps:
7497
- run:
@@ -179,17 +202,16 @@ jobs:
179202
unittests_py27:
180203
executor: py27
181204
steps:
182-
- run_unittest
205+
- run_unittests_py27
183206

184207
unittests_py36:
185208
executor: py36
186209
steps:
187-
- run_unittest
210+
- run_unittests_py36
188211

189212
py3_compat:
190213
executor: py27
191214
steps:
192-
- checkout
193215
- check_py3_compat
194216

195217
wagon:
@@ -225,6 +247,8 @@ workflows:
225247
tests:
226248
jobs: &all_jobs
227249
- unittests_py27
250+
- unittests_py36
251+
- py3_compat
228252
- wagon:
229253
filters:
230254
branches:
@@ -265,18 +289,20 @@ workflows:
265289
- 2.14.18-build
266290
jobs:
267291
- unittests_py27
292+
- unittests_py36
293+
- py3_compat
268294
- wagon:
269295
filters:
270296
branches:
271-
only: /(2.14.18-build|master)/
297+
only: /(2.14.19-build|master)/
272298
- rhel_wagon:
273299
filters:
274300
branches:
275-
only: /(2.14.18-build|master)/
301+
only: /(2.14.19-build|master)/
276302
- integration_tests:
277303
requires:
278304
- wagon
279305
- rhel_wagon
280306
filters:
281307
branches:
282-
only: /(2.14.18-build|master)/
308+
only: /(2.14.19-build|master)/

.circleci/py3fixers

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--stage1
2+
-f lib2to3.fixes.fix_getcwdu
3+
-f lib2to3.fixes.fix_long
4+
-f lib2to3.fixes.fix_nonzero
5+
-f lib2to3.fixes.fix_input
6+
-f lib2to3.fixes.fix_raw_input
7+
-f lib2to3.fixes.fix_itertools
8+
-f lib2to3.fixes.fix_itertools_imports
9+
-f lib2to3.fixes.fix_exec
10+
-f lib2to3.fixes.fix_operator
11+
-f libfuturize.fixes.fix_execfile
12+
-f libpasteurize.fixes.fix_newstyle
13+
-f lib2to3.fixes.fix_filter
14+
# fix_dict is not idempotent
15+
# -f lib2to3.fixes.fix_dict
16+
-f lib2to3.fixes.fix_map
17+
-f lib2to3.fixes.fix_zip
18+
-f lib2to3.fixes.fix_xrange
19+
-f lib2to3.fixes.fix_basestring
20+
-f libfuturize.fixes.fix_cmp
21+
-f libfuturize.fixes.fix_division_safe
22+
-f lib2to3.fixes.fix_metaclass
23+
-f libfuturize.fixes.fix_unicode_keep_u

CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2.14.19:
2+
- Make plugin python 3 complaint
13
2.14.18:
24
- Support Import Keypair Public Material
35
2.14.17:

dev-requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
https://github.com/cloudify-cosmo/cloudify-rest-client/archive/3.4.2-build.zip
2-
https://github.com/cloudify-cosmo/cloudify-dsl-parser/archive/3.4.2-build.zip
3-
https://github.com/cloudify-cosmo/cloudify-plugins-common/archive/3.4.2-build.zip
1+
future

glance_plugin/image.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# * See the License for the specific language governing permissions and
1414
# * limitations under the License.
15-
import httplib
16-
from urlparse import urlparse
15+
from openstack_plugin_common._compat import (httplib, urlparse)
1716

1817
from cloudify import ctx
1918
from cloudify.decorators import operation

glance_plugin/tests/test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def test_check_image_url(self):
5454
# test if it passes no file & url
5555
http_connection_mock = mock.MagicMock()
5656
http_connection_mock.return_value.getresponse.return_value.status = 200
57-
with mock.patch('httplib.HTTPConnection', http_connection_mock):
57+
with mock.patch('openstack_plugin_common._compat.'
58+
'httplib.HTTPConnection', http_connection_mock):
5859
glance_plugin.image._validate_image()
5960

6061
def test_check_image_file(self):
@@ -80,7 +81,8 @@ def test_check_image_bad_file(self):
8081
def test_check_image_bad_url(self):
8182
http_connection_mock = mock.MagicMock()
8283
http_connection_mock.return_value.getresponse.return_value.status = 400
83-
with mock.patch('httplib.HTTPConnection', http_connection_mock):
84+
with mock.patch('openstack_plugin_common._compat.'
85+
'httplib.HTTPConnection', http_connection_mock):
8486
self.assertRaises(NonRecoverableError,
8587
glance_plugin.image._validate_image)
8688

keystone_plugin/tests/test_project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from builtins import object
12
import mock
23
import unittest
34

@@ -33,7 +34,7 @@ class TestProject(unittest.TestCase):
3334
test_user = 'test-user'
3435
test_role = 'test-role'
3536

36-
class MockProjectOS:
37+
class MockProjectOS(object):
3738
def __init__(self, id, name):
3839
self._id = id
3940
self._name = name

keystone_plugin/tests/test_user.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from builtins import object
12
import mock
23
import unittest
34

@@ -27,7 +28,7 @@ class TestUser(unittest.TestCase):
2728
updated_name = 'updated-name'
2829
test_deployment_id = 'test-deployment-id'
2930

30-
class MockUserOS:
31+
class MockUserOS(object):
3132
def __init__(self, id, name):
3233
self._id = id
3334
self._name = name

neutron_plugin/floatingip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
delete_floatingip,
3333
floatingip_creation_validation
3434
)
35-
from network import NETWORK_OPENSTACK_TYPE
35+
from .network import NETWORK_OPENSTACK_TYPE
3636

3737
FLOATINGIP_OPENSTACK_TYPE = 'floatingip'
3838
FLOATING_NETWORK_ERROR_PREFIX = \

neutron_plugin/rbac_policy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def find_resource_to_apply_rbac_policy(ctx):
9090

9191
def validate_found_resource(input_dict, found_resource):
9292
if found_resource:
93-
for key in found_resource.keys():
93+
for key in found_resource:
9494
if key in input_dict and input_dict.get(key):
9595
raise NonRecoverableError(
9696
'Multiple definitions of resource for which '

0 commit comments

Comments
 (0)