Skip to content

Commit

Permalink
Merge pull request #10 from am-lim/amlim/updateDataPlanev2023-10-01
Browse files Browse the repository at this point in the history
Update data plane tests and version
  • Loading branch information
am-lim committed Nov 5, 2023
2 parents 518c40e + a384a1a commit 24aca31
Show file tree
Hide file tree
Showing 15 changed files with 14,192 additions and 2,136 deletions.
5 changes: 5 additions & 0 deletions src/devcenter/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release History
===============
4.0.0
++++++
* Update control plane API to v2023-10-01-preview
* Update data plane API to v2023-10-01-preview

3.0.0
++++++
* Update control plane API to v2023-06-01-preview
Expand Down
4 changes: 3 additions & 1 deletion src/devcenter/azext_devcenter/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ def validate_env_name_already_exists(env_iterator, name, user_id, project):


def is_iso8601(namespace):
if namespace.expiration_date is None:
return
try:
datetime.fromisoformat(namespace.expiration_date)
return True
return
except ValueError as exception:
error_message = f"""The expiration date is invalid '{namespace.expiration_date}' \
it must be in ISO 8601 format. For example: 2023-12-30T22:35:00+00:00"""
Expand Down
21 changes: 15 additions & 6 deletions src/devcenter/azext_devcenter/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# pylint: disable=protected-access

from datetime import datetime
import json
from azure.cli.core.aaz import has_value
from azure.cli.core.aaz import register_callback
from azure.cli.core.azclierror import ResourceNotFoundError
Expand Down Expand Up @@ -973,10 +974,10 @@ def devcenter_environment_list(
)

if user_id is not None:
return cf_dataplane.deployment_environments.list_all_environments(
return cf_dataplane.deployment_environments.list_environments(
project_name=project_name, user_id=user_id
)
return cf_dataplane.deployment_environments.list_environments(
return cf_dataplane.deployment_environments.list_all_environments(
project_name=project_name
)

Expand Down Expand Up @@ -1022,7 +1023,8 @@ def devcenter_environment_create(
body["environmentType"] = environment_type
body["catalogName"] = catalog_name
body["environmentDefinitionName"] = environment_definition_name
body["expirationDate"] = datetime.fromisoformat(expiration_date)
if expiration_date is not None:
body["expirationDate"] = datetime.fromisoformat(expiration_date)
return sdk_no_wait(
no_wait,
cf_dataplane.deployment_environments.begin_create_or_update_environment,
Expand Down Expand Up @@ -1056,7 +1058,8 @@ def devcenter_environment_update(
body["environmentType"] = environment["environmentType"]
body["catalogName"] = environment["catalogName"]
body["environmentDefinitionName"] = environment["environmentDefinitionName"]
body["expirationDate"] = datetime.fromisoformat(expiration_date)
if expiration_date is not None:
body["expirationDate"] = datetime.fromisoformat(expiration_date)
return sdk_no_wait(
no_wait,
cf_dataplane.deployment_environments.begin_create_or_update_environment,
Expand Down Expand Up @@ -1191,12 +1194,17 @@ def devcenter_environment_operation_show_logs_by_operation(
cmd.cli_ctx, endpoint, dev_center, project_name
)

return cf_dataplane.environments.get_logs_by_operation(
logs = cf_dataplane.environments.get_logs_by_operation(
project_name=project_name,
operation_id=operation_id,
user_id=user_id,
environment_name=environment_name,
)
logs_array = []
for log in logs:
logs_string = json.loads(log)
logs_array.append(logs_string)
return logs_array


def devcenter_environment_operation_show_action(
Expand Down Expand Up @@ -1313,7 +1321,8 @@ def devcenter_environment_operation_update_environment(
cmd.cli_ctx, endpoint, dev_center, project_name
)
body = {}
body["expirationDate"] = datetime.fromisoformat(expiration_date)
if expiration_date is not None:
body["expirationDate"] = datetime.fromisoformat(expiration_date)

return cf_dataplane.environments.patch_environment(
project_name=project_name,
Expand Down
31 changes: 19 additions & 12 deletions src/devcenter/azext_devcenter/tests/latest/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# --------------------------------------------------------------------------
import time


def create_dev_center(self):
dev_center = self.cmd(
"az devcenter admin devcenter create "
Expand Down Expand Up @@ -75,6 +76,7 @@ def create_virtual_network_with_subnet(self):
'az network vnet subnet create --nsg "{nsgName}" -n "{subnetName}" --vnet-name "{vNetName}" -g "{rg}" --address-prefixes "10.0.0.0/21"'
).get_output_in_json()


def create_virtual_network_with_subnet_euap(self):
self.kwargs.update(
{
Expand All @@ -84,14 +86,19 @@ def create_virtual_network_with_subnet_euap(self):
}
)

self.cmd('az network vnet create -n "{vNetName}" --location "canadacentral" -g "{rg}"')
self.cmd(
'az network vnet create -n "{vNetName}" --location "canadacentral" -g "{rg}"'
)

self.cmd('az network nsg create -n "{nsgName}" --location "canadacentral" -g "{rg}"')
self.cmd(
'az network nsg create -n "{nsgName}" --location "canadacentral" -g "{rg}"'
)

return self.cmd(
'az network vnet subnet create --nsg "{nsgName}" -n "{subnetName}" --vnet-name "{vNetName}" -g "{rg}" --address-prefixes "10.0.0.0/21"'
).get_output_in_json()


def create_sig(self):
self.kwargs.update(
{
Expand Down Expand Up @@ -228,9 +235,9 @@ def get_endpoint(self):


def create_network_connection(self):
if (self.kwargs.get('location', '') == "centraluseuap"):
if self.kwargs.get("location", "") == "centraluseuap":
subnet = create_virtual_network_with_subnet_euap(self)
else:
else:
subnet = create_virtual_network_with_subnet(self)
self.kwargs.update(
{
Expand Down Expand Up @@ -259,9 +266,9 @@ def create_network_connection(self):


def create_network_connection_dp(self):
if (self.kwargs.get('location', '') == "centraluseuap"):
if self.kwargs.get("location", "") == "centraluseuap":
subnet = create_virtual_network_with_subnet_euap(self)
else:
else:
subnet = create_virtual_network_with_subnet(self)

self.kwargs.update(
Expand Down Expand Up @@ -366,6 +373,7 @@ def create_env_type(self):
],
)


def get_aad_id(self):
if self.is_live:
user = self.cmd('az ad user show --id "{userName}"').get_output_in_json()
Expand Down Expand Up @@ -394,7 +402,7 @@ def add_dev_box_user_role_to_project(self):
time.sleep(180)


def create_pool(self):
def create_pool(self):
create_network_connection_dp(self)
imageRefId = f"{self.kwargs.get('devCenterId', '')}/galleries/Default/images/MicrosoftWindowsDesktop_windows-ent-cpc_win11-22h2-ent-cpc-os"

Expand Down Expand Up @@ -476,7 +484,7 @@ def catalog_create_and_sync_cmds(self):
"catalogName": self.create_random_name(prefix="c2", length=12),
"branch": "main",
"path": "/Environments",
"secretIdentifier": "https://dummy.fake.net/secrets/dummy/0000000000000000000000000000000",
"secretIdentifier": "https://dummy.fake.net/secrets/dummy/00000000000000000000000000000007",
"uri": "https://domain.com/dummy/dummy.git",
}
)
Expand All @@ -497,6 +505,7 @@ def catalog_create_and_sync_cmds(self):
'--resource-group "{rg}" '
)


def create_catalog_control_plane(self):
create_dev_center_with_identity(self)
create_kv_policy(self)
Expand Down Expand Up @@ -611,7 +620,5 @@ def create_dev_box_dependencies(self):


def login_account(self):
if (self.is_live):
self.cmd(
"az login -t 003b06c3-d471-4452-9686-9e7f3ca85f0a"
)
if self.is_live:
self.cmd("az login -t 003b06c3-d471-4452-9686-9e7f3ca85f0a")
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,7 @@ interactions:
User-Agent:
- azsdk-python-developer-devcenter/1.0.0b3 Python/3.10.7 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs?api-version=2023-07-01-preview
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs?api-version=2023-10-01-preview
response:
body:
string: "{\n \"value\": [\n {\n \"name\": \"c2000005\"\n }\n ]\n\
Expand Down Expand Up @@ -1625,7 +1625,7 @@ interactions:
User-Agent:
- azsdk-python-developer-devcenter/1.0.0b3 Python/3.10.7 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs/c2000005?api-version=2023-07-01-preview
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs/c2000005?api-version=2023-10-01-preview
response:
body:
string: "{\n \"name\": \"c2000005\"\n}"
Expand Down Expand Up @@ -1661,7 +1661,7 @@ interactions:
User-Agent:
- azsdk-python-developer-devcenter/1.0.0b3 Python/3.10.7 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs?api-version=2023-07-01-preview
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs?api-version=2023-10-01-preview
response:
body:
string: "{\n \"value\": [\n {\n \"name\": \"c2000005\"\n }\n ]\n\
Expand Down Expand Up @@ -1698,7 +1698,7 @@ interactions:
User-Agent:
- azsdk-python-developer-devcenter/1.0.0b3 Python/3.10.7 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs/c2000005?api-version=2023-07-01-preview
uri: https://003b06c3-d471-4452-9686-9e7f3ca85f0a-cli000002.canadacentral.devcenter.azure.com/projects/cli000004/catalogs/c2000005?api-version=2023-10-01-preview
response:
body:
string: "{\n \"name\": \"c2000005\"\n}"
Expand Down
Loading

0 comments on commit 24aca31

Please sign in to comment.