-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Network] Migrate network to track2 SDK #16245
Conversation
Network |
bf64ff0
to
46d0a72
Compare
c3917d5
to
0da192d
Compare
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
@@ -172,7 +172,7 @@ def _resolve_model(self): | |||
|
|||
doc_string = doc_string.replace('\r', '').replace('\n', ' ') | |||
doc_string = re.sub(' +', ' ', doc_string) | |||
model_name_regex = re.compile(r':return: (.*that returns )?(?P<model>[a-zA-Z]*)') | |||
model_name_regex = re.compile(r':return: (?:.*?that returns (?:either )?)?(?P<model>[a-zA-Z]*)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dark magic. Consider adding more comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Originally I added comments, it seems when I resolved conflicts manually after rebasing dev, the comments was removed accidentally. I'll add comments here to explain why this change happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could add more annotation or example? The regex is not clear.
@@ -2904,7 +2915,7 @@ def create_private_endpoint(cmd, resource_group_name, private_endpoint_name, sub | |||
else: | |||
private_endpoint.private_link_service_connections = [pls_connection] | |||
|
|||
return client.create_or_update(resource_group_name, private_endpoint_name, private_endpoint) | |||
return client.begin_create_or_update(resource_group_name, private_endpoint_name, private_endpoint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need support no_wait for this long running operation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, usually LRO need support no_wait, but actually some of our code doesn't follow this guideline.
In this PR, we just focus on migration and keep the same behavior as before.
For improvement, we can do it in future PRs.
@@ -472,6 +472,7 @@ def _make_singular(value): | |||
g.command('delete', delete_network_resource_property_entry('application_gateways', subresource), supports_no_wait=True) | |||
g.custom_command('create', 'create_ag_{}'.format(_make_singular(subresource)), supports_no_wait=True, validator=create_validator) | |||
g.generic_update_command('update', command_type=network_ag_sdk, supports_no_wait=True, | |||
setter_name='begin_create_or_update', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the setter name is create_or_update
(track1), we don't need provide it.
@@ -564,7 +568,7 @@ def _make_singular(value): | |||
client_factory=cf_app_gateway_waf_policy, | |||
min_api='2018-12-01') as g: | |||
g.custom_command('create', 'create_ag_waf_policy') | |||
g.command('delete', 'delete') | |||
g.command('delete', 'begin_delete') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For LRO, the name is changed from xxx
to begin_xxx
.
|
||
# if VNETs specified, have to create the protection plan and then add the VNETs | ||
plan_id = LongRunningOperation(cmd.cli_ctx)( | ||
ddos_client.create_or_update(resource_group_name, ddos_plan_name, location=location, tags=tags)).id | ||
ddos_client.begin_create_or_update(resource_group_name, ddos_plan_name, parameters=ddos_protection_plan)).id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In track2, SDK parameters are not flattened, so we need pass object parameter instead of flattened parameters to SDK.
@@ -2807,7 +2818,7 @@ def assign_express_route_port_identity(cmd, resource_group_name, express_route_p | |||
ports = client.get(resource_group_name, express_route_port_name) | |||
|
|||
ManagedServiceIdentity, ManagedServiceIdentityUserAssignedIdentitiesValue = \ | |||
cmd.get_models('ManagedServiceIdentity', 'ManagedServiceIdentityUserAssignedIdentitiesValue') | |||
cmd.get_models('ManagedServiceIdentity', 'Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties') # pylint: disable=line-too-long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserassignedidentitiesAdditionalproperties [](start = 50, length = 98)
It's an autorest/swagger issue, and will fix it future PR once the SDK is fixed.
# legacy implementation | ||
return _legacy_generate_vpn_client(client, resource_group_name, virtual_network_gateway_name, params, polling=ARMPolling(lro_options={'final-state-via': 'location'})) | ||
return client.begin_generatevpnclientpackage(resource_group_name, virtual_network_gateway_name, params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use SDK method directly now and no need to write own method to call rest api.
@@ -899,7 +899,7 @@ def load_arguments(self, _): | |||
c.argument('floating_ip', help='Enable floating IP.', arg_type=get_three_state_flag()) | |||
c.argument('idle_timeout', help='Idle timeout in minutes.', type=int) | |||
c.argument('protocol', help='Network transport protocol.', arg_type=get_enum_type(TransportProtocol)) | |||
c.argument('private_ip_address_version', min_api='2019-04-01', help='The private IP address version to use.', default=IPVersion.ipv4.value if IPVersion else '') | |||
c.argument('private_ip_address_version', min_api='2019-04-01', help='The private IP address version to use.', default=IPVersion.I_PV4.value if IPVersion else '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name change by track2 SDK.
@@ -234,7 +234,8 @@ def find_autorest_generated_folder(module_prefix="azure.mgmt"): | |||
track2_packages = [ | |||
'azure.mgmt.keyvault', | |||
'azure.mgmt.storage', | |||
'azure.mgmt.compute' | |||
'azure.mgmt.compute', | |||
'azure.mgmt.network' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add package here to pass CI.
vnet_gateway = VirtualNetworkGateway( | ||
gateway_type=gateway_type, vpn_type=vpn_type, vpn_gateway_generation=vpn_gateway_generation, location=location, | ||
tags=tags, sku=VirtualNetworkGatewaySku(name=sku, tier=sku), active_active=active_active, ip_configurations=[], | ||
tags=tags, sku=VirtualNetworkGatewaySku(name=sku, tier=sku), active=active, ip_configurations=[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why property name changed? Is it normal for Track 2 SDK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, most are not changed. I think it's due to track2 codegen logic change.
# self.cmd('network application-gateway show -g {rg} -n {gateway}', | ||
# checks=self.check('length(backendHttpSettingsCollection[1].trustedRootCertificates)', 2)) | ||
# self.cmd('network application-gateway http-settings update -g {rg} --gateway-name {gateway} -n {settings} --no-wait') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why mark these lines as comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, comment out accidentally and will uncomment and record this test.
@@ -6008,15 +6036,15 @@ def create_vnet_peering(cmd, resource_group_name, virtual_network_name, virtual_ | |||
use_remote_gateways=use_remote_gateways) | |||
aux_subscription = parse_resource_id(remote_virtual_network)['subscription'] | |||
ncf = network_client_factory(cmd.cli_ctx, aux_subscriptions=[aux_subscription]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aux_subscriptions
will stop working for Track 2 SDKs due to SDK limitation Azure/azure-sdk-for-python#8313.
Description
Here are main changes for Network migration to track2:
begin_xxx_xxx
, for example in track1, the name iscreate_or_update
; while in track2, the name isbegin_create_or_update
.begin_create_or_update
.HttpResponseError
instead ofCloudError
.ipv4
toI_PV4
.--no-wait
.Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.