Skip to content

Commit

Permalink
[Network] Application Gateway API 2017-06-01 support (#3938)
Browse files Browse the repository at this point in the history
* Customize app gateway SKU and capacity on VMSS create.

* Progress on new app-gateway commands.

* Add support for redirect configuration commands.

* Update `application-gateway ssl-policy set` command.

* Update existing commands to support new arguments.

* Re-record tests and fix linter silliness.

* Fix #3919.

* Fix VMSS create. Remove "MarkSpecified" action.

* CI fixes and parameter updates.
  • Loading branch information
tjprescott authored Jun 30, 2017
1 parent fa51648 commit 56bfba8
Show file tree
Hide file tree
Showing 102 changed files with 55,938 additions and 64,900 deletions.
8,798 changes: 0 additions & 8,798 deletions baseline_command_table.json

This file was deleted.

3 changes: 2 additions & 1 deletion src/azure-cli-core/azure/cli/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def register_cli_argument(self, *args, **kwargs):
register_cli_argument(*args, **kwargs)
else:
from azure.cli.core.commands.parameters import ignore_type
kwargs = {'arg_type': ignore_type}
kwargs = {}
args = tuple([args[0], args[1], ignore_type])
register_cli_argument(*args, **kwargs)

def register_extra_cli_argument(self, *args, **kwargs):
Expand Down
45 changes: 38 additions & 7 deletions src/azure-cli-core/azure/cli/core/commands/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import argparse
import time
import random
from azure.cli.core.profiles import ResourceType
Expand Down Expand Up @@ -61,12 +60,44 @@ def validate_file_or_dict(string):
return shell_safe_json_parse(string)


SPECIFIED_SENTINEL = '__SET__'
def validate_parameter_set(namespace, required, forbidden, dest_to_options=None, description=None):
""" validates that a given namespace contains the specified required parameters and does not contain any of
the provided forbidden parameters (unless the value came from a default). """

missing_required = [x for x in required if not getattr(namespace, x)]
included_forbidden = [x for x in forbidden if getattr(namespace, x) and
not hasattr(getattr(namespace, x), 'is_default')]
if missing_required or included_forbidden:
from azure.cli.core.util import CLIError

class MarkSpecifiedAction(argparse.Action): # pylint: disable=too-few-public-methods
""" Use this to identify when a parameter is explicitly set by the user (as opposed to a
default). You must remove the __SET__ sentinel substring in a follow-up validator."""
def _dest_to_option(dest):
try:
return dest_to_options[dest]
except (KeyError, TypeError):
# assume the default dest to option
return '--{}'.format(dest).replace('_', '-')

def __call__(self, parser, args, values, option_string=None):
setattr(args, self.dest, '{}{}'.format(SPECIFIED_SENTINEL, values))
error = 'invalid usage{}{}'.format(' for ' if description else ':', description)
if missing_required:
missing_string = ', '.join(_dest_to_option(x) for x in missing_required)
error = '{}\n\tmissing: {}'.format(error, missing_string)
if included_forbidden:
forbidden_string = ', '.join(_dest_to_option(x) for x in included_forbidden)
error = '{}\n\tnot applicable: {}'.format(error, forbidden_string)
raise CLIError(error)


class DefaultStr(str):

def __new__(cls, *args, **kwargs):
instance = str.__new__(cls, *args, **kwargs)
instance.is_default = True
return instance


class DefaultInt(int):

def __new__(cls, *args, **kwargs):
instance = int.__new__(cls, *args, **kwargs)
instance.is_default = True
return instance
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, import_prefix, client_name):
AZURE_API_PROFILES = {
'latest': {
ResourceType.MGMT_STORAGE: '2016-12-01',
ResourceType.MGMT_NETWORK: '2017-03-01',
ResourceType.MGMT_NETWORK: '2017-06-01',
ResourceType.MGMT_CONTAINER_SERVICE: '2017-01-31',
ResourceType.MGMT_COMPUTE: '2016-04-30-preview',
ResourceType.MGMT_RESOURCE_FEATURES: '2015-12-01',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ interactions:
AZURECLI/2.0.6+dev]
accept-language: [en-US]
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/virtualNetworks?api-version=2017-03-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/virtualNetworks?api-version=2017-06-01
response:
body: {string: '{"value":[]}'}
headers:
Expand Down Expand Up @@ -437,7 +437,7 @@ interactions:
AZURECLI/2.0.6+dev]
accept-language: [en-US]
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/networkInterfaces/vm1VMNic?api-version=2017-03-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/networkInterfaces/vm1VMNic?api-version=2017-06-01
response:
body: {string: "{\r\n \"name\": \"vm1VMNic\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/networkInterfaces/vm1VMNic\"\
,\r\n \"etag\": \"W/\\\"875c08df-09dc-45da-852a-65ce884c6447\\\"\",\r\n \
Expand Down Expand Up @@ -488,7 +488,7 @@ interactions:
AZURECLI/2.0.6+dev]
accept-language: [en-US]
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/publicIPAddresses/vm1PublicIP?api-version=2017-03-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/publicIPAddresses/vm1PublicIP?api-version=2017-06-01
response:
body: {string: "{\r\n \"name\": \"vm1PublicIP\",\r\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_monitor000001/providers/Microsoft.Network/publicIPAddresses/vm1PublicIP\"\
,\r\n \"etag\": \"W/\\\"913f9ae8-8ea2-430d-b2b5-54bfe7d7e9d5\\\"\",\r\n \
Expand Down
15 changes: 15 additions & 0 deletions src/command_modules/azure-cli-network/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
Release History
===============

unreleased
++++++++++++++++++
* `application-gateway address-pool create/update`: fix bug when using the `--servers` argument.
* `application-gateway`: add `redirect-config` commands
* `application-gateway ssl-policy`: add `list-options`, `predefined list` and `predefined show` commands
* `application-gateway ssl-policy set`: new arguments `--name`, `--cipher-suites`, `--min-protocol-version`
* `application-gateway http-settings create/update`: new arguments `--host-name-from-backend-pool`, `--affinity-cookie-name`,
`--enable-probe`, `--path`
* `application-gateway url-path-map create/update`: new arguments `--default-redirect-config`, `--redirect-config`
* `application-gateway url-path-map rule create`: new argument `--redirect-config`
* `application-gateway url-path-map rule delete`: add support for `--no-wait`
* `application-gateway probe create/update`: new arguments `--host-name-from-http-settings`, `--min-servers`, `--match-body`, `--match-status-codes`
* `application-gateway rule create/update`: new argument `--redirect-config`


2.0.9 (2017-06-21)
++++++++++++++++++
* `nic create/update`: Add support for `--accelerated-networking`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,40 @@
"""
# endregion

# region Application Gateway redirect configuration

helps['network application-gateway redirect-config'] = """
type: group
short-summary: Manage redirect configurations.
"""

helps['network application-gateway redirect-config create'] = """
type: command
short-summary: Create a redirect configuration.
"""

helps['network application-gateway redirect-config delete'] = """
type: command
short-summary: Delete a redirect configuration.
"""

helps['network application-gateway redirect-config list'] = """
type: command
short-summary: List redirect configurations.
"""

helps['network application-gateway redirect-config show'] = """
type: command
short-summary: Show details of a redirect configuration.
"""

helps['network application-gateway redirect-config update'] = """
type: command
short-summary: Update a redirect configuration.
"""

# endregion

# region Application Gateway rules

helps['network application-gateway rule'] = """
Expand Down Expand Up @@ -391,12 +425,28 @@
helps['network application-gateway ssl-policy set'] = """
type: command
short-summary: Update or clear SSL policy settings.
parameters:
- name: --cipher-suites
populator-commands:
- az network application-gateway ssl-policy list-options
- name: --disabled-ssl-protocols
populator-commands:
- az network application-gateway ssl-policy list-options
- name: --min-protocol-version
populator-commands:
- az network application-gateway ssl-policy list-options
"""

helps['network application-gateway ssl-policy show'] = """
type: command
short-summary: Show the SSL policy settings.
"""

helps['network application-gateway ssl-policy predefined'] = """
type: group
short-summary: Information on predefined SSL policies.
"""

# endregion

# region Application Gateway URL path map
Expand Down
Loading

0 comments on commit 56bfba8

Please sign in to comment.