@@ -1990,24 +1990,33 @@ class GetRoCEPropertiesTask(task.Task):
19901990 def __init__ (self , client , * args , ** kwargs ):
19911991 super (GetRoCEPropertiesTask , self ).__init__ (* args , ** kwargs )
19921992 self .client = client
1993+
1994+ @staticmethod
1995+ def _set_de_replicas (mapping_info ):
1996+ portals = mapping_info .get ('portals' )
1997+ if len (portals ) == 1 :
1998+ return
19931999
1994- def execute ( self , target_ips , host_id , lun_id , lun_info ):
1995- host_lun_info = self . client . get_hostlun_info ( host_id , lun_id )
1996- if not host_lun_info :
1997- msg = _ ( "No hostlun information between host %(host_id)s and lun %(lun_id)s." % {
1998- 'host_id ' : host_id ,
1999- 'lun_id ' : lun_id
2000+ dm_replicas = []
2001+ for portal in portals :
2002+ dm_replicas . append ({
2003+ 'target_nqn' : mapping_info . get ( 'target_nqn' ),
2004+ 'vol_uuid ' : mapping_info . get ( 'vol_uuid' ) ,
2005+ 'portals ' : [ portal ]
20002006 })
2001- LOG .error (msg )
2002- raise exception .VolumeBackendAPIException (data = msg )
2003- host_lun_id = host_lun_info [0 ]['hostLunId' ]
2007+ mapping_info .update ({
2008+ 'dm_replicas' : dm_replicas
2009+ })
2010+
2011+ def execute (self , target_ips , host_id , lun_id , lun_info , lun ):
20042012 mapping_info = {
2013+ 'vol_uuid' : lun .id ,
20052014 'portals' : [(ip , constants .ROCE_TARGET_PORT , 'rdma' ) for ip in target_ips ],
2006- 'target_luns' : [host_lun_id ] * len (target_ips ),
20072015 'target_nqn' : constants .ROCE_TARGET_NQN_PREFIX + self .client ._login_device_id ,
20082016 'discard' : True ,
20092017 'volume_nguid' : lun_info .get ('NGUID' )
20102018 }
2019+ self ._set_de_replicas (mapping_info )
20112020 return mapping_info
20122021
20132022
0 commit comments