|
10 | 10 |
|
11 | 11 | from azure.cli.core.commands.client_factory import get_subscription_id |
12 | 12 | from azure.cli.core.util import sdk_no_wait |
13 | | -from azure.cli.command_modules.acs._roleassignments import add_role_assignment |
14 | 13 |
|
15 | 14 | from azext_fleet._client_factory import CUSTOM_MGMT_FLEET |
16 | | -from azext_fleet._helpers import print_or_merge_credentials |
| 15 | +from azext_fleet._helpers import print_or_merge_credentials, validate_subnet |
17 | 16 | from azext_fleet.constants import UPGRADE_TYPE_CONTROLPLANEONLY |
18 | 17 | from azext_fleet.constants import UPGRADE_TYPE_FULL |
19 | 18 | from azext_fleet.constants import UPGRADE_TYPE_NODEIMAGEONLY |
20 | 19 | from azext_fleet.constants import UPGRADE_TYPE_ERROR_MESSAGES |
21 | | -from azext_fleet.constants import FLEET_1P_APP_ID |
22 | 20 |
|
23 | 21 |
|
24 | 22 | # pylint: disable=too-many-locals |
@@ -112,19 +110,9 @@ def create_fleet(cmd, |
112 | 110 | ) |
113 | 111 |
|
114 | 112 | if enable_private_cluster: |
115 | | - if not add_role_assignment(cmd, 'Network Contributor', FLEET_1P_APP_ID, scope=agent_subnet_id): |
116 | | - raise CLIError( |
117 | | - "failed to create role assignment for Fleet RP.\nDo you have owner permissions on the vnet?\n" |
118 | | - "Is the Microsoft.Containerservice namespace registered?\n" |
119 | | - "Please try registering Fleet namespace before retrying: az provider register --namespace 'Microsoft.Containerservice'" # pylint: disable=line-too-long |
120 | | - ) |
| 113 | + validate_subnet(cmd, resource_group_name, agent_subnet_id) |
121 | 114 | if enable_vnet_integration: |
122 | | - if not add_role_assignment(cmd, 'Network Contributor', FLEET_1P_APP_ID, scope=apiserver_subnet_id): |
123 | | - raise CLIError( |
124 | | - "failed to create role assignment for Fleet RP.\nDo you have owner permissions on the vnet?\n" |
125 | | - "Is the Microsoft.Containerservice namespace registered?\n" |
126 | | - "Please try registering Fleet namespace before retrying: az provider register --namespace 'Microsoft.Containerservice'" # pylint: disable=line-too-long |
127 | | - ) |
| 115 | + validate_subnet(cmd, resource_group_name, apiserver_subnet_id) |
128 | 116 |
|
129 | 117 | return sdk_no_wait(no_wait, |
130 | 118 | client.begin_create_or_update, |
|
0 commit comments