1515from azure .mgmt .servicefabricmanagedclusters .models import (
1616 NetworkSecurityRule ,
1717 ManagedCluster ,
18+ ManagedClusterProperties ,
1819 Sku ,
1920 ClientCertificate
2021)
@@ -87,19 +88,20 @@ def create_cluster(cmd,
8788 if client_cert_issuer_thumbprint is not None :
8889 client_cert_issuer_thumbprint = ',' .join (client_cert_issuer_thumbprint )
8990 client_certs .append (ClientCertificate (is_admin = client_cert_is_admin , common_name = client_cert_common_name , issuer_thumbprint = client_cert_issuer_thumbprint ))
90-
91+
9192 new_cluster = ManagedCluster (location = location ,
92- dns_name = dns_name ,
93- admin_user_name = admin_user_name ,
94- admin_password = admin_password ,
9593 sku = skuObj ,
96- client_connection_port = client_connection_port ,
97- http_gateway_connection_port = gateway_connection_port ,
98- clients = client_certs ,
99- cluster_upgrade_mode = upgrade_mode ,
100- cluster_upgrade_cadence = upgrade_cadence ,
101- cluster_code_version = code_version ,
102- tags = tags )
94+ tags = tags ,
95+ properties = ManagedClusterProperties (
96+ dns_name = dns_name ,
97+ admin_user_name = admin_user_name ,
98+ admin_password = admin_password ,
99+ client_connection_port = client_connection_port ,
100+ http_gateway_connection_port = gateway_connection_port ,
101+ clients = client_certs ,
102+ cluster_upgrade_mode = upgrade_mode ,
103+ cluster_upgrade_cadence = upgrade_cadence ,
104+ cluster_code_version = code_version ))
103105
104106 logger .info ("Creating managed cluster '%s'" , cluster_name )
105107 poller = client .managed_clusters .begin_create_or_update (resource_group_name , cluster_name , new_cluster )
@@ -122,19 +124,19 @@ def update_cluster(cmd,
122124 cluster = client .managed_clusters .get (resource_group_name , cluster_name )
123125
124126 if client_connection_port is not None :
125- cluster .client_connection_port = client_connection_port
127+ cluster .properties . client_connection_port = client_connection_port
126128 if gateway_connection_port is not None :
127- cluster .http_gateway_connection_port = gateway_connection_port
129+ cluster .properties . http_gateway_connection_port = gateway_connection_port
128130 if dns_name is not None :
129- cluster .dns_name = dns_name
131+ cluster .properties . dns_name = dns_name
130132 if tags is not None :
131133 cluster .tags = tags
132134
133- if not cluster .public_ip_prefix_id :
134- cluster .public_ip_prefix_id = None
135+ if not cluster .properties . public_ip_prefix_id :
136+ cluster .properties . public_ip_prefix_id = None
135137
136- if not cluster .public_i_pv6_prefix_id :
137- cluster .public_i_pv6_prefix_id = None
138+ if not cluster .properties . public_i_pv6_prefix_id :
139+ cluster .properties . public_i_pv6_prefix_id = None
138140
139141 poller = client .managed_clusters .begin_create_or_update (resource_group_name , cluster_name , cluster )
140142 return LongRunningOperation (cmd .cli_ctx )(poller )
@@ -154,23 +156,23 @@ def add_client_cert(cmd,
154156 try :
155157 cluster = client .managed_clusters .get (resource_group_name , cluster_name )
156158
157- if cluster .clients is None :
158- cluster .clients = []
159+ if cluster .properties . clients is None :
160+ cluster .properties . clients = []
159161
160162 if thumbprint is not None :
161- cluster .clients .append (ClientCertificate (is_admin = is_admin , thumbprint = thumbprint ))
163+ cluster .properties . clients .append (ClientCertificate (is_admin = is_admin , thumbprint = thumbprint ))
162164 elif common_name is not None :
163165 if issuer_thumbprint is not None :
164166 issuer_thumbprint = ',' .join (issuer_thumbprint )
165- cluster .clients .append (ClientCertificate (is_admin = is_admin , common_name = common_name , issuer_thumbprint = issuer_thumbprint ))
167+ cluster .properties . clients .append (ClientCertificate (is_admin = is_admin , common_name = common_name , issuer_thumbprint = issuer_thumbprint ))
166168 else :
167169 raise CLIError ("Thumbprint and Common name are empty" )
168170
169- if not cluster .public_ip_prefix_id :
170- cluster .public_ip_prefix_id = None
171+ if not cluster .properties . public_ip_prefix_id :
172+ cluster .properties . public_ip_prefix_id = None
171173
172- if not cluster .public_i_pv6_prefix_id :
173- cluster .public_i_pv6_prefix_id = None
174+ if not cluster .properties . public_i_pv6_prefix_id :
175+ cluster .properties . public_i_pv6_prefix_id = None
174176
175177 poller = client .managed_clusters .begin_create_or_update (resource_group_name , cluster_name , cluster )
176178 return LongRunningOperation (cmd .cli_ctx )(poller )
@@ -188,22 +190,22 @@ def delete_client_cert(cmd,
188190 try :
189191 cluster = client .managed_clusters .get (resource_group_name , cluster_name )
190192
191- if not cluster .public_ip_prefix_id :
192- cluster .public_ip_prefix_id = None
193+ if not cluster .properties . public_ip_prefix_id :
194+ cluster .properties . public_ip_prefix_id = None
193195
194- if not cluster .public_i_pv6_prefix_id :
195- cluster .public_i_pv6_prefix_id = None
196+ if not cluster .properties . public_i_pv6_prefix_id :
197+ cluster .properties . public_i_pv6_prefix_id = None
196198
197- if cluster .clients is not None :
198- initial_size = len (cluster .clients )
199+ if cluster .properties . clients is not None :
200+ initial_size = len (cluster .properties . clients )
199201 if thumbprint is not None :
200202 thumbprint = [x .lower () for x in thumbprint ]
201- cluster .clients = [cert for cert in cluster .clients if cert .thumbprint .lower () not in thumbprint ]
203+ cluster .properties . clients = [cert for cert in cluster . properties .clients if cert .thumbprint .lower () not in thumbprint ]
202204 if common_name is not None :
203205 common_name = [x .lower () for x in common_name ]
204- cluster .clients = [cert for cert in cluster .clients if cert .common_name .lower () not in common_name ]
206+ cluster .properties . clients = [cert for cert in cluster . properties .clients if cert .common_name .lower () not in common_name ]
205207
206- if initial_size > len (cluster .clients ):
208+ if initial_size > len (cluster .properties . clients ):
207209 poller = client .managed_clusters .begin_create_or_update (resource_group_name , cluster_name , cluster )
208210 return LongRunningOperation (cmd .cli_ctx )(poller )
209211 return cluster
@@ -253,8 +255,8 @@ def add_network_security_rule(cmd,
253255 try :
254256 cluster = client .managed_clusters .get (resource_group_name , cluster_name )
255257
256- if cluster .network_security_rules is None :
257- cluster .network_security_rules = []
258+ if cluster .properties . network_security_rules is None :
259+ cluster .properties . network_security_rules = []
258260
259261 new_network_securityRule = NetworkSecurityRule (name = name ,
260262 access = access ,
@@ -271,13 +273,13 @@ def add_network_security_rule(cmd,
271273 destination_address_prefix = dest_addr_prefix ,
272274 source_address_prefix = source_addr_prefix )
273275
274- cluster .network_security_rules .append (new_network_securityRule )
276+ cluster .properties . network_security_rules .append (new_network_securityRule )
275277
276- if not cluster .public_ip_prefix_id :
277- cluster .public_ip_prefix_id = None
278+ if not cluster .properties . public_ip_prefix_id :
279+ cluster .properties . public_ip_prefix_id = None
278280
279- if not cluster .public_i_pv6_prefix_id :
280- cluster .public_i_pv6_prefix_id = None
281+ if not cluster .properties . public_i_pv6_prefix_id :
282+ cluster .properties . public_i_pv6_prefix_id = None
281283
282284 poller = client .managed_clusters .begin_create_or_update (resource_group_name , cluster_name , cluster )
283285 return LongRunningOperation (cmd .cli_ctx )(poller )
@@ -326,11 +328,11 @@ def update_network_security_rule(cmd,
326328 destination_address_prefixes = dest_addr_prefixes if dest_addr_prefixes is not None else existing_nsg .destination_address_prefixes ,
327329 source_address_prefixes = source_addr_prefixes if source_addr_prefixes is not None else existing_nsg .source_address_prefixes )
328330
329- if not cluster .public_ip_prefix_id :
330- cluster .public_ip_prefix_id = None
331+ if not cluster .properties . public_ip_prefix_id :
332+ cluster .properties . public_ip_prefix_id = None
331333
332- if not cluster .public_i_pv6_prefix_id :
333- cluster .public_i_pv6_prefix_id = None
334+ if not cluster .properties . public_i_pv6_prefix_id :
335+ cluster .properties . public_i_pv6_prefix_id = None
334336
335337 update_in_collection (cluster , 'network_security_rules' , updated_network_securityRule , 'name' )
336338
@@ -364,7 +366,7 @@ def list_network_security_rules(client,
364366 cluster_name ):
365367 try :
366368 cluster = client .managed_clusters .get (resource_group_name , cluster_name )
367- return cluster .network_security_rules
369+ return cluster .properties . network_security_rules
368370
369371 except HttpResponseError as ex :
370372 logger .error ("HttpResponseError: %s" , ex )
@@ -379,18 +381,18 @@ def delete_network_security_rule(cmd,
379381 try :
380382 cluster = client .managed_clusters .get (resource_group_name , cluster_name )
381383
382- if not cluster .public_ip_prefix_id :
383- cluster .public_ip_prefix_id = None
384+ if not cluster .properties . public_ip_prefix_id :
385+ cluster .properties . public_ip_prefix_id = None
384386
385- if not cluster .public_i_pv6_prefix_id :
386- cluster .public_i_pv6_prefix_id = None
387+ if not cluster .properties . public_i_pv6_prefix_id :
388+ cluster .properties . public_i_pv6_prefix_id = None
387389
388- if cluster .network_security_rules is not None :
389- initial_size = len (cluster .network_security_rules )
390+ if cluster .properties . network_security_rules is not None :
391+ initial_size = len (cluster .properties . network_security_rules )
390392 if name is not None :
391- cluster .network_security_rules = [nsg for nsg in cluster .network_security_rules if nsg .name != name ]
393+ cluster .properties . network_security_rules = [nsg for nsg in cluster . properties .network_security_rules if nsg .name != name ]
392394
393- if initial_size > len (cluster .network_security_rules ):
395+ if initial_size > len (cluster .properties . network_security_rules ):
394396 poller = client .managed_clusters .begin_create_or_update (resource_group_name , cluster_name , cluster )
395397 return LongRunningOperation (cmd .cli_ctx )(poller )
396398
0 commit comments