Skip to content

Commit

Permalink
New extension Swiftlet (#2204)
Browse files Browse the repository at this point in the history
* swiftlet init commit

* rename

* test; parameter name; help

* test

* readme

* style

* help

* codeonwers

* readme
  • Loading branch information
qwordy authored Aug 24, 2020
1 parent d62ac44 commit 59eafee
Show file tree
Hide file tree
Showing 45 changed files with 9,615 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 @@ -145,3 +145,5 @@
/src/attestation/ @YalinLi0312 @bim-msft

/src/guestconfig/ @gehuan

/src/swiftlet/ @qwordy
8 changes: 8 additions & 0 deletions src/swiftlet/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. :changelog:
Release History
===============

0.1.0
++++++
* Initial release.
31 changes: 31 additions & 0 deletions src/swiftlet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Microsoft Azure CLI 'swiftlet' Extension
==========================================

This package is for the 'swiftlet' extension. Swiftlet is a new Azure Compute offering. Swiftlet is conceived to offer a greatly simplified Azure experience for non-enterprise developers.

### How to use ###
Install this extension using the below CLI command
```
az extension add --name swiftlet
```

### Sample Commands ###
Create a Swiftlet VM
```
az swiftlet vm create --location "westus" --password "{your-password}," --ports \
port-range="3389" protocol="*" --startup-script "{inline startup script}" --swiftlet-bundle-sku "Windows_1" \
--swiftlet-image-id "windows-2019-datacenter" --username "SwiftletUser" --tags key1="value1" key2="value2" \
--resource-group "myResourceGroup" --name "myVirtualMachine"
```
Show information of a Swiftlet VM
```
az swiftlet vm show --resource-group "myResourceGroup" --name "myVirtualMachine"
```
List available Swiftlet bundles
```
az swiftlet vm list-bundle --location "westus"
```
List available Swiftlet images
```
az swiftlet vm list-image --location "westus"
```
50 changes: 50 additions & 0 deletions src/swiftlet/azext_swiftlet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from azure.cli.core import AzCommandsLoader
from azext_swiftlet.generated._help import helps # pylint: disable=unused-import
try:
from azext_swiftlet.manual._help import helps # pylint: disable=reimported
except ImportError:
pass


class SwiftletManagementClientCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_swiftlet.generated._client_factory import cf_swiftlet_cl
swiftlet_custom = CliCommandType(
operations_tmpl='azext_swiftlet.custom#{}',
client_factory=cf_swiftlet_cl)
parent = super(SwiftletManagementClientCommandsLoader, self)
parent.__init__(cli_ctx=cli_ctx, custom_command_type=swiftlet_custom)

def load_command_table(self, args):
from azext_swiftlet.generated.commands import load_command_table
load_command_table(self, args)
try:
from azext_swiftlet.manual.commands import load_command_table as load_command_table_manual
load_command_table_manual(self, args)
except ImportError:
pass
return self.command_table

def load_arguments(self, command):
from azext_swiftlet.generated._params import load_arguments
load_arguments(self, command)
try:
from azext_swiftlet.manual._params import load_arguments as load_arguments_manual
load_arguments_manual(self, command)
except ImportError:
pass


COMMAND_LOADER_CLS = SwiftletManagementClientCommandsLoader
17 changes: 17 additions & 0 deletions src/swiftlet/azext_swiftlet/action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.action import * # noqa: F403
try:
from .manual.action import * # noqa: F403
except ImportError:
pass
4 changes: 4 additions & 0 deletions src/swiftlet/azext_swiftlet/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.isExperimental": true,
"azext.minCliCoreVersion": "2.3.1"
}
17 changes: 17 additions & 0 deletions src/swiftlet/azext_swiftlet/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wildcard-import
# pylint: disable=unused-wildcard-import

from .generated.custom import * # noqa: F403
try:
from .manual.custom import * # noqa: F403
except ImportError:
pass
12 changes: 12 additions & 0 deletions src/swiftlet/azext_swiftlet/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__)
20 changes: 20 additions & 0 deletions src/swiftlet/azext_swiftlet/generated/_client_factory.py
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.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------


def cf_swiftlet_cl(cli_ctx, *_):
from azure.cli.core.commands.client_factory import get_mgmt_service_client
from ..vendored_sdks.swiftlet import SwiftletManagementClient
return get_mgmt_service_client(cli_ctx,
SwiftletManagementClient)


def cf_virtual_machine(cli_ctx, *_):
return cf_swiftlet_cl(cli_ctx).virtual_machine
155 changes: 155 additions & 0 deletions src/swiftlet/azext_swiftlet/generated/_help.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------
# pylint: disable=too-many-lines

from knack.help_files import helps


helps['swiftlet virtual-machine'] = """
type: group
short-summary: swiftlet virtual-machine
"""

helps['swiftlet virtual-machine list'] = """
type: command
short-summary: "List all of the virtual machines in the specified subscription. Use the nextLink property in the \
response to get the next page of virtual machines."
examples:
- name: List all virtual machines in a resource group.
text: |-
az swiftlet virtual-machine list --resource-group "myResourceGroup"
"""

helps['swiftlet virtual-machine show'] = """
type: command
short-summary: "Get information about the virtual machine."
examples:
- name: Get a virtual machine.
text: |-
az swiftlet virtual-machine show --resource-group "myResourceGroup" --vm-name "myVirtualMachine"
"""

helps['swiftlet virtual-machine create'] = """
type: command
short-summary: "Create or update a virtual machine."
parameters:
- name: --ports
short-summary: "The ports on which inbound traffic will be allowed."
long-summary: |
Usage: --ports port-range=XX protocol=XX
port-range: The port(s) that will be open to traffic. This will be a string that can indicate a single \
port, a range (i.e. 50-60), or "*" to indicate all ports.
protocol: The type of traffic to allow on this port. Allowed values are "TCP", "UDP", "ICMP", and "\ *" \
(indicates all supported protocol types allowed). If not specified, it will be default to "*\ ".
Multiple actions can be specified by using more than one --ports argument.
examples:
- name: Create a virtual machine with password authentication.
text: |-
az swiftlet virtual-machine create --location "westus" --password "{your-password}," --ports \
port-range="3389" protocol="*" --startup-script "{inline startup script}" --swiftlet-bundle-sku "Windows_1" \
--swiftlet-image-id "windows-2019-datacenter" --username "SwiftletUser" --tags key1="value1" key2="value2" \
--resource-group "myResourceGroup" --vm-name "myVirtualMachine"
- name: Create a virtual machine with ssh authentication.
text: |-
az swiftlet virtual-machine create --location "westus" --ports port-range="22" protocol="*" \
--ssh-public-key "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5D\
oOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPq\
K8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/\
ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1" --startup-script "{inline startup script}" --swiftlet-bundle-sku "Linux_1" \
--swiftlet-image-id "ubuntu-18.04-lts" --username "SwiftletUser" --tags key1="value1" key2="value2" --resource-group \
"myResourceGroup" --vm-name "myVirtualMachine"
"""

helps['swiftlet virtual-machine update'] = """
type: command
short-summary: "Update a virtual machine."
parameters:
- name: --ports
short-summary: "Specifies the list of ports to be opened."
long-summary: |
Usage: --ports port-range=XX protocol=XX
port-range: The port(s) that will be open to traffic. This will be a string that can indicate a single \
port, a range (i.e. 50-60), or "*" to indicate all ports.
protocol: The type of traffic to allow on this port. Allowed values are "TCP", "UDP", "ICMP", and "\ *" \
(indicates all supported protocol types allowed). If not specified, it will be default to "*\ ".
Multiple actions can be specified by using more than one --ports argument.
examples:
- name: Update tags of a virtual machine.
text: |-
az swiftlet virtual-machine update --ports port-range="80" protocol="TCP" --ports port-range="50-60" \
protocol="UDP" --tags key3="value3" --resource-group "myResourceGroup" --vm-name "myVirtualMachine"
"""

helps['swiftlet virtual-machine delete'] = """
type: command
short-summary: "Delete a virtual machine."
examples:
- name: Delete a virtual machine.
text: |-
az swiftlet virtual-machine delete --resource-group "myResourceGroup" --vm-name "myVirtualMachine"
"""

helps['swiftlet virtual-machine list-bundle'] = """
type: command
short-summary: "List all Swiftlet bundles available for the specified subscription and Azure location."
examples:
- name: List available Swiftlet bundles
text: |-
az swiftlet virtual-machine list-bundle --location "westus"
"""

helps['swiftlet virtual-machine list-image'] = """
type: command
short-summary: "List all Swiftlet images available for the specified subscription and Azure location."
examples:
- name: List available Swiftlet images
text: |-
az swiftlet virtual-machine list-image --location "westus"
"""

helps['swiftlet virtual-machine start'] = """
type: command
short-summary: "Start a specified virtual machine."
examples:
- name: Start a virtual machine.
text: |-
az swiftlet virtual-machine start --resource-group "myResourceGroup" --vm-name "myVirtualMachine"
"""

helps['swiftlet virtual-machine stop'] = """
type: command
short-summary: "Stop a specified virtual machine."
examples:
- name: Stop a virtual machine.
text: |-
az swiftlet virtual-machine stop --resource-group "myResourceGroup" --vm-name "myVirtualMachine"
"""

helps['swiftlet virtual-machine wait'] = """
type: command
short-summary: Place the CLI in a waiting state until a condition of the swiftlet virtual-machine is met.
examples:
- name: Pause executing next line of CLI script until the swiftlet virtual-machine is successfully created.
text: |-
az swiftlet virtual-machine wait --resource-group "myResourceGroup" --vm-name "myVirtualMachine" \
--created
- name: Pause executing next line of CLI script until the swiftlet virtual-machine is successfully updated.
text: |-
az swiftlet virtual-machine wait --resource-group "myResourceGroup" --vm-name "myVirtualMachine" \
--updated
- name: Pause executing next line of CLI script until the swiftlet virtual-machine is successfully deleted.
text: |-
az swiftlet virtual-machine wait --resource-group "myResourceGroup" --vm-name "myVirtualMachine" \
--deleted
"""
Loading

0 comments on commit 59eafee

Please sign in to comment.