1212from knack .log import get_logger
1313from azure .mgmt .core .tools import parse_resource_id , is_valid_resource_id , resource_id
1414
15- from azure .cli .core .aaz import AAZClientConfiguration , has_value , register_client
15+ from azure .cli .core .aaz import AAZClientConfiguration , has_value , register_client , AAZFileArgTextFormat
1616from azure .cli .core .aaz ._client import AAZMgmtClient
1717from azure .cli .core .aaz .utils import assign_aaz_list_arg
1818from azure .cli .core .commands .client_factory import get_subscription_id , get_mgmt_service_client
@@ -5925,11 +5925,19 @@ def _build_arguments_schema(cls, *args, **kwargs):
59255925 return args_schema
59265926
59275927
5928+ class RootCertFormat (AAZFileArgTextFormat ):
5929+ def read_file (self , file_path ):
5930+ with open (file_path , 'r' , encoding = self ._encoding ) as cert_file :
5931+ lines = cert_file .readlines ()
5932+
5933+ cert_data = '' .join (line .strip () for line in lines if not line .startswith ('-----' ))
5934+ return cert_data
5935+
5936+
59285937class VnetGatewayCreate (_VnetGatewayCreate ):
59295938 @classmethod
59305939 def _build_arguments_schema (cls , * args , ** kwargs ):
5931- from azure .cli .core .aaz import AAZListArg , AAZStrArg , AAZFileArg , AAZResourceIdArg , AAZResourceIdArgFormat , \
5932- AAZFileArgBase64EncodeFormat
5940+ from azure .cli .core .aaz import AAZListArg , AAZStrArg , AAZFileArg , AAZResourceIdArg , AAZResourceIdArgFormat
59335941 args_schema = super ()._build_arguments_schema (* args , ** kwargs )
59345942 args_schema .public_ip_addresses = AAZListArg (options = ['--public-ip-addresses' , '--public-ip-address' ],
59355943 help = "Specify a single public IP (name or ID) for an active-standby gateway. Specify two space-separated public IPs for an active-active gateway." )
@@ -5956,7 +5964,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
59565964 )
59575965 args_schema .root_cert_data = AAZFileArg (options = ['--root-cert-data' ], arg_group = "Root Cert Authentication" ,
59585966 help = "Base64 contents of the root certificate file or file path." ,
5959- fmt = AAZFileArgBase64EncodeFormat ())
5967+ fmt = RootCertFormat ())
59605968 args_schema .root_cert_name = AAZStrArg (options = ['--root-cert-name' ], arg_group = "Root Cert Authentication" ,
59615969 help = "Root certificate name." )
59625970 args_schema .gateway_default_site ._fmt = AAZResourceIdArgFormat (
@@ -6019,13 +6027,12 @@ def pre_operations(self):
60196027 args .nat_rules = rules
60206028
60216029 if has_value (args .address_prefixes ) or has_value (args .client_protocol ):
6022- import os
60236030 if has_value (args .root_cert_data ):
6024- path = os . path . expanduser ( args .root_cert_data .to_serialized_data () )
6031+ data = args .root_cert_data .to_serialized_data ()
60256032 else :
6026- path = None
6033+ data = None
60276034 if has_value (args .root_cert_name ):
6028- args .vpn_client_root_certificates = [{'name' : args .root_cert_name , 'public_cert_data' : path }]
6035+ args .vpn_client_root_certificates = [{'name' : args .root_cert_name , 'public_cert_data' : data }]
60296036 else :
60306037 args .vpn_client_root_certificates = []
60316038
@@ -6048,8 +6055,7 @@ def _output(self, *args, **kwargs):
60486055class VnetGatewayUpdate (_VnetGatewayUpdate ):
60496056 @classmethod
60506057 def _build_arguments_schema (cls , * args , ** kwargs ):
6051- from azure .cli .core .aaz import AAZListArg , AAZStrArg , AAZFileArg , AAZResourceIdArg , AAZResourceIdArgFormat , \
6052- AAZFileArgBase64EncodeFormat
6058+ from azure .cli .core .aaz import AAZListArg , AAZStrArg , AAZFileArg , AAZResourceIdArg , AAZResourceIdArgFormat
60536059 args_schema = super ()._build_arguments_schema (* args , ** kwargs )
60546060 args_schema .public_ip_addresses = AAZListArg (options = ['--public-ip-addresses' , '--public-ip-address' ],
60556061 help = "Specify a single public IP (name or ID) for an active-standby gateway. Specify two space-separated public IPs for an active-active gateway." ,
@@ -6069,7 +6075,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
60696075 )
60706076 args_schema .root_cert_data = AAZFileArg (options = ['--root-cert-data' ], arg_group = "Root Cert Authentication" ,
60716077 help = "Base64 contents of the root certificate file or file path." ,
6072- fmt = AAZFileArgBase64EncodeFormat (), nullable = True )
6078+ fmt = RootCertFormat (), nullable = True )
60736079 args_schema .root_cert_name = AAZStrArg (options = ['--root-cert-name' ], arg_group = "Root Cert Authentication" ,
60746080 help = "Root certificate name." , nullable = True ,)
60756081 args_schema .gateway_default_site ._fmt = AAZResourceIdArgFormat (
@@ -6084,10 +6090,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
60846090
60856091 def pre_operations (self ):
60866092 args = self .ctx .args
6087- if has_value (args .root_cert_data ):
6088- import os
6089- path = os .path .expanduser (args .root_cert_data .to_serialized_data ())
6090- args .root_cert_data = path
60916093
60926094 if has_value (args .sku ):
60936095 args .sku_tier = args .sku
0 commit comments