Use Cinder v2 API within Generic driver

Manila uses v1 Cinder API for it's Generic driver.
Cinder v1 API is deprecated and is going to be removed,
see: https://blueprints.launchpad.net/cinder/+spec/deprecate-v1-api
So, update our Generic driver to use v2 Cinder API.

Implements blueprint v2-cinder-api-for-generic-driver

Change-Id: I3cbd713a9a4c6eccee50ba4af4bdf2794db021d7
This commit is contained in:
Valeriy Ponomaryov 2015-01-05 18:14:22 +02:00 committed by vponomaryov
parent 0dd28ab401
commit bfed689614
4 changed files with 9 additions and 11 deletions

View File

@ -246,7 +246,7 @@ class API(base.Base):
for volume in volumes:
volume_data = cinder.cinderclient(context).volumes.get(volume.id)
volume.name = volume_data.display_name
volume.name = volume_data.name
return volumes

View File

@ -26,7 +26,7 @@ from manila.volume import cinder
class Volume(object):
def __init__(self, volume_id):
self.id = volume_id
self.display_name = volume_id
self.name = volume_id
class FakeNovaClient(object):

View File

@ -28,7 +28,6 @@ class FakeVolume(object):
self.id = kwargs.pop('id', 'fake_vol_id')
self.status = kwargs.pop('status', 'available')
self.device = kwargs.pop('device', '')
self.display_name = kwargs.pop('display_name', 'fake_vol_name')
for key, value in kwargs.items():
setattr(self, key, value)
@ -40,7 +39,6 @@ class FakeVolumeSnapshot(object):
def __init__(self, **kwargs):
self.id = kwargs.pop('id', 'fake_volsnap_id')
self.status = kwargs.pop('status', 'available')
self.display_name = kwargs.pop('display_name', 'fake_volsnap_name')
for key, value in kwargs.items():
setattr(self, key, value)

View File

@ -22,7 +22,7 @@ import sys
from cinderclient import exceptions as cinder_exception
from cinderclient import service_catalog
from cinderclient.v1 import client as cinder_client
from cinderclient.v2 import client as cinder_client
from oslo.config import cfg
from manila.db import base
@ -136,8 +136,8 @@ def _untranslate_volume_summary_view(context, vol):
else:
d['attach_status'] = 'detached'
d['display_name'] = vol.display_name
d['display_description'] = vol.display_description
d['name'] = vol.name
d['description'] = vol.description
d['volume_type_id'] = vol.volume_type
d['snapshot_id'] = vol.snapshot_id
@ -161,8 +161,8 @@ def _untranslate_snapshot_summary_view(context, snapshot):
d['progress'] = snapshot.progress
d['size'] = snapshot.size
d['created_at'] = snapshot.created_at
d['display_name'] = snapshot.display_name
d['display_description'] = snapshot.display_description
d['name'] = snapshot.name
d['description'] = snapshot.description
d['volume_id'] = snapshot.volume_id
d['project_id'] = snapshot.project_id
d['volume_size'] = snapshot.size
@ -289,8 +289,8 @@ class API(base.Base):
snapshot_id = None
kwargs = dict(snapshot_id=snapshot_id,
display_name=name,
display_description=description,
name=name,
description=description,
volume_type=volume_type,
user_id=context.user_id,
project_id=context.project_id,