-
-
Save amcrn/eb57e411430638267a3d to your computer and use it in GitHub Desktop.
bug/1382881
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/trove/common/remote.py b/trove/common/remote.py | |
index 46eeef9..03b2cc3 100644 | |
--- a/trove/common/remote.py | |
+++ b/trove/common/remote.py | |
@@ -16,14 +16,16 @@ | |
from trove.common import cfg | |
from trove.common import exception | |
from trove.common import strategy | |
+from trove.openstack.common import log as logging | |
+from trove.openstack.common.gettextutils import _ | |
from trove.openstack.common.importutils import import_class | |
-from cinderclient.v2 import client as CinderClient | |
from heatclient.v1 import client as HeatClient | |
from keystoneclient.service_catalog import ServiceCatalog | |
from novaclient.v1_1.client import Client | |
from swiftclient.client import Connection | |
+LOG = logging.getLogger(__name__) | |
CONF = cfg.CONF | |
PROXY_AUTH_URL = CONF.trove_auth_url | |
@@ -117,6 +119,26 @@ def create_admin_nova_client(context): | |
def cinder_client(context): | |
+ from cinderclient.v2 import client as CinderClient | |
+ client = _cinder_client_base(context, CinderClient) | |
+ api_version = client.get_volume_api_version_from_endpoint() | |
+ if api_version != '2': | |
+ LOG.warn(_("Using Cinder v2 client, but the Cinder version from the " | |
+ "current endpoint is %s.") % api_version) | |
+ return client | |
+ | |
+ | |
+def cinder_client_v1(context): | |
+ from cinderclient.v1 import client as CinderClient | |
+ client = _cinder_client_base(context, CinderClient) | |
+ api_version = client.get_volume_api_version_from_endpoint() | |
+ if api_version != '1': | |
+ LOG.warn(_("Using Cinder v1 client, but the Cinder version from the " | |
+ "current endpoint is %s.") % api_version) | |
+ return client | |
+ | |
+ | |
+def _cinder_client_base(context, CinderClient): | |
if CONF.cinder_url: | |
url = '%(cinder_url)s%(tenant)s' % { | |
'cinder_url': normalize_url(CONF.cinder_url), | |
diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py | |
index 6f0edf9..e9694b2 100755 | |
--- a/trove/taskmanager/models.py | |
+++ b/trove/taskmanager/models.py | |
@@ -649,10 +649,22 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin): | |
def _create_volume(self, volume_size, datastore_manager): | |
LOG.debug("Begin _create_volume for id: %s" % self.id) | |
volume_client = create_cinder_client(self.context) | |
+ volume_name = "datastore-%s" % self.id | |
volume_desc = ("datastore volume for %s" % self.id) | |
- volume_ref = volume_client.volumes.create( | |
- volume_size, name="datastore-%s" % self.id, | |
- description=volume_desc, volume_type=CONF.cinder_volume_type) | |
+ | |
+ # the v1 contract of the cinder client requires display_name vs. name | |
+ # and display_description vs. description. | |
+ api_version = volume_client.get_volume_api_version_from_endpoint() | |
+ if (api_version == '1' and CONF.remote_cinder_client == | |
+ 'trove.common.remote.cinder_client_v1'): | |
+ volume_ref = volume_client.volumes.create( | |
+ volume_size, display_name=volume_name, | |
+ display_description=volume_desc, | |
+ volume_type=CONF.cinder_volume_type) | |
+ else: | |
+ volume_ref = volume_client.volumes.create( | |
+ volume_size, name=volume_name, description=volume_desc, | |
+ volume_type=CONF.cinder_volume_type) | |
# Record the volume ID in case something goes wrong. | |
self.update_db(volume_id=volume_ref.id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment