# Copyright 2014 # The Cloudscaling Group, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from ec2api.tests import tools XML_RESULT_TEMPLATE = ''' <%(action)sResponse xmlns="http://ec2.amazonaws.com/doc/%(api_version)s/"> %(request_id)s %(data)s ''' XML_ERROR_TEMPLATE = ''' %(code)s%(message)s %(request_id)s ''' XML_FAKE_RESULT = ''' true false 1234 fake fake fake fake fake fake ''' DICT_FAKE_RESULT_DATA = { 'fakeInfo': { 'fakeNone': None, 'fakeTrue': True, 'fakeFalse': False, 'fakeInt': 1234, 'fakeStr': 'fake', 'fakeSet': [{'fakeData': 'fake'}, {'fakeData': 'fake'}], }, 'fakeEmptySet': [], 'fakeComplexSet': [ {'fakeSubSet': [{'fakeData': 'fake'}, {'fakeData': None}]}, {'fakeSubSet': [{'fakeData': 'fake'}, {'fakeData': 'fake'}]}, ], } DICT_FAKE_RESULT = { 'FakeActionResponse': tools.update_dict( DICT_FAKE_RESULT_DATA, {'requestId': None}) } XML_SINGLE_RESULT = ''' req-8a80bb71-1e1d-49be-819f-fba429b0ddf1 pending vol-00000001 1 2014-06-04T19:55:55.448117 snap-00000001 ''' DICT_SINGLE_RESULT = { 'CreateSnapshotResponse': { 'status': 'pending', 'description': None, 'volumeId': 'vol-00000001', 'volumeSize': 1, 'progress': None, 'startTime': '2014-06-04T19:55:55.448117', 'ownerId': None, 'snapshotId': 'snap-00000001', 'requestId': 'req-8a80bb71-1e1d-49be-819f-fba429b0ddf1', } } XML_RESULT_SET = ''' req-1fc541a8-477d-4928-a90e-4448ea57ba51 77dcabaee8ea4a8fbae697ddc09afdaf true aki-00000001 available None (cirros-0.3.2-x86_64-uec-kernel) instance-store /dev/sda1 kernel cirros-0.3.2-x86_64-uec-kernel 77dcabaee8ea4a8fbae697ddc09afdaf true ari-00000002 available None (cirros-0.3.2-x86_64-uec-ramdisk) instance-store /dev/sda1 ramdisk cirros-0.3.2-x86_64-uec-ramdisk cirros-0.3.2-x86_64-uec 77dcabaee8ea4a8fbae697ddc09afdaf true ami-00000003 available instance-store None (cirros-0.3.2-x86_64-uec) aki-00000001 ari-00000002 /dev/sda1 machine 77dcabaee8ea4a8fbae697ddc09afdaf true ami-00000004 available None (Fedora-x86_64-20-20131211.1-sda) instance-store /dev/sda1 machine Fedora-x86_64-20-20131211.1-sda ''' DICT_RESULT_SET = { 'DescribeImagesResponse': { 'imagesSet': [{ 'description': None, 'imageOwnerId': '77dcabaee8ea4a8fbae697ddc09afdaf', 'isPublic': True, 'imageId': 'aki-00000001', 'imageState': 'available', 'architecture': None, 'imageLocation': 'None (cirros-0.3.2-x86_64-uec-kernel)', 'rootDeviceType': 'instance-store', 'rootDeviceName': '/dev/sda1', 'imageType': 'kernel', 'name': 'cirros-0.3.2-x86_64-uec-kernel', }, { 'description': None, 'imageOwnerId': '77dcabaee8ea4a8fbae697ddc09afdaf', 'isPublic': True, 'imageId': 'ari-00000002', 'imageState': 'available', 'architecture': None, 'imageLocation': 'None (cirros-0.3.2-x86_64-uec-ramdisk)', 'rootDeviceType': 'instance-store', 'rootDeviceName': '/dev/sda1', 'imageType': 'ramdisk', 'name': 'cirros-0.3.2-x86_64-uec-ramdisk', }, { 'name': 'cirros-0.3.2-x86_64-uec', 'imageOwnerId': '77dcabaee8ea4a8fbae697ddc09afdaf', 'isPublic': True, 'imageId': 'ami-00000003', 'imageState': 'available', 'rootDeviceType': 'instance-store', 'architecture': None, 'imageLocation': 'None (cirros-0.3.2-x86_64-uec)', 'kernelId': 'aki-00000001', 'ramdiskId': 'ari-00000002', 'rootDeviceName': '/dev/sda1', 'imageType': 'machine', 'description': None, }, { 'description': None, 'imageOwnerId': '77dcabaee8ea4a8fbae697ddc09afdaf', 'isPublic': True, 'imageId': 'ami-00000004', 'imageState': 'available', 'architecture': None, 'imageLocation': 'None (Fedora-x86_64-20-20131211.1-sda)', 'rootDeviceType': 'instance-store', 'rootDeviceName': '/dev/sda1', 'imageType': 'machine', 'name': 'Fedora-x86_64-20-20131211.1-sda', }], 'requestId': 'req-1fc541a8-477d-4928-a90e-4448ea57ba51', } } XML_EMPTY_RESULT_SET = ''' a25fa489-f97f-428a-9d30-9fcb1e9b9b65 ''' DICT_EMPTY_RESULT_SET = { 'DescribeVolumesResponse': { 'requestId': 'a25fa489-f97f-428a-9d30-9fcb1e9b9b65', 'volumeSet': [], } } XML_ERROR = ''' InvalidInstanceID.NotFound Instance i-00000001 could not be found. req-89eb083f-3c44-46e7-bc37-2c050ed7a9ce ''' DICT_ERROR = { 'Response': { 'RequestID': 'req-89eb083f-3c44-46e7-bc37-2c050ed7a9ce', 'Errors': { 'Error': { 'Code': 'InvalidInstanceID.NotFound', 'Message': 'Instance i-00000001 could not be found.', } } } } XML_SILENT_OPERATIN_RESULT = ''' req-8a80bb71-1e1d-49be-819f-fba429b0ddf1 true ''' DOTTED_FAKE_PARAMS = { 'FakeStr': 'fake', 'FakeInt': '1234', 'FakeBool': 'False', 'FakeDict.FakeKey': 'fake', 'FakeList.1.FakeElemKey': 'fake', 'FakeList.2.FakeElemKey': 'fake', 'FakeComplexList.1.FakeElemKey.1.FakeSubElemKey': 'fake', 'FakeComplexList.1.FakeElemKey.2.FakeSubElemKey': 'fake', 'FakeComplexList.1.FakeElemKeyOther': 'fake', 'FakeComplexList.2.FakeElemKey.1.FakeSubElemKey': 'fake', 'FakeComplexList.2.FakeElemKey.2.FakeSubElemKey': 'fake', 'FakeComplexList.2.FakeElemKeyOther': 'fake', } DICT_FAKE_PARAMS = { 'fake_str': 'fake', 'fake_int': 1234, 'fake_bool': False, 'fake_dict': {'fake_key': 'fake'}, 'fake_list': [{'fake_elem_key': 'fake'}, {'fake_elem_key': 'fake'}], 'fake_complex_list': [ {'fake_elem_key': [{'fake_sub_elem_key': 'fake'}, {'fake_sub_elem_key': 'fake'}], 'fake_elem_key_other': 'fake'}, {'fake_elem_key': [{'fake_sub_elem_key': 'fake'}, {'fake_sub_elem_key': 'fake'}], 'fake_elem_key_other': 'fake'}], }