From 7674d77701875a39f55a15a6c61fce3272c6c98f Mon Sep 17 00:00:00 2001 From: kumarashit Date: Tue, 7 Jul 2020 13:29:10 +0530 Subject: [PATCH 1/2] Changing the keys as per the swagger specs. This is to correct the swagger validation while creating and attaching volume --- contrib/st2/opensds/actions/attach_volume.py | 8 ++++---- contrib/st2/opensds/actions/create_volume.py | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/st2/opensds/actions/attach_volume.py b/contrib/st2/opensds/actions/attach_volume.py index 9434fdb..673dc70 100644 --- a/contrib/st2/opensds/actions/attach_volume.py +++ b/contrib/st2/opensds/actions/attach_volume.py @@ -28,10 +28,10 @@ def run(self, auth_token="", volume_id=""): data = { - "AttachMode": attach_mode, - "HostId": host_id, - "TenantId": tenant_id, - "VolumeId": volume_id} + "attachMode": attach_mode if attach_mode else "rw", + "hostId": host_id, + "tenantId": tenant_id, + "volumeId": volume_id} headers = { 'content-type': 'application/json', 'x-auth-token': auth_token diff --git a/contrib/st2/opensds/actions/create_volume.py b/contrib/st2/opensds/actions/create_volume.py index 4dff273..bbbc6de 100644 --- a/contrib/st2/opensds/actions/create_volume.py +++ b/contrib/st2/opensds/actions/create_volume.py @@ -32,13 +32,13 @@ def run(self, auth_token="", size=1): data = { - "Name": name, - "Description": description, - "AvailabilityZone": availability_zone, - "ProfileId": profile_id, - "SnapshotId": snapshot_id, - "SnapshotFromCloud": snapshot_from_cloud, - "Size": size + "name": name, + "description": description if description else "Volume creation", + "availabilityZone": availability_zone if availability_zone else "default", + "profileId": profile_id, + "snapshotId": snapshot_id if snapshot_id else "", + "snapshotFromCloud": snapshot_from_cloud if snapshot_from_cloud else False, + "size": size } if profile_id: data["ProfileId"] = profile_id From a66fa65587939385c1f23f1fb998d8716121e16c Mon Sep 17 00:00:00 2001 From: kumarashit Date: Tue, 7 Jul 2020 14:40:50 +0530 Subject: [PATCH 2/2] Fix CI issue. Though this is not related to the current changes for the feature fix --- orchestration/db/api.py | 1 + tests/unit/db/test_api.py | 1 + 2 files changed, 2 insertions(+) diff --git a/orchestration/db/api.py b/orchestration/db/api.py index d508d6a..16bb77f 100644 --- a/orchestration/db/api.py +++ b/orchestration/db/api.py @@ -24,6 +24,7 @@ from sqlalchemy.sql.expression import and_ from orchestration.utils.config import logger + # session_scope can be used cleanly in transaction, # references the officel document of sqlalchemy. @contextmanager diff --git a/tests/unit/db/test_api.py b/tests/unit/db/test_api.py index d835de9..43760ac 100644 --- a/tests/unit/db/test_api.py +++ b/tests/unit/db/test_api.py @@ -97,6 +97,7 @@ def test_list_services(mock_session): result = api.list_services(None) assert len(result) == 0 + # ------------------------Test for task------------------------------------ @mock.patch('uuid.uuid4') @mock.patch('orchestration.db.api.session_scope')