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

add omsagent rename changes #143

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,15 @@ def Delete(self, cmd, client, resource_group_name, cluster_name, name, cluster_t
cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}'.format(subscription_id, resource_group_name, cluster_rp, cluster_type, cluster_name)
if (extension is not None) and (extension.configuration_settings is not None):
configSettings = extension.configuration_settings
# omsagent is being renamed to ama-logs. Check for both for compatibility
if 'omsagent.useAADAuth' in configSettings:
useAADAuthSetting = configSettings['omsagent.useAADAuth']
if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting):
useAADAuth = True
elif 'amalogs.useAADAuth' in configSettings:
useAADAuthSetting = configSettings['amalogs.useAADAuth']
if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting):
useAADAuth = True
if useAADAuth:
association_url = cmd.cli_ctx.cloud.endpoints.resource_manager + f"{cluster_resource_id}/providers/Microsoft.Insights/dataCollectionRuleAssociations/ContainerInsightsExtension?api-version=2021-04-01"
for _ in range(3):
Expand Down Expand Up @@ -453,11 +458,17 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r
if 'logAnalyticsWorkspaceResourceID' in configuration_settings:
workspace_resource_id = configuration_settings['logAnalyticsWorkspaceResourceID']

# omsagent is being renamed to ama-logs. Check for both for compatibility
if 'omsagent.useAADAuth' in configuration_settings:
useAADAuthSetting = configuration_settings['omsagent.useAADAuth']
logger.info("provided useAADAuth flag is : %s", useAADAuthSetting)
if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting):
useAADAuth = True
elif 'amalogs.useAADAuth' in configuration_settings:
useAADAuthSetting = configuration_settings['amalogs.useAADAuth']
logger.info("provided useAADAuth flag is : %s", useAADAuthSetting)
if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting):
useAADAuth = True

workspace_resource_id = workspace_resource_id.strip()

Expand All @@ -473,7 +484,9 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r
'proxyEndpoint url should in this format http(s)://<user>:<pwd>@<proxyhost>:<port>'
)
logger.info("successfully validated proxyEndpoint url hence passing proxy endpoint to extension")
# omsagent is being renamed to ama-logs. Set for both for compatibility
configuration_protected_settings['omsagent.proxy'] = configuration_protected_settings['proxyEndpoint']
configuration_protected_settings['amalogs.proxy'] = configuration_protected_settings['proxyEndpoint']

if not workspace_resource_id:
workspace_resource_id = _ensure_default_log_analytics_workspace_for_monitoring(
Expand Down Expand Up @@ -509,20 +522,28 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_r
if not shared_keys:
raise InvalidArgumentValueError('Failed to retrieve shared key for workspace {}'.format(
log_analytics_workspace))
# omsagent is being renamed to ama-logs. Set for both for compatibility
configuration_protected_settings['omsagent.secret.key'] = shared_keys.primary_shared_key
configuration_protected_settings['amalogs.secret.key'] = shared_keys.primary_shared_key
# omsagent is being renamed to ama-logs. Set for both for compatibility
configuration_protected_settings['omsagent.secret.wsid'] = log_analytics_workspace.customer_id
configuration_protected_settings['amalogs.secret.wsid'] = log_analytics_workspace.customer_id
configuration_settings['logAnalyticsWorkspaceResourceID'] = workspace_resource_id

# set the domain for the ci agent for non azure public clouds
cloud_name = cmd.cli_ctx.cloud.name
if cloud_name.lower() == 'azurechinacloud':
configuration_settings['omsagent.domain'] = 'opinsights.azure.cn'
configuration_settings['amalogs.domain'] = 'opinsights.azure.cn'
elif cloud_name.lower() == 'azureusgovernment':
configuration_settings['omsagent.domain'] = 'opinsights.azure.us'
configuration_settings['amalogs.domain'] = 'opinsights.azure.us'
elif cloud_name.lower() == 'usnat':
configuration_settings['omsagent.domain'] = 'opinsights.azure.eaglex.ic.gov'
configuration_settings['amalogs.domain'] = 'opinsights.azure.eaglex.ic.gov'
elif cloud_name.lower() == 'ussec':
configuration_settings['omsagent.domain'] = 'opinsights.azure.microsoft.scloud'
configuration_settings['amalogs.domain'] = 'opinsights.azure.microsoft.scloud'


def get_existing_container_insights_extension_dcr_tags(cmd, dcr_url):
Expand Down