@@ -188,10 +188,10 @@ def _check_lun_type(opts):
188
188
LOG .error (msg )
189
189
raise exception .InvalidInput (reason = msg )
190
190
191
- def _add_smartx (self , opts , fs_id ):
191
+ def _add_smartx (self , opts , fs_id , vstore_id ):
192
192
try :
193
193
if opts ['qos' ]:
194
- self .smart_qos .add (opts ['qos' ], fs_id )
194
+ self .smart_qos .add (opts ['qos' ], fs_id , vstore_id )
195
195
if opts ['huawei_smartpartition' ]:
196
196
self .smart_partition .add (opts ['partitionname' ], fs_id )
197
197
if opts ['huawei_smartcache' ]:
@@ -318,7 +318,8 @@ def _create_filesystem(self, share, pool_name, share_fs_id=None,
318
318
self .configuration .timeout )
319
319
fs_info = self ._split_clone_fs (context , share , fs_id )
320
320
321
- self ._add_smartx (opts , fs_id )
321
+ vstore_id = fs_info .get ('vstoreId' )
322
+ self ._add_smartx (opts , fs_id , vstore_id )
322
323
self ._add_hypermetro (context , opts , params , remote_vstore_id , fs_info )
323
324
return fs_id
324
325
@@ -546,29 +547,44 @@ def delete_share(self, context, share, share_server=None):
546
547
def update_replica_filesystem (self , replica_fs_id , params ):
547
548
self .helper .update_filesystem (replica_fs_id , params )
548
549
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' )):
553
552
metro_id = self ._get_metro_id_from_fs_info (fs_info )
554
553
metro_info = self .helper .get_hypermetro_pair_by_id (metro_id )
555
554
if not metro_info :
556
555
msg = (_ ("The hypermetro pair %(metro_id)s does not exist." ) %
557
556
{"metro_id" : metro_id })
558
557
LOG .error (msg )
559
558
raise exception .InvalidInput (reason = msg )
559
+ return metro_info
560
+ return {}
560
561
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 )
572
588
573
589
if json .loads (fs_info .get ('REMOTEREPLICATIONIDS' )):
574
590
replica_id = self ._get_replica_id_from_fs_info (fs_info )
@@ -591,6 +607,11 @@ def _update_filesystem(self, fs_info, params):
591
607
LOG .error (msg )
592
608
raise exception .InvalidInput (reason = msg )
593
609
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
+
594
615
self .helper .update_filesystem (fs_id , params )
595
616
596
617
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):
645
666
params = {"CAPACITY" : size }
646
667
self ._update_filesystem (fs_info , params )
647
668
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
+
648
674
def create_snapshot (self , context , snapshot , share_server = None ):
649
675
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' ])
652
683
LOG .info ("Create snapshot %(snapshot)s from share %(share)s "
653
684
"successfully." , {"snapshot" : snapshot ["id" ],
654
685
"share" : snapshot ['share_name' ]})
655
686
return {'provider_location' : snapshot_id }
656
687
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
+
657
695
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
+
658
712
provider_location = snapshot .get ('provider_location' )
659
713
if provider_location and '@' in provider_location :
660
714
snapshot_id = provider_location
@@ -749,6 +803,7 @@ def _update_pool_info(self):
749
803
capacity .get ('PROVISIONEDCAPACITY' , 0.0 ),
750
804
'allocated_capacity_gb' : capacity .get ('CONSUMEDCAPACITY' , 0.0 ),
751
805
'reserved_percentage' : 0 ,
806
+ 'reserved_snapshot_percentage' : 0 ,
752
807
'qos' : [self .feature_supports ['SmartQoS' ], False ],
753
808
'huawei_smartcache' :
754
809
[self .feature_supports ['SmartCache' ], False ],
@@ -783,7 +838,7 @@ def _update_share_stats(self, date=None):
783
838
data = {
784
839
'share_backend_name' : backend_name or 'HUAWEI_NAS_Driver' ,
785
840
'vendor_name' : 'Huawei' ,
786
- 'driver_version' : '2.3.RC2 ' ,
841
+ 'driver_version' : '2.5.RC1 ' ,
787
842
'storage_protocol' : 'NFS_CIFS' ,
788
843
'snapshot_support' : (self .feature_supports ['HyperSnap' ]
789
844
and self .configuration .snapshot_support ),
@@ -850,9 +905,19 @@ def _get_access_for_share_copy(self, share):
850
905
{'access' : access , 'share' : share ['name' ]})
851
906
return access
852
907
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
+
853
913
def create_share_from_snapshot (self , context , share ,
854
914
snapshot , share_server = None ):
855
915
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' ])
856
921
share_fs_id = share_fs_info ['ID' ]
857
922
snapshot_id = huawei_utils .snapshot_id (share_fs_id , snapshot ['name' ])
858
923
@@ -1907,9 +1972,19 @@ def _snapshot_rollback_finish():
1907
1972
constants .SNAPSHOT_ROLLBACK_TIMEOUT )
1908
1973
LOG .info ("Snapshot %s rollback successful." , snapshot_name )
1909
1974
1975
+ def rpc_revert_to_hypermetro_snapshot (self , context , share_name ,
1976
+ snapshot_name ):
1977
+ self ._revert_to_snapshot (share_name , snapshot_name )
1978
+
1910
1979
def revert_to_snapshot (self , context , snapshot , share_access_rules ,
1911
1980
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' ])
1913
1988
1914
1989
def rpc_update_snapshot (self , replica_share_name ,
1915
1990
active_snapshot_name , replica_snapshot_name ):
0 commit comments