http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/storage/drivers/s3.py ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/storage/drivers/s3.py b/apache-libcloud-1.0.0rc2/libcloud/storage/drivers/s3.py deleted file mode 100644 index c4c249c..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/storage/drivers/s3.py +++ /dev/null @@ -1,1037 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -import base64 -import hmac -import time -import sys - -from hashlib import sha1 - -try: - from lxml.etree import Element, SubElement -except ImportError: - from xml.etree.ElementTree import Element, SubElement - -from libcloud.utils.py3 import httplib -from libcloud.utils.py3 import urlquote -from libcloud.utils.py3 import urlencode -from libcloud.utils.py3 import b -from libcloud.utils.py3 import tostring - -from libcloud.utils.xml import fixxpath, findtext -from libcloud.utils.files import read_in_chunks -from libcloud.common.types import InvalidCredsError, LibcloudError -from libcloud.common.base import ConnectionUserAndKey, RawResponse -from libcloud.common.aws import AWSBaseResponse, AWSDriver, \ - AWSTokenConnection, SignedAWSConnection - -from libcloud.storage.base import Object, Container, StorageDriver -from libcloud.storage.types import ContainerError -from libcloud.storage.types import ContainerIsNotEmptyError -from libcloud.storage.types import InvalidContainerNameError -from libcloud.storage.types import ContainerDoesNotExistError -from libcloud.storage.types import ObjectDoesNotExistError -from libcloud.storage.types import ObjectHashMismatchError - - -# How long before the token expires -EXPIRATION_SECONDS = 15 * 60 - -S3_US_STANDARD_HOST = 's3.amazonaws.com' -S3_US_WEST_HOST = 's3-us-west-1.amazonaws.com' -S3_US_WEST_OREGON_HOST = 's3-us-west-2.amazonaws.com' -S3_EU_WEST_HOST = 's3-eu-west-1.amazonaws.com' -S3_AP_SOUTHEAST_HOST = 's3-ap-southeast-1.amazonaws.com' -S3_AP_NORTHEAST1_HOST = 's3-ap-northeast-1.amazonaws.com' -S3_AP_NORTHEAST2_HOST = 's3-ap-northeast-2.amazonaws.com' -S3_AP_NORTHEAST_HOST = S3_AP_NORTHEAST1_HOST -S3_SA_EAST_HOST = 's3-sa-east-1.amazonaws.com' - -S3_RGW_OUTSCALE_HOSTS_BY_REGION =\ - {'eu-west-1': 'osu.eu-west-1.outscale.com', - 'eu-west-2': 'osu.eu-west-2.outscale.com', - 'us-west-1': 'osu.us-west-1.outscale.com', - 'us-east-2': 'osu.us-east-2.outscale.com', - 'cn-southeast-1': 'osu.cn-southeast-1.outscale.hk'} - -S3_RGW_OUTSCALE_DEFAULT_REGION = 'eu-west-2' - -API_VERSION = '2006-03-01' -NAMESPACE = 'http://s3.amazonaws.com/doc/%s/' % (API_VERSION) - -# AWS multi-part chunks must be minimum 5MB -CHUNK_SIZE = 5 * 1024 * 1024 - -# Desired number of items in each response inside a paginated request in -# ex_iterate_multipart_uploads. -RESPONSES_PER_REQUEST = 100 - - -class S3Response(AWSBaseResponse): - namespace = None - valid_response_codes = [httplib.NOT_FOUND, httplib.CONFLICT, - httplib.BAD_REQUEST] - - def success(self): - i = int(self.status) - return i >= 200 and i <= 299 or i in self.valid_response_codes - - def parse_error(self): - if self.status in [httplib.UNAUTHORIZED, httplib.FORBIDDEN]: - raise InvalidCredsError(self.body) - elif self.status == httplib.MOVED_PERMANENTLY: - raise LibcloudError('This bucket is located in a different ' + - 'region. Please use the correct driver.', - driver=S3StorageDriver) - raise LibcloudError('Unknown error. Status code: %d' % (self.status), - driver=S3StorageDriver) - - -class S3RawResponse(S3Response, RawResponse): - pass - - -class BaseS3Connection(ConnectionUserAndKey): - """ - Represents a single connection to the S3 Endpoint - """ - - host = 's3.amazonaws.com' - responseCls = S3Response - rawResponseCls = S3RawResponse - - @staticmethod - def get_auth_signature(method, headers, params, expires, secret_key, path, - vendor_prefix): - """ - Signature = URL-Encode( Base64( HMAC-SHA1( YourSecretAccessKeyID, - UTF-8-Encoding-Of( StringToSign ) ) ) ); - - StringToSign = HTTP-VERB + "\n" + - Content-MD5 + "\n" + - Content-Type + "\n" + - Expires + "\n" + - CanonicalizedVendorHeaders + - CanonicalizedResource; - """ - special_headers = {'content-md5': '', 'content-type': '', 'date': ''} - vendor_headers = {} - - for key, value in list(headers.items()): - key_lower = key.lower() - if key_lower in special_headers: - special_headers[key_lower] = value.strip() - elif key_lower.startswith(vendor_prefix): - vendor_headers[key_lower] = value.strip() - - if expires: - special_headers['date'] = str(expires) - - buf = [method] - for _, value in sorted(special_headers.items()): - buf.append(value) - string_to_sign = '\n'.join(buf) - - buf = [] - for key, value in sorted(vendor_headers.items()): - buf.append('%s:%s' % (key, value)) - header_string = '\n'.join(buf) - - values_to_sign = [] - for value in [string_to_sign, header_string, path]: - if value: - values_to_sign.append(value) - - string_to_sign = '\n'.join(values_to_sign) - b64_hmac = base64.b64encode( - hmac.new(b(secret_key), b(string_to_sign), digestmod=sha1).digest() - ) - return b64_hmac.decode('utf-8') - - def add_default_params(self, params): - expires = str(int(time.time()) + EXPIRATION_SECONDS) - params['AWSAccessKeyId'] = self.user_id - params['Expires'] = expires - return params - - def pre_connect_hook(self, params, headers): - params['Signature'] = self.get_auth_signature( - method=self.method, headers=headers, params=params, - expires=params['Expires'], secret_key=self.key, path=self.action, - vendor_prefix=self.driver.http_vendor_prefix) - return params, headers - - -class S3Connection(AWSTokenConnection, BaseS3Connection): - """ - Represents a single connection to the S3 endpoint, with AWS-specific - features. - """ - pass - - -class S3MultipartUpload(object): - """ - Class representing an amazon s3 multipart upload - """ - - def __init__(self, key, id, created_at, initiator, owner): - """ - Class representing an amazon s3 multipart upload - - :param key: The object/key that was being uploaded - :type key: ``str`` - - :param id: The upload id assigned by amazon - :type id: ``str`` - - :param created_at: The date/time at which the upload was started - :type created_at: ``str`` - - :param initiator: The AWS owner/IAM user who initiated this - :type initiator: ``str`` - - :param owner: The AWS owner/IAM who will own this object - :type owner: ``str`` - """ - self.key = key - self.id = id - self.created_at = created_at - self.initiator = initiator - self.owner = owner - - def __repr__(self): - return ('<S3MultipartUpload: key=%s>' % (self.key)) - - -class BaseS3StorageDriver(StorageDriver): - name = 'Amazon S3 (standard)' - website = 'http://aws.amazon.com/s3/' - connectionCls = BaseS3Connection - hash_type = 'md5' - supports_chunked_encoding = False - supports_s3_multipart_upload = True - ex_location_name = '' - namespace = NAMESPACE - http_vendor_prefix = 'x-amz' - - def iterate_containers(self): - response = self.connection.request('/') - if response.status == httplib.OK: - containers = self._to_containers(obj=response.object, - xpath='Buckets/Bucket') - return containers - - raise LibcloudError('Unexpected status code: %s' % (response.status), - driver=self) - - def list_container_objects(self, container, ex_prefix=None): - """ - Return a list of objects for the given container. - - :param container: Container instance. - :type container: :class:`Container` - - :param ex_prefix: Only return objects starting with ex_prefix - :type ex_prefix: ``str`` - - :return: A list of Object instances. - :rtype: ``list`` of :class:`Object` - """ - return list(self.iterate_container_objects(container, - ex_prefix=ex_prefix)) - - def iterate_container_objects(self, container, ex_prefix=None): - """ - Return a generator of objects for the given container. - - :param container: Container instance - :type container: :class:`Container` - - :param ex_prefix: Only return objects starting with ex_prefix - :type ex_prefix: ``str`` - - :return: A generator of Object instances. - :rtype: ``generator`` of :class:`Object` - """ - params = {} - if ex_prefix: - params['prefix'] = ex_prefix - - last_key = None - exhausted = False - container_path = self._get_container_path(container) - - while not exhausted: - if last_key: - params['marker'] = last_key - - response = self.connection.request(container_path, - params=params) - - if response.status != httplib.OK: - raise LibcloudError('Unexpected status code: %s' % - (response.status), driver=self) - - objects = self._to_objs(obj=response.object, - xpath='Contents', container=container) - is_truncated = response.object.findtext(fixxpath( - xpath='IsTruncated', namespace=self.namespace)).lower() - exhausted = (is_truncated == 'false') - - last_key = None - for obj in objects: - last_key = obj.name - yield obj - - def get_container(self, container_name): - try: - response = self.connection.request('/%s' % container_name, - method='HEAD') - if response.status == httplib.NOT_FOUND: - raise ContainerDoesNotExistError(value=None, driver=self, - container_name=container_name) - except InvalidCredsError: - # This just means the user doesn't have IAM permissions to do a - # HEAD request but other requests might work. - pass - return Container(name=container_name, extra=None, driver=self) - - def get_object(self, container_name, object_name): - container = self.get_container(container_name=container_name) - object_path = self._get_object_path(container, object_name) - response = self.connection.request(object_path, method='HEAD') - - if response.status == httplib.OK: - obj = self._headers_to_object(object_name=object_name, - container=container, - headers=response.headers) - return obj - - raise ObjectDoesNotExistError(value=None, driver=self, - object_name=object_name) - - def _get_container_path(self, container): - """ - Return a container path - - :param container: Container instance - :type container: :class:`Container` - - :return: A path for this container. - :rtype: ``str`` - """ - return '/%s' % (container.name) - - def _get_object_path(self, container, object_name): - """ - Return an object's CDN path. - - :param container: Container instance - :type container: :class:`Container` - - :param object_name: Object name - :type object_name: :class:`str` - - :return: A path for this object. - :rtype: ``str`` - """ - container_url = self._get_container_path(container) - object_name_cleaned = self._clean_object_name(object_name) - object_path = '%s/%s' % (container_url, object_name_cleaned) - return object_path - - def create_container(self, container_name): - if self.ex_location_name: - root = Element('CreateBucketConfiguration') - child = SubElement(root, 'LocationConstraint') - child.text = self.ex_location_name - - data = tostring(root) - else: - data = '' - - response = self.connection.request('/%s' % (container_name), - data=data, - method='PUT') - - if response.status == httplib.OK: - container = Container(name=container_name, extra=None, driver=self) - return container - elif response.status == httplib.CONFLICT: - raise InvalidContainerNameError( - value='Container with this name already exists. The name must ' - 'be unique among all the containers in the system', - container_name=container_name, driver=self) - elif response.status == httplib.BAD_REQUEST: - raise ContainerError( - value='Bad request when creating container: %s' % - response.body, - container_name=container_name, driver=self) - - raise LibcloudError('Unexpected status code: %s' % (response.status), - driver=self) - - def delete_container(self, container): - # Note: All the objects in the container must be deleted first - response = self.connection.request('/%s' % (container.name), - method='DELETE') - if response.status == httplib.NO_CONTENT: - return True - elif response.status == httplib.CONFLICT: - raise ContainerIsNotEmptyError( - value='Container must be empty before it can be deleted.', - container_name=container.name, driver=self) - elif response.status == httplib.NOT_FOUND: - raise ContainerDoesNotExistError(value=None, - driver=self, - container_name=container.name) - - return False - - def download_object(self, obj, destination_path, overwrite_existing=False, - delete_on_failure=True): - obj_path = self._get_object_path(obj.container, obj.name) - - response = self.connection.request(obj_path, method='GET', raw=True) - - return self._get_object(obj=obj, callback=self._save_object, - response=response, - callback_kwargs={ - 'obj': obj, - 'response': response.response, - 'destination_path': destination_path, - 'overwrite_existing': overwrite_existing, - 'delete_on_failure': delete_on_failure}, - success_status_code=httplib.OK) - - def download_object_as_stream(self, obj, chunk_size=None): - obj_path = self._get_object_path(obj.container, obj.name) - response = self.connection.request(obj_path, method='GET', raw=True) - - return self._get_object(obj=obj, callback=read_in_chunks, - response=response, - callback_kwargs={'iterator': response.response, - 'chunk_size': chunk_size}, - success_status_code=httplib.OK) - - def upload_object(self, file_path, container, object_name, extra=None, - verify_hash=True, ex_storage_class=None): - """ - @inherits: :class:`StorageDriver.upload_object` - - :param ex_storage_class: Storage class - :type ex_storage_class: ``str`` - """ - upload_func = self._upload_file - upload_func_kwargs = {'file_path': file_path} - - return self._put_object(container=container, object_name=object_name, - upload_func=upload_func, - upload_func_kwargs=upload_func_kwargs, - extra=extra, file_path=file_path, - verify_hash=verify_hash, - storage_class=ex_storage_class) - - def _upload_multipart(self, response, data, iterator, container, - object_name, calculate_hash=True): - """ - Callback invoked for uploading data to S3 using Amazon's - multipart upload mechanism - - :param response: Response object from the initial POST request - :type response: :class:`S3RawResponse` - - :param data: Any data from the initial POST request - :type data: ``str`` - - :param iterator: The generator for fetching the upload data - :type iterator: ``generator`` - - :param container: The container owning the object to which data is - being uploaded - :type container: :class:`Container` - - :param object_name: The name of the object to which we are uploading - :type object_name: ``str`` - - :keyword calculate_hash: Indicates if we must calculate the data hash - :type calculate_hash: ``bool`` - - :return: A tuple of (status, checksum, bytes transferred) - :rtype: ``tuple`` - """ - - object_path = self._get_object_path(container, object_name) - - # Get the upload id from the response xml - response.body = response.response.read() - body = response.parse_body() - upload_id = body.find(fixxpath(xpath='UploadId', - namespace=self.namespace)).text - - try: - # Upload the data through the iterator - result = self._upload_from_iterator(iterator, object_path, - upload_id, calculate_hash) - (chunks, data_hash, bytes_transferred) = result - - # Commit the chunk info and complete the upload - etag = self._commit_multipart(object_path, upload_id, chunks) - except Exception: - exc = sys.exc_info()[1] - # Amazon provides a mechanism for aborting an upload. - self._abort_multipart(object_path, upload_id) - raise exc - - # Modify the response header of the first request. This is used - # by other functions once the callback is done - response.headers['etag'] = etag - - return (True, data_hash, bytes_transferred) - - def _upload_from_iterator(self, iterator, object_path, upload_id, - calculate_hash=True): - """ - Uploads data from an iterator in fixed sized chunks to S3 - - :param iterator: The generator for fetching the upload data - :type iterator: ``generator`` - - :param object_path: The path of the object to which we are uploading - :type object_name: ``str`` - - :param upload_id: The upload id allocated for this multipart upload - :type upload_id: ``str`` - - :keyword calculate_hash: Indicates if we must calculate the data hash - :type calculate_hash: ``bool`` - - :return: A tuple of (chunk info, checksum, bytes transferred) - :rtype: ``tuple`` - """ - - data_hash = None - if calculate_hash: - data_hash = self._get_hash_function() - - bytes_transferred = 0 - count = 1 - chunks = [] - params = {'uploadId': upload_id} - - # Read the input data in chunk sizes suitable for AWS - for data in read_in_chunks(iterator, chunk_size=CHUNK_SIZE, - fill_size=True, yield_empty=True): - bytes_transferred += len(data) - - if calculate_hash: - data_hash.update(data) - - chunk_hash = self._get_hash_function() - chunk_hash.update(data) - chunk_hash = base64.b64encode(chunk_hash.digest()).decode('utf-8') - - # This provides an extra level of data check and is recommended - # by amazon - headers = {'Content-MD5': chunk_hash} - params['partNumber'] = count - - request_path = '?'.join((object_path, urlencode(params))) - - resp = self.connection.request(request_path, method='PUT', - data=data, headers=headers) - - if resp.status != httplib.OK: - raise LibcloudError('Error uploading chunk', driver=self) - - server_hash = resp.headers['etag'] - - # Keep this data for a later commit - chunks.append((count, server_hash)) - count += 1 - - if calculate_hash: - data_hash = data_hash.hexdigest() - - return (chunks, data_hash, bytes_transferred) - - def _commit_multipart(self, object_path, upload_id, chunks): - """ - Makes a final commit of the data. - - :param object_path: Server side object path. - :type object_path: ``str`` - - :param upload_id: ID of the multipart upload. - :type upload_id: ``str`` - - :param upload_id: A list of (chunk_number, chunk_hash) tuples. - :type upload_id: ``list`` - """ - - root = Element('CompleteMultipartUpload') - - for (count, etag) in chunks: - part = SubElement(root, 'Part') - part_no = SubElement(part, 'PartNumber') - part_no.text = str(count) - - etag_id = SubElement(part, 'ETag') - etag_id.text = str(etag) - - data = tostring(root) - - params = {'uploadId': upload_id} - request_path = '?'.join((object_path, urlencode(params))) - response = self.connection.request(request_path, data=data, - method='POST') - - if response.status != httplib.OK: - element = response.object - # pylint: disable=maybe-no-member - code, message = response._parse_error_details(element=element) - msg = 'Error in multipart commit: %s (%s)' % (message, code) - raise LibcloudError(msg, driver=self) - - # Get the server's etag to be passed back to the caller - body = response.parse_body() - server_hash = body.find(fixxpath(xpath='ETag', - namespace=self.namespace)).text - return server_hash - - def _abort_multipart(self, object_path, upload_id): - """ - Aborts an already initiated multipart upload - - :param object_path: Server side object path. - :type object_path: ``str`` - - :param upload_id: ID of the multipart upload. - :type upload_id: ``str`` - """ - - params = {'uploadId': upload_id} - request_path = '?'.join((object_path, urlencode(params))) - resp = self.connection.request(request_path, method='DELETE') - - if resp.status != httplib.NO_CONTENT: - raise LibcloudError('Error in multipart abort. status_code=%d' % - (resp.status), driver=self) - - def upload_object_via_stream(self, iterator, container, object_name, - extra=None, ex_storage_class=None): - """ - @inherits: :class:`StorageDriver.upload_object_via_stream` - - :param ex_storage_class: Storage class - :type ex_storage_class: ``str`` - """ - - method = 'PUT' - params = None - - # This driver is used by other S3 API compatible drivers also. - # Amazon provides a different (complex?) mechanism to do multipart - # uploads - if self.supports_s3_multipart_upload: - # Initiate the multipart request and get an upload id - upload_func = self._upload_multipart - upload_func_kwargs = {'iterator': iterator, - 'container': container, - 'object_name': object_name} - method = 'POST' - iterator = iter('') - params = 'uploads' - - elif self.supports_chunked_encoding: - upload_func = self._stream_data - upload_func_kwargs = {'iterator': iterator} - else: - # In this case, we have to load the entire object to - # memory and send it as normal data - upload_func = self._upload_data - upload_func_kwargs = {} - - return self._put_object(container=container, object_name=object_name, - upload_func=upload_func, - upload_func_kwargs=upload_func_kwargs, - extra=extra, method=method, query_args=params, - iterator=iterator, verify_hash=False, - storage_class=ex_storage_class) - - def delete_object(self, obj): - object_path = self._get_object_path(obj.container, obj.name) - response = self.connection.request(object_path, method='DELETE') - if response.status == httplib.NO_CONTENT: - return True - elif response.status == httplib.NOT_FOUND: - raise ObjectDoesNotExistError(value=None, driver=self, - object_name=obj.name) - - return False - - def ex_iterate_multipart_uploads(self, container, prefix=None, - delimiter=None): - """ - Extension method for listing all in-progress S3 multipart uploads. - - Each multipart upload which has not been committed or aborted is - considered in-progress. - - :param container: The container holding the uploads - :type container: :class:`Container` - - :keyword prefix: Print only uploads of objects with this prefix - :type prefix: ``str`` - - :keyword delimiter: The object/key names are grouped based on - being split by this delimiter - :type delimiter: ``str`` - - :return: A generator of S3MultipartUpload instances. - :rtype: ``generator`` of :class:`S3MultipartUpload` - """ - - if not self.supports_s3_multipart_upload: - raise LibcloudError('Feature not supported', driver=self) - - # Get the data for a specific container - request_path = '%s/?uploads' % (self._get_container_path(container)) - params = {'max-uploads': RESPONSES_PER_REQUEST} - - if prefix: - params['prefix'] = prefix - - if delimiter: - params['delimiter'] = delimiter - - def finder(node, text): - return node.findtext(fixxpath(xpath=text, - namespace=self.namespace)) - - while True: - response = self.connection.request(request_path, params=params) - - if response.status != httplib.OK: - raise LibcloudError('Error fetching multipart uploads. ' - 'Got code: %s' % response.status, - driver=self) - - body = response.parse_body() - # pylint: disable=maybe-no-member - for node in body.findall(fixxpath(xpath='Upload', - namespace=self.namespace)): - - initiator = node.find(fixxpath(xpath='Initiator', - namespace=self.namespace)) - owner = node.find(fixxpath(xpath='Owner', - namespace=self.namespace)) - - key = finder(node, 'Key') - upload_id = finder(node, 'UploadId') - created_at = finder(node, 'Initiated') - initiator = finder(initiator, 'DisplayName') - owner = finder(owner, 'DisplayName') - - yield S3MultipartUpload(key, upload_id, created_at, - initiator, owner) - - # Check if this is the last entry in the listing - # pylint: disable=maybe-no-member - is_truncated = body.findtext(fixxpath(xpath='IsTruncated', - namespace=self.namespace)) - - if is_truncated.lower() == 'false': - break - - # Provide params for the next request - upload_marker = body.findtext(fixxpath(xpath='NextUploadIdMarker', - namespace=self.namespace)) - key_marker = body.findtext(fixxpath(xpath='NextKeyMarker', - namespace=self.namespace)) - - params['key-marker'] = key_marker - params['upload-id-marker'] = upload_marker - - def ex_cleanup_all_multipart_uploads(self, container, prefix=None): - """ - Extension method for removing all partially completed S3 multipart - uploads. - - :param container: The container holding the uploads - :type container: :class:`Container` - - :keyword prefix: Delete only uploads of objects with this prefix - :type prefix: ``str`` - """ - - # Iterate through the container and delete the upload ids - for upload in self.ex_iterate_multipart_uploads(container, prefix, - delimiter=None): - object_path = '/%s/%s' % (container.name, upload.key) - self._abort_multipart(object_path, upload.id) - - def _clean_object_name(self, name): - name = urlquote(name) - return name - - def _put_object(self, container, object_name, upload_func, - upload_func_kwargs, method='PUT', query_args=None, - extra=None, file_path=None, iterator=None, - verify_hash=True, storage_class=None): - headers = {} - extra = extra or {} - storage_class = storage_class or 'standard' - if storage_class not in ['standard', 'reduced_redundancy']: - raise ValueError( - 'Invalid storage class value: %s' % (storage_class)) - - key = self.http_vendor_prefix + '-storage-class' - headers[key] = storage_class.upper() - - content_type = extra.get('content_type', None) - meta_data = extra.get('meta_data', None) - acl = extra.get('acl', None) - - if meta_data: - for key, value in list(meta_data.items()): - key = self.http_vendor_prefix + '-meta-%s' % (key) - headers[key] = value - - if acl: - headers[self.http_vendor_prefix + '-acl'] = acl - - request_path = self._get_object_path(container, object_name) - - if query_args: - request_path = '?'.join((request_path, query_args)) - - # TODO: Let the underlying exceptions bubble up and capture the SIGPIPE - # here. - # SIGPIPE is thrown if the provided container does not exist or the - # user does not have correct permission - result_dict = self._upload_object( - object_name=object_name, content_type=content_type, - upload_func=upload_func, upload_func_kwargs=upload_func_kwargs, - request_path=request_path, request_method=method, - headers=headers, file_path=file_path, iterator=iterator) - - response = result_dict['response'] - bytes_transferred = result_dict['bytes_transferred'] - headers = response.headers - response = response.response - server_hash = headers['etag'].replace('"', '') - - if (verify_hash and result_dict['data_hash'] != server_hash): - raise ObjectHashMismatchError( - value='MD5 hash checksum does not match', - object_name=object_name, driver=self) - elif response.status == httplib.OK: - obj = Object( - name=object_name, size=bytes_transferred, hash=server_hash, - extra={'acl': acl}, meta_data=meta_data, container=container, - driver=self) - - return obj - else: - raise LibcloudError( - 'Unexpected status code, status_code=%s' % (response.status), - driver=self) - - def _to_containers(self, obj, xpath): - for element in obj.findall(fixxpath(xpath=xpath, - namespace=self.namespace)): - yield self._to_container(element) - - def _to_objs(self, obj, xpath, container): - return [self._to_obj(element, container) for element in - obj.findall(fixxpath(xpath=xpath, namespace=self.namespace))] - - def _to_container(self, element): - extra = { - 'creation_date': findtext(element=element, xpath='CreationDate', - namespace=self.namespace) - } - - container = Container(name=findtext(element=element, xpath='Name', - namespace=self.namespace), - extra=extra, - driver=self - ) - - return container - - def _headers_to_object(self, object_name, container, headers): - hash = headers['etag'].replace('"', '') - extra = {'content_type': headers['content-type'], - 'etag': headers['etag']} - meta_data = {} - - if 'last-modified' in headers: - extra['last_modified'] = headers['last-modified'] - - for key, value in headers.items(): - if not key.lower().startswith(self.http_vendor_prefix + '-meta-'): - continue - - key = key.replace(self.http_vendor_prefix + '-meta-', '') - meta_data[key] = value - - obj = Object(name=object_name, size=headers['content-length'], - hash=hash, extra=extra, - meta_data=meta_data, - container=container, - driver=self) - return obj - - def _to_obj(self, element, container): - owner_id = findtext(element=element, xpath='Owner/ID', - namespace=self.namespace) - owner_display_name = findtext(element=element, - xpath='Owner/DisplayName', - namespace=self.namespace) - meta_data = {'owner': {'id': owner_id, - 'display_name': owner_display_name}} - last_modified = findtext(element=element, - xpath='LastModified', - namespace=self.namespace) - extra = {'last_modified': last_modified} - - obj = Object(name=findtext(element=element, xpath='Key', - namespace=self.namespace), - size=int(findtext(element=element, xpath='Size', - namespace=self.namespace)), - hash=findtext(element=element, xpath='ETag', - namespace=self.namespace).replace('"', ''), - extra=extra, - meta_data=meta_data, - container=container, - driver=self - ) - - return obj - - -class S3StorageDriver(AWSDriver, BaseS3StorageDriver): - connectionCls = S3Connection - - -class S3USWestConnection(S3Connection): - host = S3_US_WEST_HOST - - -class S3USWestStorageDriver(S3StorageDriver): - name = 'Amazon S3 (us-west-1)' - connectionCls = S3USWestConnection - ex_location_name = 'us-west-1' - - -class S3USWestOregonConnection(S3Connection): - host = S3_US_WEST_OREGON_HOST - - -class S3USWestOregonStorageDriver(S3StorageDriver): - name = 'Amazon S3 (us-west-2)' - connectionCls = S3USWestOregonConnection - ex_location_name = 'us-west-2' - - -class S3EUWestConnection(S3Connection): - host = S3_EU_WEST_HOST - - -class S3EUWestStorageDriver(S3StorageDriver): - name = 'Amazon S3 (eu-west-1)' - connectionCls = S3EUWestConnection - ex_location_name = 'EU' - - -class S3APSEConnection(S3Connection): - host = S3_AP_SOUTHEAST_HOST - - -class S3APSEStorageDriver(S3StorageDriver): - name = 'Amazon S3 (ap-southeast-1)' - connectionCls = S3APSEConnection - ex_location_name = 'ap-southeast-1' - - -class S3APNE1Connection(S3Connection): - host = S3_AP_NORTHEAST1_HOST - -S3APNEConnection = S3APNE1Connection - - -class S3APNE1StorageDriver(S3StorageDriver): - name = 'Amazon S3 (ap-northeast-1)' - connectionCls = S3APNEConnection - ex_location_name = 'ap-northeast-1' - -S3APNEStorageDriver = S3APNE1StorageDriver - - -class S3APNE2Connection(SignedAWSConnection, BaseS3Connection): - host = S3_AP_NORTHEAST2_HOST - service_name = 's3' - version = API_VERSION - - def __init__(self, user_id, key, secure=True, host=None, port=None, - url=None, timeout=None, proxy_url=None, token=None, - retry_delay=None, backoff=None): - super(S3APNE2Connection, self).__init__(user_id, key, secure, host, - port, url, timeout, proxy_url, - token, retry_delay, backoff, - 4) # force version 4 - - -class S3APNE2StorageDriver(S3StorageDriver): - name = 'Amazon S3 (ap-northeast-2)' - connectionCls = S3APNE2Connection - ex_location_name = 'ap-northeast-2' - region_name = 'ap-northeast-2' - - -class S3SAEastConnection(S3Connection): - host = S3_SA_EAST_HOST - - -class S3SAEastStorageDriver(S3StorageDriver): - name = 'Amazon S3 (sa-east-1)' - connectionCls = S3SAEastConnection - ex_location_name = 'sa-east-1' - - -class S3RGWOutscaleConnection(S3Connection): - pass - - -class S3RGWOutscaleStorageDriver(S3StorageDriver): - - def __init__(self, key, secret=None, secure=True, host=None, port=None, - api_version=None, region=S3_RGW_OUTSCALE_DEFAULT_REGION, - **kwargs): - if region not in S3_RGW_OUTSCALE_HOSTS_BY_REGION: - raise LibcloudError('Unknown region (%s)' % (region), driver=self) - self.name = 'OUTSCALE Ceph RGW S3 (%s)' % (region) - self.ex_location_name = region - self.region_name = region - self.connectionCls = S3RGWOutscaleConnection - self.connectionCls.host = S3_RGW_OUTSCALE_HOSTS_BY_REGION[region] - super(S3RGWOutscaleStorageDriver, self).__init__(key, secret, - secure, host, port, - api_version, region, - **kwargs)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/storage/providers.py ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/storage/providers.py b/apache-libcloud-1.0.0rc2/libcloud/storage/providers.py deleted file mode 100644 index eddd470..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/storage/providers.py +++ /dev/null @@ -1,77 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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 libcloud.storage.types import Provider -from libcloud.storage.types import OLD_CONSTANT_TO_NEW_MAPPING -from libcloud.common.providers import get_driver as _get_provider_driver -from libcloud.common.providers import set_driver as _set_provider_driver - -DRIVERS = { - Provider.DUMMY: - ('libcloud.storage.drivers.dummy', 'DummyStorageDriver'), - Provider.CLOUDFILES: - ('libcloud.storage.drivers.cloudfiles', 'CloudFilesStorageDriver'), - Provider.OPENSTACK_SWIFT: - ('libcloud.storage.drivers.cloudfiles', 'OpenStackSwiftStorageDriver'), - Provider.S3: - ('libcloud.storage.drivers.s3', 'S3StorageDriver'), - Provider.S3_US_WEST: - ('libcloud.storage.drivers.s3', 'S3USWestStorageDriver'), - Provider.S3_US_WEST_OREGON: - ('libcloud.storage.drivers.s3', 'S3USWestOregonStorageDriver'), - Provider.S3_EU_WEST: - ('libcloud.storage.drivers.s3', 'S3EUWestStorageDriver'), - Provider.S3_AP_SOUTHEAST: - ('libcloud.storage.drivers.s3', 'S3APSEStorageDriver'), - Provider.S3_AP_NORTHEAST: - ('libcloud.storage.drivers.s3', 'S3APNE1StorageDriver'), - Provider.S3_AP_NORTHEAST1: - ('libcloud.storage.drivers.s3', 'S3APNE1StorageDriver'), - Provider.S3_AP_NORTHEAST2: - ('libcloud.storage.drivers.s3', 'S3APNE2StorageDriver'), - Provider.S3_SA_EAST: - ('libcloud.storage.drivers.s3', 'S3SAEastStorageDriver'), - Provider.S3_RGW_OUTSCALE: - ('libcloud.storage.drivers.s3', 'S3RGWOutscaleStorageDriver'), - Provider.NINEFOLD: - ('libcloud.storage.drivers.ninefold', 'NinefoldStorageDriver'), - Provider.GOOGLE_STORAGE: - ('libcloud.storage.drivers.google_storage', 'GoogleStorageDriver'), - Provider.NIMBUS: - ('libcloud.storage.drivers.nimbus', 'NimbusStorageDriver'), - Provider.LOCAL: - ('libcloud.storage.drivers.local', 'LocalStorageDriver'), - Provider.AZURE_BLOBS: - ('libcloud.storage.drivers.azure_blobs', 'AzureBlobsStorageDriver'), - Provider.KTUCLOUD: - ('libcloud.storage.drivers.ktucloud', 'KTUCloudStorageDriver'), - Provider.AURORAOBJECTS: - ('libcloud.storage.drivers.auroraobjects', 'AuroraObjectsStorageDriver'), - Provider.BACKBLAZE_B2: - ('libcloud.storage.drivers.backblaze_b2', 'BackblazeB2StorageDriver'), - Provider.ALIYUN_OSS: - ('libcloud.storage.drivers.oss', 'OSSStorageDriver'), -} - - -def get_driver(provider): - deprecated_constants = OLD_CONSTANT_TO_NEW_MAPPING - return _get_provider_driver(drivers=DRIVERS, provider=provider, - deprecated_constants=deprecated_constants) - - -def set_driver(provider, module, klass): - return _set_provider_driver(drivers=DRIVERS, provider=provider, - module=module, klass=klass) http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/storage/types.py ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/storage/types.py b/apache-libcloud-1.0.0rc2/libcloud/storage/types.py deleted file mode 100644 index ea8f645..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/storage/types.py +++ /dev/null @@ -1,141 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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 libcloud.common.types import LibcloudError - -__all__ = [ - 'Provider', - 'ContainerError', - 'ObjectError', - 'ContainerAlreadyExistsError', - 'ContainerDoesNotExistError', - 'ContainerIsNotEmptyError', - 'ObjectDoesNotExistError', - 'ObjectHashMismatchError', - 'InvalidContainerNameError', - - 'OLD_CONSTANT_TO_NEW_MAPPING' -] - - -class Provider(object): - """ - Defines for each of the supported providers - - :cvar DUMMY: Example provider - :cvar CLOUDFILES: CloudFiles - :cvar S3: Amazon S3 US - :cvar S3_US_WEST: Amazon S3 US West (Northern California) - :cvar S3_EU_WEST: Amazon S3 EU West (Ireland) - :cvar S3_AP_SOUTHEAST_HOST: Amazon S3 Asia South East (Singapore) - :cvar S3_AP_NORTHEAST_HOST: Amazon S3 Asia South East (Tokyo) - :cvar S3_RGW_OUTSCALE: OUTSCALE RGW S3 - :cvar NINEFOLD: Ninefold - :cvar GOOGLE_STORAGE Google Storage - :cvar S3_US_WEST_OREGON: Amazon S3 US West 2 (Oregon) - :cvar NIMBUS: Nimbus.io driver - :cvar LOCAL: Local storage driver - :cvar AURORAOBJECTS: AuroraObjects storage driver - :cvar ALIYUN_OSS: Aliyun OSS storage driver - """ - DUMMY = 'dummy' - S3 = 's3' - S3_US_WEST = 's3_us_west' - S3_EU_WEST = 's3_eu_west' - S3_AP_SOUTHEAST = 's3_ap_southeast' - S3_AP_NORTHEAST = 's3_ap_northeast' - S3_AP_NORTHEAST1 = 's3_ap_northeast_1' - S3_AP_NORTHEAST2 = 's3_ap_northeast_2' - S3_SA_EAST = 's3_sa_east' - S3_RGW_OUTSCALE = 's3_rgw_outscale' - NINEFOLD = 'ninefold' - GOOGLE_STORAGE = 'google_storage' - S3_US_WEST_OREGON = 's3_us_west_oregon' - NIMBUS = 'nimbus' - LOCAL = 'local' - OPENSTACK_SWIFT = 'openstack_swift' - CLOUDFILES = 'cloudfiles' - AZURE_BLOBS = 'azure_blobs' - KTUCLOUD = 'ktucloud' - AURORAOBJECTS = 'auroraobjects' - BACKBLAZE_B2 = 'backblaze_b2' - ALIYUN_OSS = 'aliyun_oss' - - # Deperecated - CLOUDFILES_US = 'cloudfiles_us' - CLOUDFILES_UK = 'cloudfiles_uk' - CLOUDFILES_SWIFT = 'cloudfiles_swift' - - -OLD_CONSTANT_TO_NEW_MAPPING = { - # CloudFiles - Provider.CLOUDFILES_US: Provider.CLOUDFILES, - Provider.CLOUDFILES_UK: Provider.CLOUDFILES_UK, - Provider.CLOUDFILES_SWIFT: Provider.OPENSTACK_SWIFT -} - - -class ContainerError(LibcloudError): - error_type = 'ContainerError' - - def __init__(self, value, driver, container_name): - self.container_name = container_name - super(ContainerError, self).__init__(value=value, driver=driver) - - def __str__(self): - return ('<%s in %s, container=%s, value=%s>' % - (self.error_type, repr(self.driver), - self.container_name, self.value)) - - -class ObjectError(LibcloudError): - error_type = 'ContainerError' - - def __init__(self, value, driver, object_name): - self.object_name = object_name - super(ObjectError, self).__init__(value=value, driver=driver) - - def __str__(self): - return self.__repr__() - - def __repr__(self): - return '<%s in %s, value=%s, object = %s>' % (self.error_type, - repr(self.driver), - self.value, - self.object_name) - - -class ContainerAlreadyExistsError(ContainerError): - error_type = 'ContainerAlreadyExistsError' - - -class ContainerDoesNotExistError(ContainerError): - error_type = 'ContainerDoesNotExistError' - - -class ContainerIsNotEmptyError(ContainerError): - error_type = 'ContainerIsNotEmptyError' - - -class ObjectDoesNotExistError(ObjectError): - error_type = 'ObjectDoesNotExistError' - - -class ObjectHashMismatchError(ObjectError): - error_type = 'ObjectHashMismatchError' - - -class InvalidContainerNameError(ContainerError): - error_type = 'InvalidContainerNameError' http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/__init__.py ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/__init__.py b/apache-libcloud-1.0.0rc2/libcloud/test/__init__.py deleted file mode 100644 index 747b02c..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/__init__.py +++ /dev/null @@ -1,353 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -import sys -import random - -from libcloud.utils.py3 import httplib -from libcloud.utils.py3 import StringIO -from libcloud.utils.py3 import urlparse -from libcloud.utils.py3 import parse_qs -from libcloud.utils.py3 import parse_qsl -from libcloud.utils.py3 import u -from libcloud.utils.py3 import unittest2_required - -if unittest2_required: - import unittest2 as unittest -else: - import unittest - - -XML_HEADERS = {'content-type': 'application/xml'} - - -class LibcloudTestCase(unittest.TestCase): - def __init__(self, *args, **kwargs): - self._visited_urls = [] - self._executed_mock_methods = [] - super(LibcloudTestCase, self).__init__(*args, **kwargs) - - def setUp(self): - self._visited_urls = [] - self._executed_mock_methods = [] - - def _add_visited_url(self, url): - self._visited_urls.append(url) - - def _add_executed_mock_method(self, method_name): - self._executed_mock_methods.append(method_name) - - def assertExecutedMethodCount(self, expected): - actual = len(self._executed_mock_methods) - self.assertEqual(actual, expected, - 'expected %d, but %d mock methods were executed' - % (expected, actual)) - - -class multipleresponse(object): - """ - A decorator that allows MockHttp objects to return multi responses - """ - count = 0 - func = None - - def __init__(self, f): - self.func = f - - def __call__(self, *args, **kwargs): - ret = self.func(self.func.__class__, *args, **kwargs) - response = ret[self.count] - self.count = self.count + 1 - return response - - -class MockResponse(object): - """ - A mock HTTPResponse - """ - headers = {} - body = StringIO() - status = 0 - reason = '' - version = 11 - - def __init__(self, status, body=None, headers=None, reason=None): - self.status = status - self.body = StringIO(u(body)) if body else StringIO() - self.headers = headers or self.headers - self.reason = reason or self.reason - - def read(self, *args, **kwargs): - return self.body.read(*args, **kwargs) - - def next(self): - if sys.version_info >= (2, 5) and sys.version_info <= (2, 6): - return self.body.next() - else: - return next(self.body) - - def __next__(self): - return self.next() - - def getheader(self, name, *args, **kwargs): - return self.headers.get(name, *args, **kwargs) - - def getheaders(self): - return list(self.headers.items()) - - def msg(self): - raise NotImplemented - - -class BaseMockHttpObject(object): - def _get_method_name(self, type, use_param, qs, path): - path = path.split('?')[0] - meth_name = path.replace('/', '_').replace('.', '_').replace('-', '_') - - if type: - meth_name = '%s_%s' % (meth_name, self.type) - - if use_param and use_param in qs: - param = qs[use_param][0].replace('.', '_').replace('-', '_') - meth_name = '%s_%s' % (meth_name, param) - - if meth_name == '': - meth_name = 'root' - - return meth_name - - -class MockHttp(BaseMockHttpObject): - """ - A mock HTTP client/server suitable for testing purposes. This replaces - `HTTPConnection` by implementing its API and returning a mock response. - - Define methods by request path, replacing slashes (/) with underscores (_). - Each of these mock methods should return a tuple of: - - (int status, str body, dict headers, str reason) - - >>> mock = MockHttp('localhost', 8080) - >>> mock.request('GET', '/example/') - >>> response = mock.getresponse() - >>> response.body.read() - 'Hello World!' - >>> response.status - 200 - >>> response.getheaders() - [('X-Foo', 'libcloud')] - >>> MockHttp.type = 'fail' - >>> mock.request('GET', '/example/') - >>> response = mock.getresponse() - >>> response.body.read() - 'Oh Noes!' - >>> response.status - 403 - >>> response.getheaders() - [('X-Foo', 'fail')] - - """ - responseCls = MockResponse - host = None - port = None - response = None - - type = None - use_param = None # will use this param to namespace the request function - - test = None # TestCase instance which is using this mock - - proxy_url = None - - def __init__(self, host, port, *args, **kwargs): - self.host = host - self.port = port - - def request(self, method, url, body=None, headers=None, raw=False): - # Find a method we can use for this request - parsed = urlparse.urlparse(url) - scheme, netloc, path, params, query, fragment = parsed - qs = parse_qs(query) - if path.endswith('/'): - path = path[:-1] - meth_name = self._get_method_name(type=self.type, - use_param=self.use_param, - qs=qs, path=path) - meth = getattr(self, meth_name.replace('%', '_')) - - if self.test and isinstance(self.test, LibcloudTestCase): - self.test._add_visited_url(url=url) - self.test._add_executed_mock_method(method_name=meth_name) - - status, body, headers, reason = meth(method, url, body, headers) - self.response = self.responseCls(status, body, headers, reason) - - def getresponse(self): - return self.response - - def connect(self): - """ - Can't think of anything to mock here. - """ - pass - - def close(self): - pass - - def set_http_proxy(self, proxy_url): - self.proxy_url = proxy_url - - # Mock request/response example - def _example(self, method, url, body, headers): - """ - Return a simple message and header, regardless of input. - """ - return (httplib.OK, 'Hello World!', {'X-Foo': 'libcloud'}, - httplib.responses[httplib.OK]) - - def _example_fail(self, method, url, body, headers): - return (httplib.FORBIDDEN, 'Oh Noes!', {'X-Foo': 'fail'}, - httplib.responses[httplib.FORBIDDEN]) - - -class MockHttpTestCase(MockHttp, unittest.TestCase): - # Same as the MockHttp class, but you can also use assertions in the - # classes which inherit from this one. - def __init__(self, *args, **kwargs): - unittest.TestCase.__init__(self) - - if kwargs.get('host', None) and kwargs.get('port', None): - MockHttp.__init__(self, *args, **kwargs) - - def runTest(self): - pass - - def assertUrlContainsQueryParams(self, url, expected_params, strict=False): - """ - Assert that provided url contains provided query parameters. - - :param url: URL to assert. - :type url: ``str`` - - :param expected_params: Dictionary of expected query parameters. - :type expected_params: ``dict`` - - :param strict: Assert that provided url contains only expected_params. - (defaults to ``False``) - :type strict: ``bool`` - """ - question_mark_index = url.find('?') - - if question_mark_index != -1: - url = url[question_mark_index + 1:] - - params = dict(parse_qsl(url)) - - if strict: - self.assertDictEqual(params, expected_params) - else: - for key, value in expected_params.items(): - self.assertEqual(params[key], value) - - -class StorageMockHttp(MockHttp): - def putrequest(self, method, action, skip_host=0, skip_accept_encoding=0): - pass - - def putheader(self, key, value): - pass - - def endheaders(self): - pass - - def send(self, data): - pass - - -class MockRawResponse(BaseMockHttpObject): - """ - Mock RawResponse object suitable for testing. - """ - - type = None - responseCls = MockResponse - - def __init__(self, connection): - super(MockRawResponse, self).__init__() - self._data = [] - self._current_item = 0 - - self._status = None - self._response = None - self._headers = None - self._reason = None - self.connection = connection - - def next(self): - if self._current_item == len(self._data): - raise StopIteration - - value = self._data[self._current_item] - self._current_item += 1 - return value - - def __next__(self): - return self.next() - - def _generate_random_data(self, size): - data = '' - current_size = 0 - while current_size < size: - value = str(random.randint(0, 9)) - value_size = len(value) - data += value - current_size += value_size - - return data - - @property - def response(self): - return self._get_response_if_not_availale() - - @property - def status(self): - self._get_response_if_not_availale() - return self._status - - @property - def headers(self): - self._get_response_if_not_availale() - return self._headers - - @property - def reason(self): - self._get_response_if_not_availale() - return self._reason - - def _get_response_if_not_availale(self): - if not self._response: - meth_name = self._get_method_name(type=self.type, - use_param=False, qs=None, - path=self.connection.action) - meth = getattr(self, meth_name.replace('%', '_')) - result = meth(self.connection.method, None, None, None) - self._status, self._body, self._headers, self._reason = result - self._response = self.responseCls(self._status, self._body, - self._headers, self._reason) - return self._response - -if __name__ == "__main__": - import doctest - doctest.testmod() http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/__init__.py ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/__init__.py b/apache-libcloud-1.0.0rc2/libcloud/test/backup/__init__.py deleted file mode 100644 index 007c333..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/__init__.py +++ /dev/null @@ -1,36 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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 libcloud.backup.base import BackupTarget, BackupTargetType - - -class TestCaseMixin(object): - - def get_supported_target_types(self): - targets = self.driver.get_supported_target_types() - self.assertTrue(isinstance(targets, list)) - for target in targets: - self.assertTrue(isinstance(target, BackupTargetType)) - - def test_list_targets_response(self): - targets = self.driver.list_targets() - self.assertTrue(isinstance(targets, list)) - for target in targets: - self.assertTrue(isinstance(target, BackupTarget)) - - -if __name__ == "__main__": - import doctest - doctest.testmod() http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client.xml deleted file mode 100644 index 4ce51c6..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns6:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/admin" xmlns:ns14="http://oec.api.opsource.net/schemas/directory" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/backup" xmlns:ns5="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns12="http://oec.api.opsource.net/schemas/support" xmlns:ns13="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns6="http://oec.api.opsource.net/schemas/general" xmlns:ns7="http://oec.api.opsource.net/schemas/reset" xmlns:ns10="http://oec.api.opsource.net/schemas/server" xmlns:ns8="http://oec.api.opsource.net/schemas/network" xmlns:ns11="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns2="http://oec.api.opsource.net/schemas/organization" xmlns:ns4="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns3="http://oec.api.opsource.net/schemas/vip"> - <ns6:operation>Disable Backup Client</ns6:operation> - <ns6:result>SUCCESS</ns6:result> - <ns6:resultDetail>Backup Client disabled</ns6:resultDetail> - <ns6:resultCode>REASON_0</ns6:resultCode> -</ns6:Status> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client_FAIL.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client_FAIL.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client_FAIL.xml deleted file mode 100644 index 6c2db63..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/_remove_backup_client_FAIL.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns6:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/admin" xmlns:ns14="http://oec.api.opsource.net/schemas/directory" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/backup" xmlns:ns5="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns12="http://oec.api.opsource.net/schemas/support" xmlns:ns13="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns6="http://oec.api.opsource.net/schemas/general" xmlns:ns7="http://oec.api.opsource.net/schemas/reset" xmlns:ns10="http://oec.api.opsource.net/schemas/server" xmlns:ns8="http://oec.api.opsource.net/schemas/network" xmlns:ns11="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns2="http://oec.api.opsource.net/schemas/organization" xmlns:ns4="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns3="http://oec.api.opsource.net/schemas/vip"> - <ns6:operation>Disable Backup Client</ns6:operation> - <ns6:result>ERROR</ns6:result> - <ns6:resultDetail>DISABLE_BACKUP_CLIENT 'didata-backup-test6[172-16-1-14]' - failed - Unexpected error occurred with NA9 Backup system at 2016-02-12 00:03:50.952, TransactionId: (9d483a7a-1cc9-441b-920c-e11fb0e94ba6), PCSOperation: DeprovisionBackupClient, Backup Client is currently performing another operation: Backup client is currently busy</ns6:resultDetail> - <ns6:resultCode>REASON_547</ns6:resultCode> -</ns6:Status> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml deleted file mode 100644 index c3d607f..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="utf-8" standalone="yes"?> -<servers xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="2" totalCount="2" pageSize="250"> - <!-- MCP 1.0 Server --> - <server id="e75ead52-692f-4314-8725-c8a4f4d13a87" datacenterId="NA1"> - <name>Production Web Server MCP 1</name> - <description>nopassword0</description> - <operatingSystem id="REDHAT632" displayName="REDHAT6/32" family="UNIX" /> - <cpu count="4" speed="STANDARD" coresPerSocket="1" /> - <memoryGb>2</memoryGb> - <disk id="74f81c56-96cc-4cca-b4d7-a88f641a6ea2" scsiId="0" sizeGb="10" speed="STANDARD" state="NORMAL" /> - <nic id="43b24e9e-c1c9-4d53-965b-89bcaa725103" privateIpv4="10.160.117.25" networkId="c550be0e-65c1-11e4-811f-005056806999" networkName="Test1" state="NORMAL" /> - <backup assetId="5579f3a7-4c32-4cf5-8a7e-b45c36a35c10" servicePlan="Enterprise" state="NORMAL" /> - <monitoring monitoringId="11049" servicePlan="ESSENTIALS" state="NORMAL" /> - <sourceImageId>e9ec6eb4-4634-49de-b914-01eb74da5fb9</sourceImageId> - <createTime>2015-08-11T16:51:05.000Z</createTime> - <deployed>true</deployed> - <started>true</started> - <state>NORMAL</state> - <vmwareTools versionStatus="NEED_UPGRADE" runningStatus="RUNNING" apiVersion="8389" /> - <virtualHardware version="vmx-08" upToDate="false" /> - </server> - <!-- MCP 2.0 Server --> - <server id="5a32d6e4-9707-4813-a269-56ab4d989f4d" datacenterId="NA9"> - <name>Production Web Server MCP 2</name> - <description>Server to host our main web application.</description> - <operatingSystem id="WIN2008S32" displayName="WIN2008S/32" family="WINDOWS" /> - <cpu count="2" speed="STANDARD" coresPerSocket="1" /> - <memoryGb>4</memoryGb> - <disk id="c2e1f199-116e-4dbc-9960-68720b832b0a" scsiId="0" sizeGb="50" speed="STANDARD" state="NORMAL" /> - <networkInfo networkDomainId="553f26b6-2a73-42c3-a78b-6116f11291d0"> - <primaryNic id="5e869800-df7b-4626-bcbf-8643b8be11fd" privateIpv4="10.0.4.8" ipv6="2607:f480:1111:1282:2960:fb72:7154:6160" vlanId="bc529e20-dc6f-42ba-be20-0ffe44d1993f" vlanName="Production VLAN" state="NORMAL" /> - </networkInfo> - <backup assetId="91002e08-8dc1-47a1-ad33-04f501c06f87" servicePlan="Advanced" state="NORMAL" /> - <monitoring monitoringId="11039" servicePlan="ESSENTIALS" state="NORMAL" /> - <softwareLabel>MSSQL2008R2S</softwareLabel> - <sourceImageId>3ebf3c0f-90fe-4a8b-8585-6e65b316592c</sourceImageId> - <createTime>2015-12-02T10:31:33.000Z</createTime> - <deployed>true</deployed> - <started>true</started> - <state>PENDING_CHANGE</state> - <progress> - <action>SHUTDOWN_SERVER</action> - <requestTime>2015-12-02T11:07:40.000Z</requestTime> - <userName>devuser1</userName> - </progress> - <vmwareTools versionStatus="CURRENT" runningStatus="RUNNING" apiVersion="9354" /> - <virtualHardware version="vmx-08" upToDate="false" /> - </server> -</servers> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87.xml deleted file mode 100644 index 07b1319..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<server xmlns="urn:didata.com:api:cloud:types" id="e75ead52-692f-4314-8725-c8a4f4d13a87" datacenterId="NA9"> - <name>Production Web Server</name> - <description>Server to host our main web application.</description> - <operatingSystem id="WIN2008S32" displayName="WIN2008S/32" family="WINDOWS" /> - <cpu count="2" speed="STANDARD" coresPerSocket="1" /> - <memoryGb>4</memoryGb> - <disk id="c2e1f199-116e-4dbc-9960-68720b832b0a" scsiId="0" sizeGb="50" speed="STANDARD" state="NORMAL" /> - <networkInfo networkDomainId="553f26b6-2a73-42c3-a78b-6116f11291d0"> - <primaryNic id="5e869800-df7b-4626-bcbf-8643b8be11fd" privateIpv4="10.0.4.8" ipv6="2607:f480:1111:1282:2960:fb72:7154:6160" vlanId="bc529e20-dc6f-42ba-be20-0ffe44d1993f" vlanName="Production VLAN" state="NORMAL" /> - </networkInfo> - <backup assetId="5579f3a7-4c32-4cf5-8a7e-b45c36a35c10" servicePlan="Essentials" state="NORMAL" /> - <monitoring monitoringId="11049" servicePlan="ESSENTIALS" state="NORMAL" /> - <softwareLabel>MSSQL2008R2S</softwareLabel> - <sourceImageId>3ebf3c0f-90fe-4a8b-8585-6e65b316592c</sourceImageId> - <createTime>2015-12-02T10:31:33.000Z</createTime> - <deployed>true</deployed> - <started>true</started> - <state>PENDING_CHANGE</state> - <progress> - <action>DEPLOY_SERVER</action> - <requestTime>2015-12-02T11:07:40.000Z</requestTime> - <userName>devuser1</userName> - </progress> - <vmwareTools versionStatus="CURRENT" runningStatus="RUNNING" apiVersion="9354" /> - <virtualHardware version="vmx-08" upToDate="false" /> - </server> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87_DEFAULT.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87_DEFAULT.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87_DEFAULT.xml deleted file mode 100644 index c64c530..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/caas_2_1_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_server_e75ead52_692f_4314_8725_c8a4f4d13a87_DEFAULT.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<server xmlns="urn:didata.com:api:cloud:types" id="e75ead52-692f-4314-8725-c8a4f4d13a87" datacenterId="NA9"> - <name>Production Web Server</name> - <description>Server to host our main web application.</description> - <operatingSystem id="WIN2008S32" displayName="WIN2008S/32" family="WINDOWS" /> - <cpu count="2" speed="STANDARD" coresPerSocket="1" /> - <memoryGb>4</memoryGb> - <disk id="c2e1f199-116e-4dbc-9960-68720b832b0a" scsiId="0" sizeGb="50" speed="STANDARD" state="NORMAL" /> - <networkInfo networkDomainId="553f26b6-2a73-42c3-a78b-6116f11291d0"> - <primaryNic id="5e869800-df7b-4626-bcbf-8643b8be11fd" privateIpv4="10.0.4.8" ipv6="2607:f480:1111:1282:2960:fb72:7154:6160" vlanId="bc529e20-dc6f-42ba-be20-0ffe44d1993f" vlanName="Production VLAN" state="NORMAL" /> - </networkInfo> - <backup assetId="5579f3a7-4c32-4cf5-8a7e-b45c36a35c10" servicePlan="Advanced" state="NORMAL" /> - <monitoring monitoringId="11049" servicePlan="ESSENTIALS" state="NORMAL" /> - <softwareLabel>MSSQL2008R2S</softwareLabel> - <sourceImageId>3ebf3c0f-90fe-4a8b-8585-6e65b316592c</sourceImageId> - <createTime>2015-12-02T10:31:33.000Z</createTime> - <deployed>true</deployed> - <started>true</started> - <state>PENDING_CHANGE</state> - <progress> - <action>DEPLOY_SERVER</action> - <requestTime>2015-12-02T11:07:40.000Z</requestTime> - <userName>devuser1</userName> - </progress> - <vmwareTools versionStatus="CURRENT" runningStatus="RUNNING" apiVersion="9354" /> - <virtualHardware version="vmx-08" upToDate="false" /> - </server> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_DISABLE.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_DISABLE.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_DISABLE.xml deleted file mode 100644 index bfc949d..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_DISABLE.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns13:Status xmlns:ns16="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns="http://oec.api.opsource.net/schemas/server" xmlns:ns14="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns15="http://oec.api.opsource.net/schemas/reset" xmlns:ns9="http://oec.api.opsource.net/schemas/storage" xmlns:ns5="http://oec.api.opsource.net/schemas/backup" xmlns:ns12="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns13="http://oec.api.opsource.net/schemas/general" xmlns:ns6="http://oec.api.opsource.net/schemas/support" xmlns:ns7="http://oec.api.opsource.net/schemas/organization" xmlns:ns10="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns8="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns11="http://oec.api.opsource.net/schemas/vip" xmlns:ns2="http://oec.api.opsource.net/schemas/network" xmlns:ns4="http://oec.api.opsource.net/schemas/directory" xmlns:ns3="http://oec.api.opsource.net/schemas/admin"> - <ns13:operation>Disable Backup for Server</ns13:operation> - <ns13:result>SUCCESS</ns13:result> - <ns13:resultDetail>Backup disabled for Server</ns13:resultDetail> - <ns13:resultCode>REASON_0</ns13:resultCode> -</ns13:Status> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_ENABLE.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_ENABLE.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_ENABLE.xml deleted file mode 100644 index 6012447..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_ENABLE.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns6:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" - xmlns="http://oec.api.opsource.net/schemas/server" - xmlns:ns14="http://oec.api.opsource.net/schemas/support" - xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" - xmlns:ns9="http://oec.api.opsource.net/schemas/admin" - xmlns:ns5="http://oec.api.opsource.net/schemas/vip" - xmlns:ns12="http://oec.api.opsource.net/schemas/whitelabel" - xmlns:ns13="http://oec.api.opsource.net/schemas/reset" - xmlns:ns6="http://oec.api.opsource.net/schemas/general" xmlns:ns7="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns10="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns8="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns11="http://oec.api.opsource.net/schemas/backup" xmlns:ns2="http://oec.api.opsource.net/schemas/directory" xmlns:ns4="http://oec.api.opsource.net/schemas/network" xmlns:ns3="http://oec.api.opsource.net/schemas/organization"> - <ns6:operation>Enable Backup for Server</ns6:operation> - <ns6:result>SUCCESS</ns6:result> - <ns6:resultDetail>Backup enabled for Server - see additional Information for Asset ID</ns6:resultDetail> - <ns6:resultCode>REASON_0</ns6:resultCode> - <ns6:additionalInformation name="assetId"> - <ns6:value>ee7c4b64-f7af-4a4f-8384-be362273530f</ns6:value> - </ns6:additionalInformation> -</ns6:Status> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_EXISTS.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_EXISTS.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_EXISTS.xml deleted file mode 100644 index 5ffa67e..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_EXISTS.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns0:Status xmlns:ns0="http://oec.api.opsource.net/schemas/general"> - <ns0:operation>Enable Backup for Server</ns0:operation> - <ns0:result>ERROR</ns0:result> - <ns0:resultDetail>Cloud backup for this server is already enabled or being enabled (state: NORMAL).</ns0:resultDetail> - <ns0:resultCode>REASON_550</ns0:resultCode> -</ns0:Status> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO.xml deleted file mode 100644 index fc61cce..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns9:BackupDetails assetId="12769311-938c-4669-9460-7723eb194269" servicePlan="Enterprise" state="NORMAL" xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/admin" xmlns:ns14="http://oec.api.opsource.net/schemas/directory" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/backup" xmlns:ns5="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns12="http://oec.api.opsource.net/schemas/support" xmlns:ns13="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns6="http://oec.api.opsource.net/schemas/general" xmlns:ns7="http://oec.api.opsource.net/schemas/reset" xmlns:ns10="http://oec.api.opsource.net/schemas/server" xmlns:ns8="http://oec.api.opsource.net/schemas/network" xmlns:ns11="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns2="http://oec.api.opsource.net/schemas/organization" xmlns:ns4="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns3="http://oec.api.o psource.net/schemas/vip"> - <ns9:backupClient id="30b1ff76-c76d-4d7c-b39d-3b72be0384c8" type="FA.Linux" isFileSystem="true" status="Unregistered"> - <ns9:description>Linux File Agent</ns9:description> - <ns9:schedulePolicyName>12AM - 6AM</ns9:schedulePolicyName> - <ns9:storagePolicyName>14 Day Storage Policy</ns9:storagePolicyName> - <ns9:alerting trigger="ON_FAILURE"> - <ns9:emailAddress>fake_em...@example.com</ns9:emailAddress> - <ns9:emailAddress>fake_ema...@example.com</ns9:emailAddress> - </ns9:alerting> - <ns9:times nextBackup="2016-02-09T00:00:00" lastOnline="2016-02-08T06:10:25"/> - <ns9:totalBackupSizeGb>0</ns9:totalBackupSizeGb> - <ns9:downloadUrl>https://backups-na.cloud-vpn.net/PCS/BackupClientInstallerDownload/cbb8a8c607ca4144e8828814edfc1634c8dd8782</ns9:downloadUrl> - <ns9:runningJob id="106130" name="Backup" percentageComplete="5" status="Waiting"/> - </ns9:backupClient> -</ns9:BackupDetails> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_DISABLED.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_DISABLED.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_DISABLED.xml deleted file mode 100644 index 51e4494..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_DISABLED.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns6:Status xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/admin" xmlns:ns14="http://oec.api.opsource.net/schemas/directory" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/backup" xmlns:ns5="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns12="http://oec.api.opsource.net/schemas/support" xmlns:ns13="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns6="http://oec.api.opsource.net/schemas/general" xmlns:ns7="http://oec.api.opsource.net/schemas/reset" xmlns:ns10="http://oec.api.opsource.net/schemas/server" xmlns:ns8="http://oec.api.opsource.net/schemas/network" xmlns:ns11="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns2="http://oec.api.opsource.net/schemas/organization" xmlns:ns4="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns3="http://oec.api.opsource.net/schemas/vip"> - <ns6:operation>Get Backup Details</ns6:operation> - <ns6:result>ERROR</ns6:result> - <ns6:resultDetail>Server e75ead52-692f-4314-8725-c8a4f4d13a87 has not been provisioned for backup</ns6:resultDetail> - <ns6:resultCode>REASON_543</ns6:resultCode> -</ns6:Status> http://git-wip-us.apache.org/repos/asf/libcloud/blob/8afcda91/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_NOCLIENT.xml ---------------------------------------------------------------------- diff --git a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_NOCLIENT.xml b/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_NOCLIENT.xml deleted file mode 100644 index 0f62576..0000000 --- a/apache-libcloud-1.0.0rc2/libcloud/test/backup/fixtures/dimensiondata/oec_0_9_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server_e75ead52_692f_4314_8725_c8a4f4d13a87_backup_INFO_NOCLIENT.xml +++ /dev/null @@ -1,2 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<ns9:BackupDetails assetId="71febbbc-337a-40c4-8c29-0afe85ccb3ea" servicePlan="Essentials" state="NORMAL" xmlns:ns16="http://oec.api.opsource.net/schemas/storage" xmlns="http://oec.api.opsource.net/schemas/admin" xmlns:ns14="http://oec.api.opsource.net/schemas/directory" xmlns:ns15="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns9="http://oec.api.opsource.net/schemas/backup" xmlns:ns5="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns12="http://oec.api.opsource.net/schemas/support" xmlns:ns13="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns6="http://oec.api.opsource.net/schemas/general" xmlns:ns7="http://oec.api.opsource.net/schemas/reset" xmlns:ns10="http://oec.api.opsource.net/schemas/server" xmlns:ns8="http://oec.api.opsource.net/schemas/network" xmlns:ns11="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns2="http://oec.api.opsource.net/schemas/organization" xmlns:ns4="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns3="http://oec.api.o psource.net/schemas/vip"/>