-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ Workload-Orchestration ] Add Context & Solution Management Commands #9037
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
9 commits
Select commit
Hold shift + click to select a range
90ba129
added
f1d3177
commit
e62546b
Made Changes
24dec62
Added change
348944e
Made changes
6cf5c0f
List solution revisions and instances
manaswita-chichili a21fab5
Merge branch 'audapure/deltas' of https://github.com/atharvau/azure-cβ¦
2ca1ede
Made changes rr
34a8a04
Made change
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
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
68 changes: 68 additions & 0 deletions
68
...zext_workload_orchestration/aaz/latest/workload_orchestration/context/_current_context.py
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,68 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
| @register_command( | ||
| "workload-orchestration context current", | ||
| ) | ||
| class CurrentContext(AAZCommand): | ||
| """Show current context information | ||
| :example: Show current context | ||
| az workload-orchestration context current | ||
| """ | ||
|
|
||
| _aaz_info = { | ||
| "version": "2025-06-01" | ||
| } | ||
|
|
||
| def _handler(self, command_args): | ||
| super()._handler(command_args) | ||
| self._execute_operations() | ||
| return self._output() | ||
|
|
||
| _args_schema = None | ||
|
|
||
| @classmethod | ||
| def _build_arguments_schema(cls, *args, **kwargs): | ||
| if cls._args_schema is not None: | ||
| return cls._args_schema | ||
| cls._args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
| return cls._args_schema | ||
|
|
||
| def _execute_operations(self): | ||
| self.pre_operations() | ||
| # No operations needed - just reading config | ||
| self.post_operations() | ||
|
|
||
| @register_callback | ||
| def pre_operations(self): | ||
| pass | ||
|
|
||
| @register_callback | ||
| def post_operations(self): | ||
| pass | ||
|
|
||
| def _output(self, *args, **kwargs): | ||
| context_id = self.ctx.cli_ctx.config.get('workload_orchestration', 'context_id', None) | ||
| context_name = self.ctx.cli_ctx.config.get('workload_orchestration', 'context_name', None) | ||
| resource_group = self.ctx.cli_ctx.config.get('workload_orchestration', 'resource_group', None) | ||
|
|
||
| if not context_id or not context_name or not resource_group: | ||
| return "No current context is set" | ||
|
|
||
| return { | ||
| "contextId": context_id, | ||
| "name": context_name, | ||
| "resourceGroup": resource_group | ||
| } | ||
|
|
||
| class _CurrentContextHelper: | ||
| """Helper class for CurrentContext""" | ||
|
|
||
| __all__ = ["CurrentContext"] |
82 changes: 82 additions & 0 deletions
82
...on/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_set_context.py
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,82 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
|
|
||
| @register_command( | ||
| "workload-orchestration context set", | ||
| ) | ||
| class SetContext(AAZCommand): | ||
| """Set current context using context ID | ||
| :example: Set a Context using ID | ||
| az workload-orchestration context set --id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Edge/contexts/myContext | ||
| """ | ||
|
|
||
| _aaz_info = { | ||
| "version": "2025-06-01" | ||
| } | ||
|
|
||
| def _handler(self, command_args): | ||
| super()._handler(command_args) | ||
| self._execute_operations() | ||
| return self._output() | ||
|
|
||
| _args_schema = None | ||
|
|
||
| @classmethod | ||
| def _build_arguments_schema(cls, *args, **kwargs): | ||
| if cls._args_schema is not None: | ||
| return cls._args_schema | ||
| cls._args_schema = super()._build_arguments_schema(*args, **kwargs) | ||
|
|
||
| _args_schema = cls._args_schema | ||
| _args_schema.context_id = AAZStrArg( | ||
| options=["--id"], | ||
| help="The full resource ID of the Context.", | ||
| required=True | ||
| ) | ||
| return cls._args_schema | ||
|
|
||
| def _execute_operations(self): | ||
| self.pre_operations() | ||
| # Extract context name and resource group from ID | ||
| # ID format: /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Edge/contexts/{name} | ||
| context_id = self.ctx.args.context_id.to_serialized_data() | ||
| parts = context_id.split('/') | ||
| if len(parts) != 9 or parts[6] != 'Microsoft.Edge' or parts[7] != 'contexts': | ||
| raise CLIInternalError("Invalid context ID format") | ||
|
|
||
atharvau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| context_name = parts[8] | ||
| resource_group = parts[4] | ||
|
|
||
| self.post_operations() | ||
|
|
||
| @register_callback | ||
| def pre_operations(self): | ||
| pass | ||
|
|
||
| @register_callback | ||
| def post_operations(self): | ||
| pass | ||
|
|
||
| def _output(self, *args, **kwargs): | ||
| context_id = self.ctx.args.context_id.to_serialized_data() | ||
| parts = context_id.split('/') | ||
| context_name = parts[8] | ||
| resource_group = parts[4] | ||
|
|
||
| self.ctx.cli_ctx.config.set_value('workload_orchestration', 'context_id', context_id) | ||
| self.ctx.cli_ctx.config.set_value('workload_orchestration', 'context_name', context_name) | ||
| self.ctx.cli_ctx.config.set_value('workload_orchestration', 'resource_group', resource_group) | ||
|
|
||
| return f"Successfully set current context using ID '{self.ctx.args.context_id}'" | ||
|
|
||
| class _SetContextHelper: | ||
| """Helper class for SetContext""" | ||
|
|
||
| __all__ = ["SetContext"] | ||
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
Oops, something went wrong.
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.