Skip to content

Commit

Permalink
{Network} Connection monitor V2 preview (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianhui Harold committed Feb 4, 2020
1 parent 8b7af84 commit 0284ef6
Show file tree
Hide file tree
Showing 227 changed files with 207,519 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@
/src/connectedmachine/ @farehar

/src/ip-group/ @haroldrandom

/src/connection-monitor-preview/ @haroldrandom
12 changes: 12 additions & 0 deletions src/connection-monitor-preview/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Support to update connection-monitor with new V2 parameters set:
* `az network watcher connection-monitor endpoint add/remove`
* `az network watcher connection-monitor test-configuration add/remove`
* `az network watcher connection-monitor test-group add/remove`
* `az network watcher connection-monitor output add/remove`
19 changes: 19 additions & 0 deletions src/connection-monitor-preview/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Azure CLI Connection Monitor V2 Extension #
This is an extension to Azure CLI to manage Connection Monitor V2 preview features.
Connection monitor now supports to create V1 and V2 version of connection monitor.
- V1 connection monitor supports single source and destination endpoint which comes with V1 argument groups as usual. You can start/stop them.
- V2 connection monitor supports multiple endpoints and several test protocol which comes with V2 argument groups. You can disable/enable them in test group.

## How to use ##
First, install the extension:
```
az extension add --name connection-monitor-preview
```

Then, call the help to find out usage:
```
az network watcher connection-monitor -h
```

## Requirements ##
This extension requires `azure-cli >= 2.0.80` and support at most `azure-cli <= 2.0.82`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# --------------------------------------------------------------------------------------------
# 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 azure.cli.core.profiles import register_resource_type

from ._client_factory import cf_nw_connection_monitor
from ._help import helps # pylint: disable=unused-import


class NWConnectionMonitorCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from .profiles import CUSTOM_NW_CONNECTION_MONITOR

register_resource_type('latest', CUSTOM_NW_CONNECTION_MONITOR, '2019-11-01')

nw_connection_monitor = CliCommandType(
operations_tmpl='azext_connection_monitor_preview.custom#{}',
client_factory=cf_nw_connection_monitor
)

super(NWConnectionMonitorCommandsLoader, self).__init__(cli_ctx=cli_ctx,
custom_command_type=nw_connection_monitor,
resource_type=CUSTOM_NW_CONNECTION_MONITOR)

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

def load_arguments(self, command):
from ._params import load_arguments
load_arguments(self, command)


COMMAND_LOADER_CLS = NWConnectionMonitorCommandsLoader
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


def network_client_factory(cli_ctx, **_):
from .profiles import CUSTOM_NW_CONNECTION_MONITOR
from azure.cli.core.commands.client_factory import get_mgmt_service_client
return get_mgmt_service_client(cli_ctx, CUSTOM_NW_CONNECTION_MONITOR, api_version='2019-11-01')


def cf_nw_connection_monitor(cli_ctx, _):
return network_client_factory(cli_ctx).connection_monitors


def cf_nw_connection_monitor_v1(cli_ctx, **_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from .profiles import CUSTOM_NW_CONNECTION_MONITOR_V1
return get_mgmt_service_client(cli_ctx, CUSTOM_NW_CONNECTION_MONITOR_V1, api_version='2019-06-01')
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
# 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['network watcher connection-monitor create'] = """
type: command
short-summary: Create a connection monitor.
long-summary: |
This extension allow to create V1 and V2 version of connection monitor.
V1 connection monitor supports single source and destination endpoint which comes with V1 argument groups as usual.
V2 connection monitor supports multiple endpoints and several test protocol which comes with V2 argument groups.
parameters:
- name: --source-resource
short-summary: >
Currently only Virtual Machines are supported.
- name: --dest-resource
short-summary: >
Currently only Virtual Machines are supported.
examples:
- name: Create a connection monitor for a virtual machine.
text: |
az network watcher connection-monitor create -g MyResourceGroup -n MyConnectionMonitorName \\
--source-resource MyVM
- name: Create a V2 connection monitor
text: >
az network watcher connection-monitor create
--location westus
--name MyV2ConnectionMonitor
--endpoint-source-name "vm01"
--endpoint-source-resource-id MyVM01ResourceID
--endpoint-dest-name bing
--endpoint-dest-address bing.com
--test-config-name TCPTestConfig
--protocol Tcp
--tcp-port 2048
"""


helps['network watcher connection-monitor endpoint'] = """
type: group
short-summary: Manage endpoint of a connection monitor
"""

helps['network watcher connection-monitor endpoint add'] = """
type: command
short-summary: Add an endpoint to a connection monitor
examples:
- name: Add an endpoint as destination
text: >
az network watcher connection-monitor endpoint add
--connection-monitor MyConnectionMonitor
--location westus
--name MyEndpoint
--address "bing.com"
--dest-test-groups DefaultTestGroup
- name: Add an endpoint as source
text: >
az network watcher connection-monitor endpoint add
--connection-monitor MyConnectionMonitor
--location westus
--name MyEndpoint
--resource-id MyVMResourceID
--source-test-groups DefaultTestGroup
- name: Add an endpoint with filter
text: >
az network watcher connection-monitor endpoint add
--connection-monitor MyConnectionMonitor
--location westus
--name MyEndpoint
--resource-id MyLogAnalysisWorkSpaceID
--source-test-groups DefaultTestGroup
--filter-type Include
--filter-item type=AgentAddress address=npmuser
--filter-item type=AgentAddress address=pypiuser
"""

helps['network watcher connection-monitor endpoint remove'] = """
type: command
short-summary: Remove an endpoint from a connection monitor
examples:
- name: Remove endpoint from all test groups of a connection monitor
text: >
az network watcher connection-monitor endpoint remove
--connection-monitor MyConnectionMonitor
--location westus
--name MyEndpoint
- name: Remove endpoint from two test groups of a connection monitor
text: >
az network watcher connection-monitor endpoint remove
--connection-monitor MyConnectionMonitor
--location westus
--name MyEndpoint
--test-groups DefaultTestGroup HealthCheckTestGroup
"""

helps['network watcher connection-monitor endpoint show'] = """
type: command
short-summary: Show an endpoint from a connection monitor
"""

helps['network watcher connection-monitor endpoint list'] = """
type: command
short-summary: List all endpoints form a connection monitor
"""

helps['network watcher connection-monitor test-configuration'] = """
type: group
short-summary: Manage test configuration of a connection monitor
"""

helps['network watcher connection-monitor test-configuration add'] = """
type: command
short-summary: Add a test configuration to a connection monitor
examples:
- name: Add a test configuration with HTTP supported
text: >
az network watcher connection-monitor test-configuration add
--connection-monitor MyConnectionMonitor
--location westus
--name MyHTTPTestConfiguration
--test-groups DefaultTestGroup
--protocol Http
--http-request-header name=Host value=bing.com
--http-request-header name=UserAgent value=Edge
- name: Add a test configuration with TCP supported
text: >
az network watcher connection-monitor test-configuration add
--connection-monitor MyConnectionMonitor
--location westus
--name MyHTTPTestConfiguration
--test-groups TCPTestGroup DefaultTestGroup
--protocol Tcp
--tcp-port 4096
"""

helps['network watcher connection-monitor test-configuration remove'] = """
type: command
short-summary: Remove a test configuration from a connection monitor
examples:
- name: Remove a test configuration from all test groups of a connection monitor
text: >
az network watcher connection-monitor test-configuration remove
--connection-monitor MyConnectionMonitor
--location westus
--name MyTCPTestConfiguration
- name: Remove a test configuration from two test groups of a connection monitor
text: >
az network watcher connection-monitor test-configuration remove
--connection-monitor MyConnectionMonitor
--location westus
--name MyHTTPTestConfiguration
--test-groups HTTPTestGroup DefaultTestGroup
"""

helps['network watcher connection-monitor test-configuration show'] = """
type: command
short-summary: Show a test configuration from a connection monitor
"""

helps['network watcher connection-monitor test-configuration list'] = """
type: command
short-summary: List all test configurations of a connection monitor
"""

helps['network watcher connection-monitor test-group'] = """
type: group
short-summary: Manage a test group of a connection monitor
"""

helps['network watcher connection-monitor test-group add'] = """
type: command
short-summary: Add a test group along with new-added/existing endpoint and test configuration to a connection monitor
examples:
- name: Add a test group along with existing endpoint and test configuration via their names
text: >
az network watcher connection-monitor test-group add
--connection-monitor MyConnectionMonitor
--location westus
--name MyHTTPTestGroup
--endpoint-source-name MySourceEndpoint
--endpoint-dest-name MyDestinationEndpoint
--test-config-name MyTestConfiguration
- name: Add a test group long with new-added source endpoint and existing test configuration via its name
text: >
az network watcher connection-monitor test-group add
--connection-monitor MyConnectionMonitor
--location westus
--name MyAccessibilityTestGroup
--endpoint-source-name MySourceEndpoint
--endpoint-source-resource-id MyLogAnalysisWorkspaceID
--endpoint-dest-name MyExistingDestinationEndpoint
--test-config-name MyExistingTestConfiguration
- name: Add a test group along with new-added endpoints and test configuration
text: >
az network watcher connection-monitor test-group add
--connection-monitor MyConnectionMonitor
--location westus
--name MyAccessibilityTestGroup
--endpoint-source-name MySourceEndpoint
--endpoint-source-resource-id MyVMResourceID
--endpoint-dest-name bing
--endpoint-dest-address bing.com
--test-config-name MyNewTestConfiguration
--protocol Tcp
--tcp-port 4096
"""

helps['network watcher connection-monitor test-group remove'] = """
type: command
short-summary: Remove test group from a connection monitor
"""

helps['network watcher connection-monitor test-group show'] = """
type: command
short-summary: Show a test group of a connection monitor
"""

helps['network watcher connection-monitor test-group list'] = """
type: command
short-summary: List all test groups of a connection monitor
"""

helps['network watcher connection-monitor output'] = """
type: group
short-summary: Manage output of connection monitor
"""

helps['network watcher connection-monitor output add'] = """
type: command
short-summary: Add an output to a connection monitor
"""

helps['network watcher connection-monitor output remove'] = """
type: command
short-summary: Remove all outputs from a connection monitor
"""

helps['network watcher connection-monitor output list'] = """
type: command
short-summary: List all output from a connection monitor
"""
Loading

0 comments on commit 0284ef6

Please sign in to comment.