Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def load_command_table(self, args):
load_command_table(self, args)
try:
# When generated commands are required uncomment the following two lines.
# from .generated.commands import load_command_table as load_command_table_generated
# load_command_table_generated(self, args)
from .generated.commands import load_command_table as load_command_table_generated
load_command_table_generated(self, args)
from .manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
Expand Down
6 changes: 6 additions & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

from ._client_factory import _compute_client_factory

from .generated.action import * # noqa: F403, pylint: disable=unused-wildcard-import,wildcard-import
try:
from .manual.action import * # noqa: F403, pylint: disable=unused-wildcard-import,wildcard-import
except ImportError:
pass

logger = get_logger(__name__)


Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/azure/cli/command_modules/vm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# --------------------------------------------------------------------------
from knack.help_files import helps # pylint: disable=unused-import

from .generated._help import helps
try:
from .manual._help import helps # pylint: disable=reimported
except ImportError:
Expand Down
11 changes: 6 additions & 5 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
# pylint: disable=no-self-use,too-many-lines
from __future__ import print_function

# from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403, pylint: disable=unused-import,unused-wildcard-import,wildcard-import
except ImportError:
pass

import json
import os
Expand Down Expand Up @@ -51,6 +46,12 @@
from ._client_factory import (_compute_client_factory, cf_public_ip_addresses, cf_vm_image_term,
_dev_test_labs_client_factory)

from .generated.custom import * # noqa: F403, pylint: disable=unused-wildcard-import,wildcard-import
try:
from .manual.custom import * # noqa: F403, pylint: disable=unused-wildcard-import,wildcard-import
except ImportError:
pass

logger = get_logger(__name__)


Expand Down
Binary file modified src/azure-cli/azure/cli/command_modules/vm/gen.zip
Binary file not shown.
39 changes: 38 additions & 1 deletion src/azure-cli/azure/cli/command_modules/vm/generated/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,44 @@

from knack.help_files import helps

helps['vm sshkey'] = """

helps['sshkey'] = """
type: group
short-summary: Manage ssh public key with vm
"""

helps['sshkey list'] = """
type: command
short-summary: "Lists all of the SSH public keys in the specified resource group. Use the nextLink property in the \
response to get the next page of SSH public keys. And Lists all of the SSH public keys in the subscription. Use the \
nextLink property in the response to get the next page of SSH public keys."
"""

helps['sshkey show'] = """
type: command
short-summary: "Retrieves information about an SSH public key."
examples:
- name: Get an ssh public key.
text: |-
az sshkey show --resource-group "myResourceGroup" --name "mySshPublicKeyName"
"""

helps['sshkey create'] = """
type: command
short-summary: "Creates a new SSH public key resource."
examples:
- name: Create a new SSH public key resource.
text: |-
az sshkey create --location "westus" --public-key "{ssh-rsa public key}" --resource-group \
"myResourceGroup" --name "mySshPublicKeyName"
"""

helps['sshkey update'] = """
type: command
short-summary: "Updates a new SSH public key resource."
"""

helps['sshkey delete'] = """
type: command
short-summary: "Delete an SSH public key."
"""
15 changes: 5 additions & 10 deletions src/azure-cli/azure/cli/command_modules/vm/generated/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

def load_arguments(self, _):

with self.argument_context('vm ssh-public-key list') as c:
with self.argument_context('sshkey list') as c:
c.argument('resource_group_name', resource_group_name_type)

with self.argument_context('vm ssh-public-key show') as c:
with self.argument_context('sshkey show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')

with self.argument_context('vm ssh-public-key create') as c:
with self.argument_context('sshkey create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.')
Expand All @@ -40,7 +40,7 @@ def load_arguments(self, _):
'will be populated when generateKeyPair is called. If the public key is provided upon resource '
'creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format.')

with self.argument_context('vm ssh-public-key update') as c:
with self.argument_context('sshkey update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')
Expand All @@ -50,12 +50,7 @@ def load_arguments(self, _):
'will be populated when generateKeyPair is called. If the public key is provided upon resource '
'creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format.')

with self.argument_context('vm ssh-public-key delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')

with self.argument_context('vm ssh-public-key generate-key-pair') as c:
with self.argument_context('sshkey delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')
31 changes: 14 additions & 17 deletions src/azure-cli/azure/cli/command_modules/vm/generated/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,20 @@
# pylint: disable=too-many-statements
# pylint: disable=too-many-locals

# from azure.cli.core.commands import CliCommandType
from azure.cli.core.commands import CliCommandType


def load_command_table(_):
pass
def load_command_table(self, _):

# from ..generated._client_factory import cf_ssh_public_key
# vm_ssh_public_key = CliCommandType(
# operations_tmpl='azure.mgmt.compute.operations._ssh_public_keys_operations#SshPublicKeysOperations.{}',
# client_factory=cf_ssh_public_key)
# with self.command_group('vm ssh-public-key', vm_ssh_public_key, client_factory=cf_ssh_public_key) as g:
# g.custom_command('list', 'vm_ssh_public_key_list')
# g.custom_show_command('show', 'vm_ssh_public_key_show')
# g.custom_command('create', 'vm_ssh_public_key_create')
# g.custom_command('update', 'vm_ssh_public_key_update')
# g.custom_command('delete', 'vm_ssh_public_key_delete', confirmation=True)
# g.custom_command('generate-key-pair', 'vm_ssh_public_key_generate_key_pair')
#
# with self.command_group('vm', is_experimental=True):
# pass
from ..generated._client_factory import cf_ssh_public_key

vm_ssh_public_key = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations._ssh_public_keys_operations#SshPublicKeysOperations.{}',
client_factory=cf_ssh_public_key,
)
with self.command_group('sshkey', vm_ssh_public_key, client_factory=cf_ssh_public_key) as g:
g.custom_command('list', 'sshkey_list')
g.custom_show_command('show', 'sshkey_show')
g.custom_command('create', 'sshkey_create')
g.custom_command('update', 'sshkey_update')
g.custom_command('delete', 'sshkey_delete', confirmation=True)
45 changes: 19 additions & 26 deletions src/azure-cli/azure/cli/command_modules/vm/generated/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
# pylint: disable=too-many-lines


def vm_ssh_public_key_list(client,
resource_group_name=None):
def sshkey_list(client,
resource_group_name=None):
if resource_group_name:
return client.list_by_resource_group(resource_group_name=resource_group_name)
return client.list_by_subscription()


def vm_ssh_public_key_show(client,
resource_group_name,
ssh_public_key_name):
def sshkey_show(client,
resource_group_name,
ssh_public_key_name):
return client.get(resource_group_name=resource_group_name,
ssh_public_key_name=ssh_public_key_name)


def vm_ssh_public_key_create(client,
resource_group_name,
ssh_public_key_name,
location,
tags=None,
public_key=None):
def sshkey_create(client,
resource_group_name,
ssh_public_key_name,
location,
tags=None,
public_key=None):
parameters = {}
parameters['location'] = location
parameters['tags'] = tags
Expand All @@ -39,11 +39,11 @@ def vm_ssh_public_key_create(client,
parameters=parameters)


def vm_ssh_public_key_update(client,
resource_group_name,
ssh_public_key_name,
tags=None,
public_key=None):
def sshkey_update(client,
resource_group_name,
ssh_public_key_name,
tags=None,
public_key=None):
parameters = {}
parameters['tags'] = tags
parameters['public_key'] = public_key
Expand All @@ -52,15 +52,8 @@ def vm_ssh_public_key_update(client,
parameters=parameters)


def vm_ssh_public_key_delete(client,
resource_group_name,
ssh_public_key_name):
def sshkey_delete(client,
resource_group_name,
ssh_public_key_name):
return client.delete(resource_group_name=resource_group_name,
ssh_public_key_name=ssh_public_key_name)


def vm_ssh_public_key_generate_key_pair(client,
resource_group_name,
ssh_public_key_name):
return client.generate_key_pair(resource_group_name=resource_group_name,
ssh_public_key_name=ssh_public_key_name)
42 changes: 1 addition & 41 deletions src/azure-cli/azure/cli/command_modules/vm/manual/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,11 @@
# pylint: disable=too-many-lines
# pylint: disable=too-many-statements

from azure.cli.core.commands.parameters import (
tags_type,
resource_group_name_type,
get_location_type
)
from azure.cli.core.commands.validators import get_default_location_from_resource_group
from azure.cli.core.commands.parameters import resource_group_name_type


def load_arguments(self, _):

with self.argument_context('sshkey list') as c:
c.argument('resource_group_name', resource_group_name_type)

with self.argument_context('sshkey show') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')

with self.argument_context('sshkey create') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.')
c.argument('location', arg_type=get_location_type(self.cli_ctx), required=False,
validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('public_key', type=str, help='SSH public key used to authenticate to a virtual machine through ssh. '
'If this property is not initially provided when the resource is created, the publicKey property '
'will be populated when generateKeyPair is called. If the public key is provided upon resource '
'creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format.')

with self.argument_context('sshkey update') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')
c.argument('tags', tags_type)
c.argument('public_key', type=str, help='SSH public key used to authenticate to a virtual machine through ssh. '
'If this property is not initially provided when the resource is created, the publicKey property '
'will be populated when generateKeyPair is called. If the public key is provided upon resource '
'creation, the provided public key needs to be at least 2048-bit and in ssh-rsa format.')

with self.argument_context('sshkey delete') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
'name of the SSH public key.', id_part='name')

with self.argument_context('sshkey generate') as c:
c.argument('resource_group_name', resource_group_name_type)
c.argument('ssh_public_key_name', options_list=['--name', '-n', '--ssh-public-key-name'], type=str, help='The '
Expand Down
11 changes: 4 additions & 7 deletions src/azure-cli/azure/cli/command_modules/vm/manual/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@
def load_command_table(self, _):

from ..generated._client_factory import cf_ssh_public_key

vm_ssh_public_key = CliCommandType(
operations_tmpl='azure.mgmt.compute.operations._ssh_public_keys_operations#SshPublicKeysOperations.{}',
client_factory=cf_ssh_public_key)
client_factory=cf_ssh_public_key,
)
with self.command_group('sshkey', vm_ssh_public_key, client_factory=cf_ssh_public_key) as g:
g.custom_command('list', 'vm_ssh_public_key_list')
g.custom_show_command('show', 'vm_ssh_public_key_show')
g.custom_command('create', 'vm_ssh_public_key_create')
g.custom_command('update', 'vm_ssh_public_key_update')
g.custom_command('delete', 'vm_ssh_public_key_delete', confirmation=True)
# g.custom_command('generate', 'vm_ssh_public_key_generate_key_pair')
g.custom_command('create', 'sshkey_create')
Loading