32
32
from oslo_concurrency import lockutils
33
33
from oslo_config import cfg
34
34
from oslo_db import exception as db_exc
35
+ from oslo_log import log as logging
35
36
import oslo_messaging as messaging
36
37
from oslo_messaging import conffixture as messaging_conffixture
37
38
from oslo_privsep import daemon as privsep_daemon
69
70
DB_SCHEMA = {'main' : "" , 'api' : "" }
70
71
SESSION_CONFIGURED = False
71
72
73
+ LOG = logging .getLogger (__name__ )
74
+
72
75
73
76
class ServiceFixture (fixtures .Fixture ):
74
77
"""Run a service as a test fixture."""
@@ -1947,18 +1950,26 @@ def fake_attachment_create(_self, context, volume_id, instance_uuid,
1947
1950
attachment = {'id' : attachment_id , 'connection_info' : {'data' : {}}}
1948
1951
self .volume_to_attachment [volume_id ].append (
1949
1952
(attachment_id , instance_uuid ))
1953
+ LOG .info ('Created attachment %s for volume %s. Total '
1954
+ 'attachments for volume: %d' , attachment_id , volume_id ,
1955
+ len (self .volume_to_attachment [volume_id ]))
1950
1956
1951
1957
return attachment
1952
1958
1953
1959
def fake_attachment_delete (_self , context , attachment_id ):
1954
1960
# 'attachment' is a tuple defining a attachment-instance mapping
1955
- _ , attachment , attachments = _find_attachment (attachment_id )
1961
+ volume_id , attachment , attachments = (
1962
+ _find_attachment (attachment_id ))
1956
1963
attachments .remove (attachment )
1964
+ LOG .info ('Deleted attachment %s for volume %s. Total attachments '
1965
+ 'for volume: %d' , attachment_id , volume_id ,
1966
+ len (attachments ))
1957
1967
1958
1968
def fake_attachment_update (_self , context , attachment_id , connector ,
1959
1969
mountpoint = None ):
1960
1970
# Ensure the attachment exists
1961
1971
_find_attachment (attachment_id )
1972
+ LOG .info ('Updating volume attachment: %s' , attachment_id )
1962
1973
attachment_ref = {'driver_volume_type' : 'fake_type' ,
1963
1974
'id' : attachment_id ,
1964
1975
'connection_info' : {'data' :
@@ -1987,14 +1998,19 @@ def fake_get_all_volume_types(*args, **kwargs):
1987
1998
'name' : 'lvm-1'
1988
1999
}]
1989
2000
2001
+ def fake_attachment_complete (_self , _context , attachment_id ):
2002
+ # Ensure the attachment exists
2003
+ _find_attachment (attachment_id )
2004
+ LOG .info ('Completing volume attachment: %s' , attachment_id )
2005
+
1990
2006
self .test .stub_out ('nova.volume.cinder.API.attachment_create' ,
1991
2007
fake_attachment_create )
1992
2008
self .test .stub_out ('nova.volume.cinder.API.attachment_delete' ,
1993
2009
fake_attachment_delete )
1994
2010
self .test .stub_out ('nova.volume.cinder.API.attachment_update' ,
1995
2011
fake_attachment_update )
1996
2012
self .test .stub_out ('nova.volume.cinder.API.attachment_complete' ,
1997
- lambda * args , ** kwargs : None )
2013
+ fake_attachment_complete )
1998
2014
self .test .stub_out ('nova.volume.cinder.API.attachment_get' ,
1999
2015
fake_attachment_get )
2000
2016
self .test .stub_out ('nova.volume.cinder.API.begin_detaching' ,
@@ -2007,7 +2023,7 @@ def fake_get_all_volume_types(*args, **kwargs):
2007
2023
self .test .stub_out ('nova.volume.cinder.API.roll_detaching' ,
2008
2024
lambda * args , ** kwargs : None )
2009
2025
self .test .stub_out ('nova.volume.cinder.is_microversion_supported' ,
2010
- lambda * args , ** kwargs : None )
2026
+ lambda ctxt , microversion : None )
2011
2027
self .test .stub_out ('nova.volume.cinder.API.check_attached' ,
2012
2028
lambda * args , ** kwargs : None )
2013
2029
self .test .stub_out ('nova.volume.cinder.API.get_all_volume_types' ,
0 commit comments