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

Location data #2

Merged
merged 79 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
85aa7d9
Added 2020 version models and operations
Mar 24, 2020
d345685
Updated with key pair generation
Mar 29, 2020
4e90290
review of public private key pair
Apr 1, 2020
836e6fc
updated models with latest changes in swagger
Apr 4, 2020
a1bea49
Update CLI to support SPN less onboarding
Apr 7, 2020
6522421
Removed location data changes
Apr 13, 2020
dec8fab
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
9bd5580
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
854b36f
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
576704d
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
b26a0eb
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
6d445c3
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
9df8269
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
031639b
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
47ca292
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
b237d9c
Update src/connectedk8s/azext_connectedk8s/custom.py
akashkeshari Apr 21, 2020
6249ea7
Updated error messages
Apr 21, 2020
5223949
resolved a conflict
Apr 21, 2020
c1ecbf8
updated wrt style checks
Apr 21, 2020
f43ebfb
Added a recorded test
Apr 21, 2020
32c5089
Updated with latest master changes
Apr 21, 2020
a97f36e
Updated imports
Apr 21, 2020
025522c
removed python 2.x from setup.py
Apr 21, 2020
1967b02
Updated format.py
Apr 21, 2020
df87f51
Updated readme file
Apr 22, 2020
b747e92
Updated test file
Apr 22, 2020
9d9c954
updated setup.py
Apr 22, 2020
2db8c30
updated knack version in setup.py
Apr 22, 2020
bd26f72
updated knack version to 0.7.0rc4 in setup.py
Apr 22, 2020
9dbfa0b
Updated test file to pass kubeconfig
Apr 23, 2020
c45a3a6
Updated test file to pass kubeconfig
Apr 23, 2020
f27610a
Added async support for delete
Apr 24, 2020
9852a51
Added helm charts to test data folder
Apr 27, 2020
ddad5b7
Updated helm chart pull method
Apr 27, 2020
6e6cd75
corrected import order
Apr 27, 2020
eb723fb
Ran connectedk8s test
Apr 27, 2020
a5407c1
Updated some print statements
Apr 27, 2020
3b8f930
ran test with helm upgrade --install
Apr 27, 2020
9f72a47
Updated print to warning
Apr 27, 2020
5515568
Updated error message
Apr 27, 2020
fac6740
Updated exceptions to be generic
Apr 28, 2020
e0f5022
Added aks creation in tests
Apr 29, 2020
c9d1071
updated warning statements
Apr 29, 2020
3b78ee8
updated test to create aks cluster with ssh keys
Apr 29, 2020
96a2cbe
added spn calls in recorded tests
Apr 29, 2020
2c7b8b3
Updated api-version in recorded tests
Apr 29, 2020
b9fdd1e
removed mc delete as CI test needs it to be persistant
Apr 29, 2020
cfb21ab
switched to livescenariotest
Apr 29, 2020
005e414
updated params.py
Apr 30, 2020
ba268a1
corrected databricks change
Apr 30, 2020
0ff1943
updated pod monitoring
Apr 30, 2020
d77e433
updated identation
Apr 30, 2020
44f4547
updated print statement to warnings
Apr 30, 2020
3fa9b10
added telemetry code for connect cli
May 6, 2020
5c56299
Added exception telemetry for delete operation
May 12, 2020
47fc01b
Updated with latest master
May 12, 2020
9239f83
Updated setup.py
May 12, 2020
ccdbff0
Changed default kubernetes distro
May 12, 2020
e6333d7
Distro detect.
pasankav May 12, 2020
1ef6cdd
Updated history
May 13, 2020
c1612c2
removed arm resourceid from telemetry
May 13, 2020
db1f4bd
Kubernetes connect cli telemetry integration (#1684)
akashkeshari May 13, 2020
5ed8f5d
bump vmware to 0.6.0 (#1656)
cataggar May 13, 2020
9943139
download from az-csvmware-cli (#1681)
cataggar May 13, 2020
feb1883
[Release] Update index.json for extension [ connectedk8s ] (#1689)
May 14, 2020
fb40791
AKS: add aks-custom-headers for nodepool and update (#1686)
andyzhangx May 14, 2020
3ed99da
Merge branch 'akash/connect_telemetry' into pavan/distro_detect
pasankav May 14, 2020
8a92c0c
[Release] Update index.json for extension [ aks-preview ] (#1699)
May 14, 2020
8b26810
Add kubernetes distro and identifying it.
pasankav May 14, 2020
df6806d
K8s configuration update min cli core version (#1697)
NarayanThiru May 14, 2020
87cbfa1
Add "Did You Mean This" Extension (#1692)
christopher-o-toole May 15, 2020
6bb06a7
[Release] Update index.json for extension [ k8sconfiguration ] (#1700)
May 15, 2020
fdacc2b
Remove additional line.
pasankav May 15, 2020
3860c00
correct indentation.
pasankav May 15, 2020
b9b4915
Merge branch 'master' into pavan/distro_detect
pasankav May 15, 2020
f8c4e04
correct indentation.
pasankav May 15, 2020
b752e92
correct version number.
pasankav May 15, 2020
9404057
Merge pull request #5 from akashkeshari/pavan/distro_detect
akashkeshari May 18, 2020
669071f
Merge pull request #4 from akashkeshari/akash/connect_telemetry
akashkeshari May 18, 2020
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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,6 @@

/src/kusto/ @ilayr @orhasban @astauben

/src/ai-did-you-mean-this/ @christopher-o-toole

/src/custom-providers/ @jsntcy
Binary file removed UpgradeLog.htm
Binary file not shown.
10 changes: 10 additions & 0 deletions src/ai-did-you-mean-this/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. :changelog:

Release History
===============

0.1.0
++++++
* Initial release.
* Add autogenerated recommendations for recovery from UserFault failures.
* Ensure that the hook is activated in common UserFault failure scenarios.
91 changes: 91 additions & 0 deletions src/ai-did-you-mean-this/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Microsoft Azure CLI 'AI Did You Mean This' Extension #

### Installation ###
To install the extension, use the below CLI command
```
az extension add --name ai-did-you-mean-this
```

### Background ###
The purpose of this extension is help users recover from failure. Once installed, failure recovery recommendations will automatically be provided for supported command failures. In cases where no recommendations are available, a prompt to use `az find` will be shown provided that the command can be matched to a valid CLI command.
### Limitations ###
For now, recommendations are limited to parser failures (i.e. not in a command group, argument required, unrecognized parameter, expected one argument, etc). Support for more core failures is planned for a future release.
### Try it out! ###
The following examples demonstrate how to trigger the extension. For a more complete list of supported CLI failure types, see this [CLI PR](https://github.com/Azure/azure-cli/pull/12889). Keep in mind that the recommendations shown here may be different from the ones that you receive.

#### az account ####
```
> az account
az account: error: the following arguments are required: _subcommand
usage: az account [-h]
{list,set,show,clear,list-locations,get-access-token,lock,management-group}
...

Here are the most common ways users succeeded after [account] failed:
az account list
az account show
```

#### az account set ####
```
> az account set
az account set: error: the following arguments are required: --subscription/-s
usage: az account set [-h] [--verbose] [--debug] [--only-show-errors]
[--output {json,jsonc,yaml,yamlc,table,tsv,none}]
[--query JMESPATH] --subscription SUBSCRIPTION

Here are the most common ways users succeeded after [account set] failed:
az account set --subscription Subscription
```

#### az group create ####
```
>az group create
az group create: error: the following arguments are required: --name/--resource-group/-n/-g, --location/-l
usage: az group create [-h] [--verbose] [--debug] [--only-show-errors]
[--output {json,jsonc,yaml,yamlc,table,tsv,none}]
[--query JMESPATH] [--subscription _SUBSCRIPTION]
--name RG_NAME --location LOCATION
[--tags [TAGS [TAGS ...]]] [--managed-by MANAGED_BY]

Here are the most common ways users succeeded after [group create] failed:
az group create --location westeurope --resource-group MyResourceGroup
```
#### az vm list ###
```
> az vm list --query ".id"
az vm list: error: argument --query: invalid jmespath_type value: '.id'
usage: az vm list [-h] [--verbose] [--debug] [--only-show-errors]
[--output {json,jsonc,yaml,yamlc,table,tsv,none}]
[--query JMESPATH] [--subscription _SUBSCRIPTION]
[--resource-group RESOURCE_GROUP_NAME] [--show-details]

Sorry I am not able to help with [vm list]
Try running [az find "az vm list"] to see examples of [vm list] from other users.
```
### Developer Build ###
If you want to try an experimental release of the extension, it is recommended you do so in a [Docker container](https://www.docker.com/resources/what-container). Keep in mind that you'll need to install Docker and pull the desired [Azure CLI image](https://hub.docker.com/_/microsoft-azure-cli) from the Microsoft Container Registry before proceeding.

#### Setting up your Docker Image ####
To run the Azure CLI Docker image as an interactive shell, run the below command by replacing `<version>` with your desired CLI version
```bash
docker run -it mcr.microsoft.com/azure-cli:<version>
export EXT="ai-did-you-mean-this"
pip install --upgrade --target ~/.azure/cliextensions/$EXT "git+https://github.com/christopher-o-toole/azure-cli-extensions.git@thoth-extension#subdirectory=src/$EXT&egg=$EXT"
```
Each time you start a new shell, you'll need to login before you can start using the extension. To do so, run
```bash
az login
```
and follow the instructions given in the prompt. Once you're logged in, try out the extension by issuing a faulty command
```
> az account
az account: error: the following arguments are required: _subcommand
usage: az account [-h]
{list,set,show,clear,list-locations,get-access-token,lock,management-group}
...

Here are the most common ways users succeeded after [account] failed:
az account list
az account show
```
52 changes: 52 additions & 0 deletions src/ai-did-you-mean-this/azext_ai_did_you_mean_this/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader

from knack.events import (
EVENT_INVOKER_CMD_TBL_LOADED
)

from azext_ai_did_you_mean_this._help import helps # pylint: disable=unused-import
from azext_ai_did_you_mean_this._cmd_table import on_command_table_loaded


def inject_functions_into_core():
from azure.cli.core.parser import AzCliCommandParser
from azext_ai_did_you_mean_this.custom import recommend_recovery_options
AzCliCommandParser.recommendation_provider = recommend_recovery_options


# pylint: disable=too-few-public-methods
class GlobalConfig():
ENABLE_STYLING = False


class AiDidYouMeanThisCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType

ai_did_you_mean_this_custom = CliCommandType(
operations_tmpl='azext_ai_did_you_mean_this.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=ai_did_you_mean_this_custom)
self.cli_ctx.register_event(EVENT_INVOKER_CMD_TBL_LOADED, on_command_table_loaded)
inject_functions_into_core()
# per https://github.com/Azure/azure-cli/pull/12601
try:
GlobalConfig.ENABLE_STYLING = cli_ctx.enable_color
except AttributeError:
pass

def load_command_table(self, args):
from azext_ai_did_you_mean_this.commands import load_command_table
load_command_table(self, args)
return self.command_table

def load_arguments(self, command):
pass


COMMAND_LOADER_CLS = AiDidYouMeanThisCommandsLoader
13 changes: 13 additions & 0 deletions src/ai-did-you-mean-this/azext_ai_did_you_mean_this/_cmd_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


class CommandTable(): # pylint: disable=too-few-public-methods
CMD_TBL = None


def on_command_table_loaded(_, **kwargs):
cmd_tbl = kwargs.pop('cmd_tbl', None)
CommandTable.CMD_TBL = cmd_tbl
34 changes: 34 additions & 0 deletions src/ai-did-you-mean-this/azext_ai_did_you_mean_this/_const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

UPDATE_RECOMMENDATION_STR = (
"Better failure recovery recommendations are available from the latest version of the CLI. "
"Please update for the best experience.\n"
)

UNABLE_TO_HELP_FMT_STR = (
'\nSorry I am not able to help with [{command}]'
'\nTry running [az find "az {command}"] to see examples of [{command}] from other users.'
)

RECOMMENDATION_HEADER_FMT_STR = (
'\nHere are the most common ways users succeeded after [{command}] failed:'
)

TELEMETRY_MUST_BE_ENABLED_STR = (
'User must agree to telemetry before failure recovery recommendations can be presented.'
)

TELEMETRY_MISSING_SUBSCRIPTION_ID_STR = (
"Subscription ID was not set in telemetry."
)

TELEMETRY_MISSING_CORRELATION_ID_STR = (
"Correlation ID was not set in telemetry."
)

UNABLE_TO_CALL_SERVICE_STR = (
'Either the subscription ID or correlation ID was not set. Aborting operation.'
)
17 changes: 17 additions & 0 deletions src/ai-did-you-mean-this/azext_ai_did_you_mean_this/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from knack.help_files import helps # pylint: disable=unused-import

helps['ai-did-you-mean-this'] = """
type: group
short-summary: Add recommendations for recovering from failure.
"""

helps['ai-did-you-mean-this version'] = """
type: command
short-summary: Prints the extension version.
"""
28 changes: 28 additions & 0 deletions src/ai-did-you-mean-this/azext_ai_did_you_mean_this/_style.py
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 sys

from azext_ai_did_you_mean_this import GlobalConfig


def style_message(msg):
if should_enable_styling():
import colorama # pylint: disable=import-error

try:
msg = colorama.Style.BRIGHT + msg + colorama.Style.RESET_ALL
except KeyError:
pass
return msg


def should_enable_styling():
try:
if GlobalConfig.ENABLE_STYLING and sys.stdout.isatty():
return True
except AttributeError:
pass
return False
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.4.0"
}
12 changes: 12 additions & 0 deletions src/ai-did-you-mean-this/azext_ai_did_you_mean_this/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long


def load_command_table(self, _):

with self.command_group('ai-did-you-mean-this', is_preview=True) as g:
g.custom_command('version', 'show_extension_version')
Loading