@@ -188,10 +188,10 @@ def _check_lun_type(opts):
188188 LOG .error (msg )
189189 raise exception .InvalidInput (reason = msg )
190190
191- def _add_smartx (self , opts , fs_id ):
191+ def _add_smartx (self , opts , fs_id , vstore_id ):
192192 try :
193193 if opts ['qos' ]:
194- self .smart_qos .add (opts ['qos' ], fs_id )
194+ self .smart_qos .add (opts ['qos' ], fs_id , vstore_id )
195195 if opts ['huawei_smartpartition' ]:
196196 self .smart_partition .add (opts ['partitionname' ], fs_id )
197197 if opts ['huawei_smartcache' ]:
@@ -318,7 +318,8 @@ def _create_filesystem(self, share, pool_name, share_fs_id=None,
318318 self .configuration .timeout )
319319 fs_info = self ._split_clone_fs (context , share , fs_id )
320320
321- self ._add_smartx (opts , fs_id )
321+ vstore_id = fs_info .get ('vstoreId' )
322+ self ._add_smartx (opts , fs_id , vstore_id )
322323 self ._add_hypermetro (context , opts , params , remote_vstore_id , fs_info )
323324 return fs_id
324325
@@ -546,29 +547,44 @@ def delete_share(self, context, share, share_server=None):
546547 def update_replica_filesystem (self , replica_fs_id , params ):
547548 self .helper .update_filesystem (replica_fs_id , params )
548549
549- def _update_filesystem (self , fs_info , params ):
550- fs_id = fs_info .get ('ID' )
551- if (not self .is_dorado_v6 and
552- json .loads (fs_info .get ('HYPERMETROPAIRIDS' ))):
550+ def _check_and_get_hypermetro_pair (self , fs_info ):
551+ if json .loads (fs_info .get ('HYPERMETROPAIRIDS' )):
553552 metro_id = self ._get_metro_id_from_fs_info (fs_info )
554553 metro_info = self .helper .get_hypermetro_pair_by_id (metro_id )
555554 if not metro_info :
556555 msg = (_ ("The hypermetro pair %(metro_id)s does not exist." ) %
557556 {"metro_id" : metro_id })
558557 LOG .error (msg )
559558 raise exception .InvalidInput (reason = msg )
559+ return metro_info
560+ return {}
560561
561- remote_fs_id = self ._get_remote_fs_id (fs_id , metro_info )
562- try :
563- context = manila_context .get_admin_context ()
564- self .rpc_client .update_filesystem (context , self .remote_backend ,
565- remote_fs_id , params )
566- except Exception as err :
567- msg = (_ ("Failed to update remote filesystem %(fs_id)s. "
568- "Reason: %(err)s" ) %
569- {"fs_id" : remote_fs_id , "err" : err })
570- LOG .error (msg )
571- raise exception .InvalidInput (reason = msg )
562+ def _is_dorado_v6_hypermetro_filesystem_not_active (self , fs_info ):
563+ return (self .is_dorado_v6
564+ and bool (self ._check_and_get_hypermetro_pair (fs_info ))
565+ and not self ._check_is_active_client ())
566+
567+ def _update_hypermetro_remote_filesystem (self , fs_info , params ):
568+ fs_id = fs_info .get ('ID' )
569+ metro_info = self ._check_and_get_hypermetro_pair (fs_info )
570+
571+ remote_fs_id = self ._get_remote_fs_id (fs_id , metro_info )
572+ try :
573+ context = manila_context .get_admin_context ()
574+ self .rpc_client .update_filesystem (context , self .remote_backend ,
575+ remote_fs_id , params )
576+ except Exception as err :
577+ msg = (_ ("Failed to update remote filesystem %(fs_id)s. "
578+ "Reason: %(err)s" ) %
579+ {"fs_id" : remote_fs_id , "err" : err })
580+ LOG .error (msg )
581+ raise exception .InvalidInput (reason = msg )
582+
583+ def _update_filesystem (self , fs_info , params ):
584+ fs_id = fs_info .get ('ID' )
585+ if (not self .is_dorado_v6 and
586+ json .loads (fs_info .get ('HYPERMETROPAIRIDS' ))):
587+ self ._update_hypermetro_remote_filesystem (fs_info , params )
572588
573589 if json .loads (fs_info .get ('REMOTEREPLICATIONIDS' )):
574590 replica_id = self ._get_replica_id_from_fs_info (fs_info )
@@ -591,6 +607,11 @@ def _update_filesystem(self, fs_info, params):
591607 LOG .error (msg )
592608 raise exception .InvalidInput (reason = msg )
593609
610+ if (self .is_dorado_v6 and json .loads (fs_info .get ('HYPERMETROPAIRIDS' ))
611+ and not self ._check_is_active_client ()):
612+ self ._update_hypermetro_remote_filesystem (fs_info , params )
613+ return
614+
594615 self .helper .update_filesystem (fs_id , params )
595616
596617 def _get_fs_info_by_name (self , share_name , raise_exception = True ):
@@ -645,16 +666,49 @@ def shrink_share(self, share, new_size, share_server=None):
645666 params = {"CAPACITY" : size }
646667 self ._update_filesystem (fs_info , params )
647668
669+ def rpc_create_hypermetro_snapshot (self , context ,
670+ share_name , snapshot_name ):
671+ fs_info = self ._get_fs_info_by_name (share_name )
672+ return self .helper .create_snapshot (fs_info ['ID' ], snapshot_name )
673+
648674 def create_snapshot (self , context , snapshot , share_server = None ):
649675 fs_info = self ._get_fs_info_by_name (snapshot ['share_name' ])
650- snapshot_id = self .helper .create_snapshot (fs_info ['ID' ],
651- snapshot ['name' ])
676+ if self ._is_dorado_v6_hypermetro_filesystem_not_active (fs_info ):
677+ snapshot_id = self .rpc_client .create_hypermetro_snapshot (
678+ context , snapshot ['share_name' ], snapshot ['name' ],
679+ self .remote_backend )
680+ else :
681+ snapshot_id = self .helper .create_snapshot (fs_info ['ID' ],
682+ snapshot ['name' ])
652683 LOG .info ("Create snapshot %(snapshot)s from share %(share)s "
653684 "successfully." , {"snapshot" : snapshot ["id" ],
654685 "share" : snapshot ['share_name' ]})
655686 return {'provider_location' : snapshot_id }
656687
688+ def rpc_delete_hypermetro_snapshot (self , context , share_name ,
689+ snapshot_name ):
690+ fs_info = self ._get_fs_info_by_name (share_name )
691+ snapshot_id = huawei_utils .snapshot_id (fs_info ['ID' ],
692+ snapshot_name )
693+ self .helper .delete_snapshot (snapshot_id )
694+
657695 def delete_snapshot (self , context , snapshot , share_server = None ):
696+ fs_info = self ._get_fs_info_by_name (snapshot ['share_name' ],
697+ raise_exception = False )
698+ if not fs_info :
699+ LOG .error ("The filestsyetm %s is not exist, return success." ,
700+ snapshot ['share_name' ])
701+ return
702+
703+ if self ._is_dorado_v6_hypermetro_filesystem_not_active (fs_info ):
704+ self .rpc_client .delete_hypermetro_snapshot (context ,
705+ snapshot ['share_name' ],
706+ snapshot ['name' ],
707+ self .remote_backend )
708+ LOG .info ("Delete snapshot %(snapshot)s successfully." ,
709+ {"snapshot" : snapshot ["id" ]})
710+ return
711+
658712 provider_location = snapshot .get ('provider_location' )
659713 if provider_location and '@' in provider_location :
660714 snapshot_id = provider_location
@@ -749,6 +803,7 @@ def _update_pool_info(self):
749803 capacity .get ('PROVISIONEDCAPACITY' , 0.0 ),
750804 'allocated_capacity_gb' : capacity .get ('CONSUMEDCAPACITY' , 0.0 ),
751805 'reserved_percentage' : 0 ,
806+ 'reserved_snapshot_percentage' : 0 ,
752807 'qos' : [self .feature_supports ['SmartQoS' ], False ],
753808 'huawei_smartcache' :
754809 [self .feature_supports ['SmartCache' ], False ],
@@ -783,7 +838,7 @@ def _update_share_stats(self, date=None):
783838 data = {
784839 'share_backend_name' : backend_name or 'HUAWEI_NAS_Driver' ,
785840 'vendor_name' : 'Huawei' ,
786- 'driver_version' : '2.3.RC2 ' ,
841+ 'driver_version' : '2.5.RC1 ' ,
787842 'storage_protocol' : 'NFS_CIFS' ,
788843 'snapshot_support' : (self .feature_supports ['HyperSnap' ]
789844 and self .configuration .snapshot_support ),
@@ -850,9 +905,19 @@ def _get_access_for_share_copy(self, share):
850905 {'access' : access , 'share' : share ['name' ]})
851906 return access
852907
908+ def rpc_create_share_from_hypermetro_snapshot (self , context , share ,
909+ snapshot , share_server ):
910+ return self .create_share_from_snapshot (
911+ context , share , snapshot , share_server )
912+
853913 def create_share_from_snapshot (self , context , share ,
854914 snapshot , share_server = None ):
855915 share_fs_info = self ._get_fs_info_by_name (snapshot ['share_name' ])
916+ if self ._is_dorado_v6_hypermetro_filesystem_not_active (share_fs_info ):
917+ return self .rpc_client .create_share_from_hypermetro_snapshot (
918+ context , share , snapshot , share_server , self .remote_backend )
919+
920+ share_fs_info = self ._get_fs_info_by_name (snapshot ['share_name' ])
856921 share_fs_id = share_fs_info ['ID' ]
857922 snapshot_id = huawei_utils .snapshot_id (share_fs_id , snapshot ['name' ])
858923
@@ -1907,9 +1972,19 @@ def _snapshot_rollback_finish():
19071972 constants .SNAPSHOT_ROLLBACK_TIMEOUT )
19081973 LOG .info ("Snapshot %s rollback successful." , snapshot_name )
19091974
1975+ def rpc_revert_to_hypermetro_snapshot (self , context , share_name ,
1976+ snapshot_name ):
1977+ self ._revert_to_snapshot (share_name , snapshot_name )
1978+
19101979 def revert_to_snapshot (self , context , snapshot , share_access_rules ,
19111980 snapshot_access_rules , share_server = None ):
1912- self ._revert_to_snapshot (snapshot ['share_name' ], snapshot ['name' ])
1981+ fs_info = self ._get_fs_info_by_name (snapshot ['share_name' ])
1982+ if self ._is_dorado_v6_hypermetro_filesystem_not_active (fs_info ):
1983+ self .rpc_client .revert_to_hypermetro_snapshot (
1984+ context , snapshot ['share_name' ], snapshot ['name' ],
1985+ self .remote_backend )
1986+ else :
1987+ self ._revert_to_snapshot (snapshot ['share_name' ], snapshot ['name' ])
19131988
19141989 def rpc_update_snapshot (self , replica_share_name ,
19151990 active_snapshot_name , replica_snapshot_name ):
0 commit comments