@@ -2904,6 +2904,50 @@ func (me *VpcService) DescribeEniByFilters(
2904
2904
return me .describeEnis (ctx , nil , vpcId , subnetId , nil , cvmId , sgId , name , desc , ipv4 , tags )
2905
2905
}
2906
2906
2907
+ func (me * VpcService ) DescribeHaVipByFilter (ctx context.Context , filters map [string ]string ) (instances []* vpc.HaVip , errRet error ) {
2908
+ var (
2909
+ logId = getLogId (ctx )
2910
+ request = vpc .NewDescribeHaVipsRequest ()
2911
+ )
2912
+ request .Filters = make ([]* vpc.Filter , 0 , len (filters ))
2913
+ for k , v := range filters {
2914
+ filter := vpc.Filter {
2915
+ Name : helper .String (k ),
2916
+ Values : []* string {helper .String (v )},
2917
+ }
2918
+ request .Filters = append (request .Filters , & filter )
2919
+ }
2920
+
2921
+ var offset uint64 = 0
2922
+ var pageSize uint64 = 100
2923
+ instances = make ([]* vpc.HaVip , 0 )
2924
+
2925
+ for {
2926
+ request .Offset = & offset
2927
+ request .Limit = & pageSize
2928
+ ratelimit .Check (request .GetAction ())
2929
+ response , err := me .client .UseVpcClient ().DescribeHaVips (request )
2930
+ if err != nil {
2931
+ log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
2932
+ logId , request .GetAction (), request .ToJsonString (), err .Error ())
2933
+ errRet = err
2934
+ return
2935
+ }
2936
+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
2937
+ logId , request .GetAction (), request .ToJsonString (), response .ToJsonString ())
2938
+
2939
+ if response == nil || len (response .Response .HaVipSet ) < 1 {
2940
+ break
2941
+ }
2942
+ instances = append (instances , response .Response .HaVipSet ... )
2943
+ if len (response .Response .HaVipSet ) < int (pageSize ) {
2944
+ break
2945
+ }
2946
+ offset += pageSize
2947
+ }
2948
+ return
2949
+ }
2950
+
2907
2951
func (me * VpcService ) DescribeHaVipEipById (ctx context.Context , haVipEipAttachmentId string ) (eip string , haVip string , has bool , errRet error ) {
2908
2952
logId := getLogId (ctx )
2909
2953
client := me .client .UseVpcClient ()
@@ -2953,6 +2997,27 @@ func (me *VpcService) DescribeHaVipEipById(ctx context.Context, haVipEipAttachme
2953
2997
return eip , haVip , has , errRet
2954
2998
}
2955
2999
3000
+ func (me * VpcService ) DeleteHaVip (ctx context.Context , haVipId string ) (errRet error ) {
3001
+ logId := getLogId (ctx )
3002
+ request := vpc .NewDeleteHaVipRequest ()
3003
+ defer func () {
3004
+ if errRet != nil {
3005
+ log .Printf ("[CRITAL]%s api[%s] fail,reason[%s]" , logId , request .GetAction (), errRet .Error ())
3006
+ }
3007
+ }()
3008
+ request .HaVipId = & haVipId
3009
+
3010
+ errRet = resource .Retry (writeRetryTimeout , func () * resource.RetryError {
3011
+ ratelimit .Check (request .GetAction ())
3012
+ _ , errRet = me .client .UseVpcClient ().DeleteHaVip (request )
3013
+ if errRet != nil {
3014
+ return retryError (errRet , InternalError )
3015
+ }
3016
+ return nil
3017
+ })
3018
+ return
3019
+ }
3020
+
2956
3021
func waitEniReady (ctx context.Context , id string , client * vpc.Client , wantIpv4s []string , dropIpv4s []string ) error {
2957
3022
logId := getLogId (ctx )
2958
3023
0 commit comments