Skip to content

Commit

Permalink
Add acs module support for version 2017-07-01 (#4010)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjtsdl authored and derekbekoe committed Jul 13, 2017
1 parent 168a6b4 commit 2a59cee
Show file tree
Hide file tree
Showing 9 changed files with 542 additions and 547 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@ artifacts/

# local Azure configuration
.config/

# Python version
.python-version
5 changes: 5 additions & 0 deletions src/command_modules/azure-cli-acs/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release History
===============
unreleased
+++++++++++++++++++
* api version 2017-07-01 support
* update dcos and swarm to use latest api version instead of 2016-03-30

2.0.10 (2017-07-07)
+++++++++++++++++++
* minor fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@
type: command
short-summary: Download the DCOS/Kubernetes command line.
"""
helps['acs create'] = """
examples:
- name: Create a default acs cluster
text: az acs create -g MyResourceGroup -n MyContainerService
- name: Create a Kubernetes cluster
text: az acs create --orchestrator-type Kubernetes -g MyResourceGroup -n MyContainerService
- name: Create a Kubernetes cluster with ssh key provided
text: az acs create --orchestrator-type Kubernetes -g MyResourceGroup -n MyContainerService --ssh-key-value MySSHKeyValueOrPath
- name: Create a acs cluster with two agent pools
text: az acs create -g MyResourceGroup -n MyContainerService --agent-profiles "[{'name':'agentpool1'},{'name':'agentpool2'}]"
- name: Create a acs cluster with the second agent pool with vmSize specified
text: az acs create -g MyResourceGroup -n MyContainerService --agent-profiles "[{'name':'agentpool1'},{'name':'agentpool2','vmSize':'Standard_D2'}]"
"""
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
register_cli_argument,
register_extra_cli_argument)
from azure.cli.core.commands.parameters import tags_type
from azure.cli.core.commands.validators import validate_file_or_dict
from azure.cli.core.commands.parameters import (
enum_choice_list,
file_type,
resource_group_name_type,
get_one_of_subscription_locations,
get_resource_name_completion_list)
from azure.mgmt.compute.containerservice.models import ContainerServiceOrchestratorTypes
from azure.cli.command_modules.acs._validators import validate_create_parameters, validate_ssh_key
from azure.cli.command_modules.acs._validators import validate_create_parameters, validate_ssh_key, validate_list_of_integers


def _compute_client_factory(**_):
Expand Down Expand Up @@ -59,6 +60,8 @@ def _get_default_install_location(exe_name):

name_arg_type = CliArgumentType(options_list=('--name', '-n'), metavar='NAME')

storageProfileTypes = ["StorageAccount", "ManagedDisks"]

register_cli_argument('acs', 'tags', tags_type)

register_cli_argument('acs', 'name', arg_type=name_arg_type, configured_default='acs',
Expand All @@ -70,14 +73,26 @@ def _get_default_install_location(exe_name):
register_cli_argument('acs', 'orchestrator_type', options_list=('--orchestrator-type', '-t'), **enum_choice_list(ContainerServiceOrchestratorTypes))
# some admin names are prohibited in acs, such as root, admin, etc. Because we have no control on the orchestrators, so default to a safe name.
register_cli_argument('acs', 'admin_username', options_list=('--admin-username',), default='azureuser', required=False)
register_cli_argument('acs', 'api_version', options_list=('--api-version',), required=False, help='Use API version of ACS to perform az acs operations. Available options: 2017-01-31, 2017-07-01. (2017-07-01 in preview, only in ukwest and uksouth). Default to use the latest version for the location')
register_cli_argument('acs', 'dns_name_prefix', options_list=('--dns-prefix', '-d'))
register_cli_argument('acs', 'container_service_name', options_list=('--name', '-n'), help='The name of the container service', completer=get_resource_name_completion_list('Microsoft.ContainerService/ContainerServices'))

register_cli_argument('acs', 'ssh_key_value', required=False, help='SSH key file value or key file path.', type=file_type, default=os.path.join('~', '.ssh', 'id_rsa.pub'), completer=FilesCompleter())
register_cli_argument('acs create', 'name', arg_type=name_arg_type, validator=validate_ssh_key)

register_extra_cli_argument('acs create', 'generate_ssh_keys', action='store_true', help='Generate SSH public and private key files if missing', validator=validate_create_parameters)
register_cli_argument('acs create', 'master_profile', options_list=('--master-profile', '-m'), type=validate_file_or_dict, help='The file or dictionary representation of the master profile. Note it will override any master settings once set')
register_cli_argument('acs create', 'master_vm_size', completer=get_vm_size_completion_list)
register_cli_argument('acs create', 'master_osdisk_size', type=int, help='the disk size for master pool vms. Unit in GB. If not specified, the corresponding vmsize disk size will apply')
register_cli_argument('acs create', 'master_vnet_subnet_id', type=str, help='the custom vnet subnet id. Note agent need to used the same vnet if master set')
register_cli_argument('acs create', 'master_first_consecutive_static_ip', type=str, help='the first consecutive ip used to specify static ip block')
register_cli_argument('acs create', 'master_storage_profile', **enum_choice_list(storageProfileTypes))
register_cli_argument('acs create', 'agent_profiles', options_list=('--agent-profiles', '-a'), type=validate_file_or_dict, help='The file or dictionary representation of the agent profiles. Note it will override any agent settings once set')
register_cli_argument('acs create', 'agent_vm_size', completer=get_vm_size_completion_list)
register_cli_argument('acs create', 'agent_osdisk_size', type=int, help='the disk size for agent pool vms. Unit in GB. If not specified, the corresponding vmsize disk size will apply')
register_cli_argument('acs create', 'agent_vnet_subnet_id', type=str, help='the custom vnet subnet id. Note agent need to used the same vnet if master set')
register_cli_argument('acs create', 'agent_ports', type=validate_list_of_integers, help='the ports exposed on the agent pool, such as 8080,4000,80')
register_cli_argument('acs create', 'agent_storage_profile', **enum_choice_list(storageProfileTypes))

register_cli_argument('acs create', 'windows', action='store_true', help='If true, deploy a windows container cluster.')
register_cli_argument('acs create', 'validate', action='store_true', help='Generate and validate the ARM template without creating any resources')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def validate_ssh_key(namespace):
namespace.ssh_key_value = content


def validate_list_of_integers(string):
# extract comma separated list of integers
return list(map(int, string.split(',')))


def validate_create_parameters(namespace):
if not namespace.name:
raise CLIError('--name has no value')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def run(self, command, background=False):
:param command: Command to run on the remote host
:type command: String
:param background: True if command should be run in the foreground,
false to run it in a separate thread
:param background: True to run it in a separate thread,
False should be run in the foreground
:type command: Boolean
"""
if background:
Expand Down
Loading

0 comments on commit 2a59cee

Please sign in to comment.