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

Test track 2 changes #35

Closed
wants to merge 3 commits into from
Closed
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
14 changes: 10 additions & 4 deletions k8s-custom-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ stages:
python3 -m venv env/
source env/bin/activate

# clone azure-cli
pip install --upgrade pip
pip install azdev

ls $(CLI_REPO_PATH)

azdev --version
azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME)

# clone azure-cli
git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli

azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) -c ../azure-cli
azdev extension build $(EXTENSION_NAME)

workingDirectory: $(CLI_REPO_PATH)
Expand Down Expand Up @@ -196,14 +199,17 @@ stages:
python3 -m venv env/
source env/bin/activate

# clone azure-cli
pip install --upgrade pip
pip install azdev

ls $(CLI_REPO_PATH)

azdev --version
azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME)

# clone azure-cli
git clone -q --single-branch -b dev https://github.com/Azure/azure-cli.git ../azure-cli

azdev setup -r $(CLI_REPO_PATH) -e $(EXTENSION_NAME) -c ../azure-cli
azdev extension build $(EXTENSION_NAME)
workingDirectory: $(CLI_REPO_PATH)
displayName: "Setup and Build Extension with azdev"
Expand Down
3 changes: 2 additions & 1 deletion src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ def __create_identity(cmd, resource_group_name, cluster_name, cluster_type, clus
"Error! Cluster type '{}' is not supported for extension identity".format(cluster_type)
)

from azure.core.exceptions import HttpResponseError
try:
resource = resources.get_by_id(cluster_resource_id, parent_api_version)
location = str(resource.location.lower())
except CloudError as ex:
except HttpResponseError as ex:
raise ex
identity_type = "SystemAssigned"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,16 @@ def _invoke_deployment(cmd, resource_group_name, deployment_name, template, para
logger.info(json.dumps(template, indent=2))
logger.info('==== END TEMPLATE ====')

if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
deployment_temp = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = deployment_temp(properties=properties)

if validate:
validation_poller = smc.validate(resource_group_name, deployment_name, deployment)
deployment_temp = cmd.get_models('Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
deployment = deployment_temp(properties=properties)
if validate:
if cmd.supported_api_version(min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES):
validation_poller = smc.begin_validate(resource_group_name, deployment_name, deployment)
return LongRunningOperation(cmd.cli_ctx)(validation_poller)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, deployment)
else:
return smc.validate(resource_group_name, deployment_name, deployment)

if validate:
return smc.validate(resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, smc.create_or_update, resource_group_name, deployment_name, properties)
return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)


def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
Expand Down Expand Up @@ -201,6 +199,9 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
"usgovvirginia": "usgovvirginia"
}

from azure.core.exceptions import HttpResponseError
from azure.cli.core.profiles import ResourceType

cluster_location = ''
resources = cf_resources(cmd.cli_ctx, subscription_id)

Expand All @@ -209,7 +210,7 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
try:
resource = resources.get_by_id(cluster_resource_id, '2020-01-01-preview')
cluster_location = resource.location.lower()
except CloudError as ex:
except HttpResponseError as ex:
raise ex

cloud_name = cmd.cli_ctx.cloud.name.lower()
Expand Down Expand Up @@ -261,23 +262,18 @@ def _ensure_default_log_analytics_workspace_for_monitoring(cmd, subscription_id,
try:
resource = resources.get_by_id(default_workspace_resource_id, '2015-11-01-preview')
return resource.id
except CloudError as ex:
except HttpResponseError as ex:
if ex.status_code != 404:
raise ex
else:
resource_groups.create_or_update(default_workspace_resource_group, {
'location': workspace_region})

default_workspace_params = {
'location': workspace_region,
'properties': {
'sku': {
'name': 'standalone'
}
}
}
async_poller = resources.create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
default_workspace_params)
ResourceGroup = cmd.get_models('ResourceGroup', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
resource_group = ResourceGroup(location=workspace_region)
resource_groups.create_or_update(default_workspace_resource_group, resource_group)

GenericResource = cmd.get_models('GenericResource', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES)
generic_resource = GenericResource(location=workspace_region, properties={'sku': {'name': 'standalone'}})
async_poller = resources.begin_create_or_update_by_id(default_workspace_resource_id, '2015-11-01-preview',
generic_resource)

ws_resource_id = ''
while True:
Expand All @@ -294,11 +290,12 @@ def _ensure_container_insights_for_monitoring(cmd, workspace_resource_id):
parsed = parse_resource_id(workspace_resource_id)
subscription_id, resource_group = parsed["subscription"], parsed["resource_group"]

from azure.core.exceptions import HttpResponseError
resources = cf_resources(cmd.cli_ctx, subscription_id)
try:
resource = resources.get_by_id(workspace_resource_id, '2015-11-01-preview')
location = resource.location
except CloudError as ex:
except HttpResponseError as ex:
raise ex

unix_time_in_millis = int(
Expand Down