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

Upgrade azure-mgmt-managedservices to 6.0.0 #948

Merged
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions plugins/modules/azure_rm_registrationassignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@
import uuid
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ext import AzureRMModuleBaseExt
try:
from msrestazure.azure_exceptions import CloudError
from azure.mgmt.managedservices import ManagedServicesClient
from msrestazure.azure_operation import AzureOperationPoller
from msrest.polling import LROPoller
from azure.core.polling import LROPoller
except ImportError:
# This is handled in azure_rm_common
pass
Expand Down Expand Up @@ -191,6 +190,7 @@ def exec_module(self, **kwargs):
self.mgmt_client = self.get_mgmt_svc_client(ManagedServicesClient,
base_url=self._cloud_environment.endpoints.resource_manager,
api_version='2019-09-01',
is_track2=True,
suppress_subscription_id=True)

old_response = self.get_resource()
Expand Down Expand Up @@ -235,22 +235,21 @@ def exec_module(self, **kwargs):

def create_update_resource(self):
try:
response = self.mgmt_client.registration_assignments.create_or_update(scope=self.scope,
registration_assignment_id=self.registration_assignment_id,
properties=self.body.get('properties', None),
request_body=self.body)
response = self.mgmt_client.registration_assignments.begin_create_or_update(scope=self.scope,
registration_assignment_id=self.registration_assignment_id,
request_body=self.body)
if isinstance(response, AzureOperationPoller) or isinstance(response, LROPoller):
response = self.get_poller_result(response)
except CloudError as exc:
except Exception as exc:
self.log('Error attempting to create the RegistrationAssignment instance.')
self.fail('Error creating the RegistrationAssignment instance: {0}'.format(str(exc)))
return response.as_dict()

def delete_resource(self):
try:
response = self.mgmt_client.registration_assignments.delete(scope=self.scope,
registration_assignment_id=self.registration_assignment_id)
except CloudError as e:
response = self.mgmt_client.registration_assignments.begin_delete(scope=self.scope,
registration_assignment_id=self.registration_assignment_id)
except Exception as e:
self.log('Error attempting to delete the RegistrationAssignment instance.')
self.fail('Error deleting the RegistrationAssignment instance: {0}'.format(str(e)))

Expand Down
1 change: 1 addition & 0 deletions plugins/modules/azure_rm_registrationassignment_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def exec_module(self, **kwargs):
self.mgmt_client = self.get_mgmt_svc_client(ManagedServicesClient,
base_url=self._cloud_environment.endpoints.resource_manager,
api_version='2020-09-01',
is_track2=True,
suppress_subscription_id=True)

if (self.scope is not None and self.registration_assignment_id is not None):
Expand Down
18 changes: 9 additions & 9 deletions plugins/modules/azure_rm_registrationdefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,9 @@
import uuid
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ext import AzureRMModuleBaseExt
try:
from msrestazure.azure_exceptions import CloudError
from azure.mgmt.managedservices import ManagedServicesClient
from msrestazure.azure_operation import AzureOperationPoller
from msrest.polling import LROPoller
from azure.core.polling import LROPoller
except ImportError:
# This is handled in azure_rm_common
pass
Expand Down Expand Up @@ -368,6 +367,7 @@ def exec_module(self, **kwargs):
self.mgmt_client = self.get_mgmt_svc_client(ManagedServicesClient,
base_url=self._cloud_environment.endpoints.resource_manager,
api_version='2019-09-01',
is_track2=True,
suppress_subscription_id=True)

old_response = self.get_resource()
Expand Down Expand Up @@ -406,14 +406,14 @@ def exec_module(self, **kwargs):
def create_update_resource(self):

try:
response = self.mgmt_client.registration_definitions.create_or_update(registration_definition_id=self.registration_definition_id,
scope=self.scope,
plan=self.body.get('plan', None),
properties=self.body.get('properties', None),
request_body=self.body)
response = self.mgmt_client.registration_definitions.begin_create_or_update(
registration_definition_id=self.registration_definition_id,
scope=self.scope,
request_body=self.body)

if isinstance(response, AzureOperationPoller) or isinstance(response, LROPoller):
response = self.get_poller_result(response)
except CloudError as exc:
except Exception as exc:
self.log('Error attempting to create the RegistrationDefinition instance.')
self.fail('Error creating the RegistrationDefinition instance: {0}'.format(str(exc)))
return response.as_dict()
Expand All @@ -422,7 +422,7 @@ def delete_resource(self):
try:
response = self.mgmt_client.registration_definitions.delete(registration_definition_id=self.registration_definition_id,
scope=self.scope)
except CloudError as e:
except Exception as e:
self.log('Error attempting to delete the RegistrationDefinition instance.')
self.fail('Error deleting the RegistrationDefinition instance: {0}'.format(str(e)))

Expand Down
1 change: 1 addition & 0 deletions plugins/modules/azure_rm_registrationdefinition_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def exec_module(self, **kwargs):
self.mgmt_client = self.get_mgmt_svc_client(ManagedServicesClient,
base_url=self._cloud_environment.endpoints.resource_manager,
api_version='2019-09-01',
is_track2=True,
suppress_subscription_id=True)

if self.registration_definition_id is not None:
Expand Down
2 changes: 1 addition & 1 deletion requirements-azure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ azure-mgmt-dns==8.0.0
azure-mgmt-keyvault==2.2.0
azure-mgmt-marketplaceordering==0.1.0
azure-mgmt-monitor==3.0.0
azure-mgmt-managedservices==1.0.0
azure-mgmt-managedservices==6.0.0
azure-mgmt-managementgroups==0.2.0
azure-mgmt-network==19.1.0
azure-mgmt-nspkg==2.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

- name: Create a RegistrationDefinition with scope
azure_rm_registrationdefinition:
scope: "{{ subscription_sec_id }}"
scope: "{{ subscription_sec_id }}"
properties:
description: test definition with scope
authorizations:
Expand Down