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-loganalytics to 12.0.0 #888

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
1 change: 1 addition & 0 deletions plugins/module_utils/azure_rm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ def log_analytics_client(self):
self.log('Getting log analytics client')
if not self._log_analytics_client:
self._log_analytics_client = self.get_mgmt_svc_client(LogAnalyticsManagementClient,
is_track2=True,
base_url=self._cloud_environment.endpoints.resource_manager)
return self._log_analytics_client

Expand Down
22 changes: 11 additions & 11 deletions plugins/modules/azure_rm_loganalyticsworkspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
try:
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase, format_resource_id
from msrestazure.tools import parse_resource_id
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
except ImportError:
# This is handled in azure_rm_common
pass
Expand Down Expand Up @@ -260,21 +260,21 @@ def exec_module(self, **kwargs):

def create_workspace(self, workspace):
try:
poller = self.log_analytics_client.workspaces.create_or_update(self.resource_group, self.name, workspace)
poller = self.log_analytics_client.workspaces.begin_create_or_update(self.resource_group, self.name, workspace)
return self.get_poller_result(poller)
except CloudError as exc:
except Exception as exc:
self.fail('Error when creating workspace {0} - {1}'.format(self.name, exc.message or str(exc)))

def get_workspace(self):
try:
return self.log_analytics_client.workspaces.get(self.resource_group, self.name)
except CloudError:
except ResourceNotFoundError:
pass

def delete_workspace(self):
try:
self.log_analytics_client.workspaces.delete(self.resource_group, self.name, force=self.force)
except CloudError as exc:
self.log_analytics_client.workspaces.begin_delete(self.resource_group, self.name, force=self.force)
except Exception as exc:
self.fail('Error when deleting workspace {0} - {1}'.format(self.name, exc.message or str(exc)))

def to_dict(self, workspace):
Expand All @@ -286,7 +286,7 @@ def list_intelligence_packs(self):
try:
response = self.log_analytics_client.intelligence_packs.list(self.resource_group, self.name)
return [x.as_dict() for x in response]
except CloudError as exc:
except Exception as exc:
self.fail('Error when listing intelligence packs {0}'.format(exc.message or str(exc)))

def change_intelligence(self, key, value):
Expand All @@ -295,7 +295,7 @@ def change_intelligence(self, key, value):
self.log_analytics_client.intelligence_packs.enable(self.resource_group, self.name, key)
else:
self.log_analytics_client.intelligence_packs.disable(self.resource_group, self.name, key)
except CloudError as exc:
except Exception as exc:
self.fail('Error when changing intelligence pack {0} - {1}'.format(key, exc.message or str(exc)))

def list_management_groups(self):
Expand All @@ -306,7 +306,7 @@ def list_management_groups(self):
result.append(response.next().as_dict())
except StopIteration:
pass
except CloudError as exc:
except Exception as exc:
self.fail('Error when listing management groups {0}'.format(exc.message or str(exc)))
return result

Expand All @@ -318,14 +318,14 @@ def list_usages(self):
result.append(response.next().as_dict())
except StopIteration:
pass
except CloudError as exc:
except Exception as exc:
self.fail('Error when listing usages {0}'.format(exc.message or str(exc)))
return result

def get_shared_keys(self):
try:
return self.log_analytics_client.shared_keys.get_shared_keys(self.resource_group, self.name).as_dict()
except CloudError as exc:
except Exception as exc:
self.fail('Error when getting shared key {0}'.format(exc.message or str(exc)))


Expand Down
14 changes: 7 additions & 7 deletions plugins/modules/azure_rm_loganalyticsworkspace_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
try:
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase, format_resource_id
from msrestazure.tools import parse_resource_id
from msrestazure.azure_exceptions import CloudError
from azure.core.exceptions import ResourceNotFoundError
except ImportError:
# This is handled in azure_rm_common
pass
Expand Down Expand Up @@ -196,22 +196,22 @@ def exec_module(self, **kwargs):
def get_workspace(self):
try:
return self.log_analytics_client.workspaces.get(self.resource_group, self.name)
except CloudError:
except ResourceNotFoundError:
pass
return None

def list_by_resource_group(self):
try:
return self.log_analytics_client.resource_group.list(self.resource_group)
except CloudError:
except Exception:
pass
return []

def list_intelligence_packs(self):
try:
response = self.log_analytics_client.intelligence_packs.list(self.resource_group, self.name)
return [x.as_dict() for x in response]
except CloudError as exc:
except Exception as exc:
self.fail('Error when listing intelligence packs {0}'.format(exc.message or str(exc)))

def list_management_groups(self):
Expand All @@ -222,7 +222,7 @@ def list_management_groups(self):
result.append(response.next().as_dict())
except StopIteration:
pass
except CloudError as exc:
except Exception as exc:
self.fail('Error when listing management groups {0}'.format(exc.message or str(exc)))
return result

Expand All @@ -234,14 +234,14 @@ def list_usages(self):
result.append(response.next().as_dict())
except StopIteration:
pass
except CloudError as exc:
except Exception as exc:
self.fail('Error when listing usages {0}'.format(exc.message or str(exc)))
return result

def get_shared_keys(self):
try:
return self.log_analytics_client.shared_keys.get_shared_keys(self.resource_group, self.name).as_dict()
except CloudError as exc:
except Exception as exc:
self.fail('Error when getting shared key {0}'.format(exc.message or str(exc)))

def to_dict(self, workspace):
Expand Down
2 changes: 1 addition & 1 deletion requirements-azure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ azure-graphrbac==0.61.1
azure-mgmt-cosmosdb==0.15.0
azure-mgmt-hdinsight==0.1.0
azure-mgmt-devtestlabs==3.0.0
azure-mgmt-loganalytics==1.0.0
azure-mgmt-loganalytics==12.0.0
azure-mgmt-automation==1.0.0
azure-mgmt-iothub==0.7.0
azure-mgmt-recoveryservices==0.4.0
Expand Down