Skip to content
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

[Core] az: Cleaned up azure-stack multiprofiles support #30629

Draft
wants to merge 6 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
57 changes: 0 additions & 57 deletions azure-pipelines-full-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,6 @@ variables:
- template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/variables.yml

jobs:
- job: AutomationTest20200901
displayName: Automation Test (Profile 2020-09-01)
timeoutInMinutes: 120
pool:
name: ${{ variables.ubuntu_pool }}
strategy:
matrix:
Python39:
python.version: '3.9'
Python312:
python.version: '3.12'
steps:
- template: .azure-pipelines/templates/automation_test.yml
parameters:
pythonVersion: '$(python.version)'
profile: '2020-09-01-hybrid'
fullTest: true
jobName: 'FullTest'

- job: AutomationTest20190301
displayName: Automation Test (Profile 2019-03-01)
timeoutInMinutes: 120
pool:
name: ${{ variables.ubuntu_pool }}
strategy:
matrix:
Python39:
python.version: '3.9'
Python312:
python.version: '3.12'
steps:
- template: .azure-pipelines/templates/automation_test.yml
parameters:
pythonVersion: '$(python.version)'
profile: '2019-03-01-hybrid'
fullTest: true
jobName: 'FullTest'

- job: AutomationTest20180301
displayName: Automation Test (Profile 2018-03-01)
timeoutInMinutes: 120
pool:
name: ${{ variables.ubuntu_pool }}
strategy:
matrix:
Python39:
python.version: '3.9'
Python312:
python.version: '3.12'
steps:
- template: .azure-pipelines/templates/automation_test.yml
parameters:
pythonVersion: '$(python.version)'
profile: '2018-03-01-hybrid'
fullTest: true
jobName: 'FullTest'

- job: AutomationFullTestPython39ProfileLatest
displayName: Automation Full Test Python39 Profile Latest
timeoutInMinutes: 9999
Expand Down
152 changes: 4 additions & 148 deletions src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,167 +265,23 @@ def default_api_version(self):
ResourceType.MGMT_APPCONTAINERS: '2022-10-01',
},
'2020-09-01-hybrid': {
ResourceType.MGMT_STORAGE: '2019-06-01',
ResourceType.MGMT_NETWORK: '2018-11-01',
ResourceType.MGMT_COMPUTE: SDKProfile('2020-06-01', {
'resource_skus': '2019-04-01',
'disks': '2019-07-01',
'disk_encryption_sets': '2019-07-01',
'disk_accesses': '2020-05-01',
'snapshots': '2019-07-01',
'galleries': '2019-12-01',
'gallery_images': '2019-12-01',
'gallery_image_versions': '2019-12-01',
'virtual_machine_scale_sets': '2020-06-01'
}),
ResourceType.MGMT_KEYVAULT: '2016-10-01',
ResourceType.MGMT_MSI: '2018-11-30',
ResourceType.MGMT_RESOURCE_FEATURES: '2021-07-01',
ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_POLICY: '2016-12-01',
ResourceType.MGMT_RESOURCE_RESOURCES: '2019-10-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
'classic_administrators': '2015-06-01',
'policy_assignments': '2016-12-01',
'policy_definitions': '2016-12-01'
}),
# The order does make things different.
# Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT
ResourceType.DATA_KEYVAULT_CERTIFICATES: None,
ResourceType.DATA_KEYVAULT_KEYS: None,
ResourceType.DATA_KEYVAULT_SECRETS: None,
ResourceType.DATA_STORAGE: '2018-11-09',
ResourceType.DATA_STORAGE_BLOB: '2019-07-07',
ResourceType.DATA_STORAGE_FILEDATALAKE: '2019-07-07',
ResourceType.DATA_STORAGE_FILESHARE: '2019-07-07',
ResourceType.DATA_STORAGE_QUEUE: '2019-07-07',
ResourceType.DATA_COSMOS_TABLE: '2017-04-17',
ResourceType.MGMT_APPSERVICE: '2018-02-01',
ResourceType.MGMT_EVENTHUB: '2022-01-01-preview',
ResourceType.MGMT_SERVICEBUS: '2022-10-01-preview',
ResourceType.MGMT_IOTHUB: '2019-07-01-preview',
ResourceType.MGMT_DATABOXEDGE: '2019-08-01',
ResourceType.MGMT_CONTAINERREGISTRY: '2019-05-01',
ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2020-11-01', {
'container_services': '2017-07-01',
'open_shift_managed_clusters': '2019-09-30-preview'
})
},
'2019-03-01-hybrid': {
ResourceType.MGMT_STORAGE: '2017-10-01',
ResourceType.MGMT_NETWORK: '2017-10-01',
ResourceType.MGMT_COMPUTE: SDKProfile('2017-12-01', {
'resource_skus': '2017-09-01',
'disks': '2017-03-30',
'snapshots': '2017-03-30'
}),
ResourceType.MGMT_MSI: '2018-11-30',
ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_POLICY: '2016-12-01',
ResourceType.MGMT_RESOURCE_RESOURCES: '2018-05-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_KEYVAULT: '2016-10-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
'classic_administrators': '2015-06-01',
'policy_assignments': '2016-12-01',
'policy_definitions': '2016-12-01'
}),
# The order does make things different.
# Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT
ResourceType.DATA_KEYVAULT_CERTIFICATES: None,
ResourceType.DATA_KEYVAULT_KEYS: None,
ResourceType.DATA_KEYVAULT_SECRETS: None,
ResourceType.DATA_STORAGE: '2017-11-09',
ResourceType.DATA_STORAGE_BLOB: '2017-11-09',
ResourceType.DATA_STORAGE_FILEDATALAKE: '2017-11-09',
ResourceType.DATA_STORAGE_FILESHARE: '2017-11-09',
ResourceType.DATA_STORAGE_QUEUE: '2017-11-09',
ResourceType.DATA_COSMOS_TABLE: '2017-04-17',
# Full MultiAPI support is not done in AppService, the line below is merely
# to have commands show up in the hybrid profile which happens to have the latest
# API versions
ResourceType.MGMT_APPSERVICE: '2018-02-01',
ResourceType.MGMT_EVENTHUB: '2022-01-01-preview',
ResourceType.MGMT_SERVICEBUS: '2022-10-01-preview',
ResourceType.MGMT_IOTHUB: '2019-03-22',
ResourceType.MGMT_DATABOXEDGE: '2019-08-01'
},
'2018-03-01-hybrid': {
ResourceType.MGMT_STORAGE: '2016-01-01',
ResourceType.MGMT_NETWORK: '2017-10-01',
ResourceType.MGMT_COMPUTE: SDKProfile('2017-03-30'),
ResourceType.MGMT_MSI: '2018-11-30',
ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_LOCKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_POLICY: '2016-12-01',
ResourceType.MGMT_RESOURCE_RESOURCES: '2018-02-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_KEYVAULT: '2016-10-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
'classic_administrators': '2015-06-01'
}),
# The order does make things different.
# Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT
ResourceType.DATA_KEYVAULT_CERTIFICATES: None,
ResourceType.DATA_KEYVAULT_KEYS: None,
ResourceType.DATA_KEYVAULT_SECRETS: None,
ResourceType.DATA_STORAGE: '2017-04-17',
ResourceType.DATA_STORAGE_BLOB: '2017-04-17',
ResourceType.DATA_STORAGE_FILEDATALAKE: '2017-04-17',
ResourceType.DATA_STORAGE_FILESHARE: '2017-04-17',
ResourceType.DATA_STORAGE_QUEUE: '2017-04-17',
ResourceType.DATA_COSMOS_TABLE: '2017-04-17'
},
'2017-03-09-profile': {
ResourceType.MGMT_STORAGE: '2016-01-01',
ResourceType.MGMT_NETWORK: '2015-06-15',
ResourceType.MGMT_COMPUTE: SDKProfile('2016-03-30'),
ResourceType.MGMT_MSI: '2018-11-30',
ResourceType.MGMT_RESOURCE_LINKS: '2016-09-01',
ResourceType.MGMT_RESOURCE_LOCKS: '2015-01-01',
ResourceType.MGMT_RESOURCE_POLICY: '2015-10-01-preview',
ResourceType.MGMT_RESOURCE_RESOURCES: '2016-02-01',
ResourceType.MGMT_RESOURCE_SUBSCRIPTIONS: '2016-06-01',
ResourceType.MGMT_RESOURCE_PRIVATELINKS: '2020-05-01',
ResourceType.MGMT_RESOURCE_TEMPLATESPECS: '2015-01-01',
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
ResourceType.MGMT_KEYVAULT: '2016-10-01',
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
'classic_administrators': '2015-06-01'
}),
# The order does make things different.
# Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT
ResourceType.DATA_KEYVAULT_CERTIFICATES: None,
ResourceType.DATA_KEYVAULT_KEYS: None,
ResourceType.DATA_KEYVAULT_SECRETS: None,
ResourceType.DATA_STORAGE: '2015-04-05',
ResourceType.DATA_STORAGE_BLOB: '2015-04-05',
ResourceType.DATA_STORAGE_FILEDATALAKE: '2015-04-05',
ResourceType.DATA_STORAGE_FILESHARE: '2015-04-05',
ResourceType.DATA_STORAGE_QUEUE: '2015-04-05'
}
}


# We should avoid using ad hoc API versions,
# use the version in a profile as much as possible.
AD_HOC_API_VERSIONS = {
ResourceType.MGMT_IOTHUB: {
# src/azure-cli/azure/cli/command_modules/iot/custom.py:1206
'iot_hub_resource': '2019-07-01-preview',
},
ResourceType.MGMT_APPSERVICE: {
# src/azure-cli/azure/cli/command_modules/appservice/_constants.py:68
'app_service_certificate_orders': '2022-09-01'
Expand Down
37 changes: 0 additions & 37 deletions src/azure-cli-core/azure/cli/core/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,37 +763,6 @@ def test_normalize(self):
# verify serialization works
self.assertIsNotNone(json.dumps(consolidated[0]))

def test_normalize_v2016_06_01(self):
cli = DummyCli()
storage_mock = {'subscriptions': None}
profile = Profile(cli_ctx=cli, storage=storage_mock)
from azure.mgmt.resource.subscriptions.v2016_06_01.models import Subscription \
as Subscription_v2016_06_01
subscription = Subscription_v2016_06_01()
subscription.id = self.id1
subscription.display_name = self.display_name1
subscription.state = self.state1
subscription.tenant_id = self.tenant_id

consolidated = profile._normalize_properties(self.user1, [subscription], False)

# The subscription shouldn't have managed_by_tenants and home_tenant_id
expected = {
'id': '1',
'name': self.display_name1,
'state': 'Enabled',
'user': {
'name': '[email protected]',
'type': 'user'
},
'isDefault': False,
'tenantId': self.tenant_id,
'environmentName': 'AzureCloud'
}
self.assertEqual(expected, consolidated[0])
# verify serialization works
self.assertIsNotNone(json.dumps(consolidated[0]))

def test_update_add_two_different_subscriptions(self):
cli = DummyCli()
storage_mock = {'subscriptions': []}
Expand Down Expand Up @@ -1537,12 +1506,6 @@ def __init__(self, tenant_id, display_name=MOCK_TENANT_DISPLAY_NAME, default_dom


class TestUtils(unittest.TestCase):
def test_attach_token_tenant_v2016_06_01(self):
from azure.mgmt.resource.subscriptions.v2016_06_01.models import Subscription
subscription = Subscription()
_attach_token_tenant(subscription, "token_tenant_1")
self.assertEqual(subscription.tenant_id, "token_tenant_1")
self.assertFalse(hasattr(subscription, "home_tenant_id"))

def test_attach_token_tenant_v2022_12_01(self):
from azure.mgmt.resource.subscriptions.v2022_12_01.models import Subscription
Expand Down

This file was deleted.

Loading
Loading