
A few changes necessary to make driver compatible with ScaleIO version 1.3x - refactored SIO REST calls to go through common code - obtain REST API version number dynamically - allow configuration to override what API version to use - Make API calls based upon API version - Add unit tests to validate calls to retrieve version This commit adds a new configuration option, called: sio_server_api_version - This can be used to override the value retrieved from the ScaleIO server at runtime - This is helpful for manual testing, but should not be needed in a production environment DocImpact Change-Id: I741bc5384fa3a5afcb80f52f4b39b4123e2b8e11 Closes-Bug: #1644904
101 lines
3.4 KiB
Python
101 lines
3.4 KiB
Python
# Copyright (c) 2013 - 2015 EMC Corporation.
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
import json
|
|
import requests
|
|
import six
|
|
|
|
from cinder.volume import configuration as conf
|
|
from cinder.volume.drivers.dell_emc.scaleio import driver
|
|
from oslo_config import cfg
|
|
|
|
|
|
class ScaleIODriver(driver.ScaleIODriver):
|
|
"""Mock ScaleIO Driver class.
|
|
|
|
Provides some fake configuration options
|
|
"""
|
|
def __init__(self, *args, **kwargs):
|
|
configuration = conf.Configuration(
|
|
[
|
|
cfg.StrOpt('fake'),
|
|
],
|
|
None
|
|
)
|
|
|
|
# Override the defaults to fake values
|
|
configuration.set_override('san_ip', override='127.0.0.1')
|
|
configuration.set_override('sio_rest_server_port', override='8888')
|
|
configuration.set_override('san_login', override='test')
|
|
configuration.set_override('san_password', override='pass')
|
|
configuration.set_override('sio_storage_pool_id', override='test_pool')
|
|
configuration.set_override('sio_protection_domain_id',
|
|
override='test_domain')
|
|
configuration.set_override('sio_storage_pools',
|
|
override='test_domain:test_pool')
|
|
configuration.set_override('max_over_subscription_ratio',
|
|
override=5.0)
|
|
configuration.set_override('sio_server_api_version',
|
|
override='2.0.0')
|
|
if 'san_thin_provision' in kwargs:
|
|
configuration.set_override(
|
|
'san_thin_provision',
|
|
override=kwargs['san_thin_provision'])
|
|
|
|
super(ScaleIODriver, self).__init__(configuration=configuration,
|
|
*args,
|
|
**kwargs)
|
|
|
|
def local_path(self, volume):
|
|
pass
|
|
|
|
def reenable_replication(self, context, volume):
|
|
pass
|
|
|
|
def promote_replica(self, context, volume):
|
|
pass
|
|
|
|
def create_replica_test_volume(self, volume, src_vref):
|
|
pass
|
|
|
|
def unmanage(self, volume):
|
|
pass
|
|
|
|
|
|
class MockHTTPSResponse(requests.Response):
|
|
"""Mock HTTP Response
|
|
|
|
Defines the https replies from the mocked calls to do_request()
|
|
"""
|
|
def __init__(self, content, status_code=200):
|
|
super(MockHTTPSResponse, self).__init__()
|
|
|
|
if isinstance(content, six.text_type):
|
|
content = content.encode('utf-8')
|
|
self._content = content
|
|
self.status_code = status_code
|
|
|
|
def json(self, **kwargs):
|
|
if isinstance(self._content, (bytes, six.text_type)):
|
|
return super(MockHTTPSResponse, self).json(**kwargs)
|
|
|
|
return self._content
|
|
|
|
@property
|
|
def text(self):
|
|
if not isinstance(self._content, (bytes, six.text_type)):
|
|
return json.dumps(self._content)
|
|
|
|
return super(MockHTTPSResponse, self).text
|