-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Knack conversion for lab module (#5068)
* initial lab knack convert * username validator to commands.py * resource-group to resource_group_name to get argtype bindings * cleaned up params * tranformers to _format, fixed precedence of client_factory kwarg, style, validators * enabled style/static check * bug with if no command_type * addressed comments, fixed transformers * flake * Operations template path periods
- Loading branch information
1 parent
dc3f6bf
commit 262361e
Showing
13 changed files
with
438 additions
and
465 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
59 changes: 59 additions & 0 deletions
59
src/command_modules/azure-cli-lab/azure/cli/command_modules/lab/_format.py
This file contains 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,59 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
from collections import OrderedDict | ||
|
||
|
||
def export_artifacts(formula): | ||
""" Exports artifacts from the given formula. This method removes some of the properties of the | ||
artifact model as they do not play important part for users in create or read context. | ||
""" | ||
artifacts = [] | ||
if formula and formula.formula_content and formula.formula_content.artifacts: | ||
artifacts = formula.formula_content.artifacts | ||
for artifact in formula.formula_content.artifacts: | ||
del artifact.status | ||
del artifact.deployment_status_message | ||
del artifact.vm_extension_status_message | ||
del artifact.install_time | ||
return artifacts | ||
|
||
|
||
def transform_artifact_source_list(artifact_source_list): | ||
return [transform_artifact_source(v) for v in artifact_source_list] | ||
|
||
|
||
def transform_artifact_source(result): | ||
return OrderedDict([('name', result['name']), | ||
('sourceType', result['sourceType']), | ||
('status', result.get('status')), | ||
('uri', result.get('uri'))]) | ||
|
||
|
||
def transform_arm_template_list(arm_template_list): | ||
return [transform_arm_template(v) for v in arm_template_list] | ||
|
||
|
||
def transform_arm_template(result): | ||
return OrderedDict([('name', result['name']), | ||
('resourceGroup', result['resourceGroup']), | ||
('publisher', result.get('publisher'))]) | ||
|
||
|
||
def transform_vm_list(vm_list): | ||
return [_transform_vm_dict(v) for v in vm_list] | ||
|
||
|
||
def _transform_vm_dict(result): | ||
return OrderedDict([('name', result['name']), | ||
('location', result['location']), | ||
('osType', result['osType'])]) | ||
|
||
|
||
def transform_vm(result): | ||
return OrderedDict([('name', result.name), | ||
('location', result.location), | ||
('osType', result.os_type)]) |
This file contains 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.