-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Adding support for IP Connect and partial for Quick connect. #5800
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
66ff916
Initial changes for ipconnect and quickconnect
aavalang ffc3268
adding endpoints for quickconnect/developer sku
aavalang 5696bfc
stlying fixes
aavalang db01bd8
adding constant file with enum for skus
aavalang 8a8c448
Documentation and final changes
aavalang 58c5e85
Documentation and final changes
aavalang 3441d0e
Documentation and final changes
aavalang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: disable=import-error,unused-import | ||
|
|
||
| from enum import Enum | ||
|
|
||
|
|
||
| class BastionSku(Enum): | ||
|
|
||
| Basic = "Basic" | ||
| Standard = "Standard" | ||
| Developer = "Developer" | ||
| QuickConnect = "QuickConnect" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import ipaddress | ||
| from azure.cli.core.azclierror import InvalidArgumentValueError | ||
|
|
||
|
|
||
| def validate_ip_address(namespace): | ||
| if namespace.target_ip_address is not None: | ||
| _validate_ip_address_format(namespace) | ||
|
|
||
|
|
||
| def _validate_ip_address_format(namespace): | ||
| if namespace.target_ip_address is not None: | ||
| input_value = namespace.target_ip_address | ||
| if ' ' in input_value: | ||
| raise InvalidArgumentValueError("Spaces not allowed: '{}' ".format(input_value)) | ||
| input_ips = input_value.split(',') | ||
| if len(input_ips) > 8: | ||
| raise InvalidArgumentValueError('Maximum 8 IP addresses are allowed per rule.') | ||
| validated_ips = '' | ||
| for ip in input_ips: | ||
| # Use ipaddress library to validate ip network format | ||
| ip_obj = ipaddress.ip_network(ip) | ||
| validated_ips += str(ip_obj) + ',' | ||
| namespace.target_ip_address = validated_ips[:-1] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: disable=import-error,unused-import | ||
|
|
||
|
|
||
| def _get_data_pod(cmd, resource_port, target_resource_id, bastion): | ||
| from azure.cli.core._profile import Profile | ||
| from azure.cli.core.util import should_disable_connection_verify | ||
| import requests | ||
|
|
||
| profile = Profile(cli_ctx=cmd.cli_ctx) | ||
| auth_token, _, _ = profile.get_raw_token() | ||
| content = { | ||
| 'resourceId': target_resource_id, | ||
| 'bastionResourceId': bastion.id, | ||
| 'vmPort': resource_port, | ||
| 'azToken': auth_token[1], | ||
| 'connectionType': 'nativeclient' | ||
| } | ||
| headers = {'Content-Type': 'application/json'} | ||
|
|
||
| web_address = f"https://{bastion['dnsName']}/api/connection" | ||
| response = requests.post(web_address, json=content, headers=headers, | ||
| verify=(not should_disable_connection_verify())) | ||
|
|
||
| return response.content.decode("utf-8") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.