Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCVMM] Public Preview refresh using New Resource Model #6708

Merged
merged 19 commits into from
Sep 21, 2023
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
11 changes: 11 additions & 0 deletions src/scvmm/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
Release History
===============

Upcoming
++++++
* Using New Resource Model for all VM operations:
* `vm` command : Create, Update, Delete, Show, VirtualMachineInstance and Perform Operations on VM Instance
* `vm guest-agent` command : Enable, Show VMInstanceGuestAgent
* `vm extension` command : Create, Update, Delete, Show, List MachineExtensions
* If underlying machine is not present, it gets created during vm create
* Added delete-from-host flag for `vm delete`
* Deprecated VM List option as VM Instance is a child resource of Machines.
* Updated tests and helps accordingly.

0.1.8
++++++
* Added support for checkpoint operations to create, delete and restore checkpoints
Expand Down
6 changes: 3 additions & 3 deletions src/scvmm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ az scvmm avset create \
--name resourceName
```

##### Create Virtual Machine Resource
##### Create Virtual Machine Instance Resource

###### Onboard exisitng Virtual Machine to azure
###### Onboard existing Virtual Machine Instance to azure

```
az scvmm vm create \
Expand All @@ -94,7 +94,7 @@ az scvmm vm create \
--name resourceName
```

###### Create new Virtual Machine
###### Create new Virtual Machine Instance

```
az scvmm vm create \
Expand Down
49 changes: 38 additions & 11 deletions src/scvmm/azext_scvmm/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,87 @@
# --------------------------------------------------------------------------------------------

from azure.cli.core.commands.client_factory import get_mgmt_service_client
from .vendored_sdks import SCVMM
from azure.cli.core import AzCli
from .vendored_sdks.scvmm import SCVMM
from .vendored_sdks.hybridcompute import HybridComputeManagementClient


def cf_scvmm(cli_ctx, *_) -> SCVMM:
def cf_scvmm(cli_ctx: AzCli, *_) -> SCVMM:
"""
Client factory for scvmm clients.
"""
return get_mgmt_service_client(cli_ctx, SCVMM)


def cf_vmmserver(cli_ctx, *_):
def cf_hybridcompute(cli_ctx: AzCli, *_) -> HybridComputeManagementClient:
return get_mgmt_service_client(cli_ctx, HybridComputeManagementClient)


def cf_vmmserver(cli_ctx: AzCli, *_):
"""
Client factory for vmmservers.
"""
return cf_scvmm(cli_ctx).vmm_servers


def cf_cloud(cli_ctx, *_):
def cf_cloud(cli_ctx: AzCli, *_):
"""
Client factory for clouds.
"""
return cf_scvmm(cli_ctx).clouds


def cf_virtual_network(cli_ctx, *_):
def cf_virtual_network(cli_ctx: AzCli, *_):
"""
Client factory for virtual networks.
"""
return cf_scvmm(cli_ctx).virtual_networks


def cf_virtual_machine_template(cli_ctx, *_):
def cf_virtual_machine_template(cli_ctx: AzCli, *_):
"""
Client factory for vm templates.
"""
return cf_scvmm(cli_ctx).virtual_machine_templates


def cf_virtual_machine(cli_ctx, *_):
def cf_virtual_machine_instance(cli_ctx: AzCli, *_):
"""
Client factory for virtual machines.
Client factory for virtual machine instances.
"""
return cf_scvmm(cli_ctx).virtual_machines
return cf_scvmm(cli_ctx).virtual_machine_instances


def cf_availability_sets(cli_ctx, *_):
def cf_availability_sets(cli_ctx: AzCli, *_):
"""
Client factory for availability sets.
"""
return cf_scvmm(cli_ctx).availability_sets


def cf_inventory_items(cli_ctx, *_):
def cf_inventory_items(cli_ctx: AzCli, *_):
"""
Client factory for inventory items.
"""
return cf_scvmm(cli_ctx).inventory_items


def cf_vminstance_guest_agent(cli_ctx: AzCli, *_):
"""
Client factory for guest agent.
"""
return cf_scvmm(cli_ctx).vm_instance_guest_agents


def cf_machine(cli_ctx: AzCli, *_):
"""
Client factory for machines.
"""
return cf_hybridcompute(cli_ctx).machines


def cf_machine_extension(cli_ctx: AzCli, *_):
"""
Client factory for machines.
"""
return cf_hybridcompute(cli_ctx).machine_extensions
98 changes: 98 additions & 0 deletions src/scvmm/azext_scvmm/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,3 +914,101 @@
"""

# endregion

# region vm guest-agent

helps[
'scvmm vm guest-agent'
] = """
type: group
short-summary: vm guest agent.
"""

helps[
'scvmm vm guest-agent enable'
] = """
type: command
short-summary: "Enable guest agent on the vm"
examples:
- name: Enable guest agent on the vm
text: |-
az scvmm vm guest-agent enable --username contoso-user --password contoso-pass \
--resource-group contoso-rg --subscription contoso-sub \
--vm-name contoso-vm
"""

helps[
'scvmm vm guest-agent show'
] = """
type: command
short-summary: "Get details of a guest agent by guest agent name, resource-group and vm name."
examples:
- name: Get details of a guest agent
text: |-
az scvmm vm guest-agent show --resource-group contoso-rg \
--vm-name contoso-vm
"""

# endregion

# region vm extension

helps['scvmm vm extension'] = """
type: group
short-summary: Manage vm extension with scvmm
"""

helps['scvmm vm extension list'] = """
type: command
short-summary: "The operation to get all extensions of a non-Azure vm."
examples:
- name: Get all VM Extensions
text: |-
az scvmm vm extension list --vm-name contoso-vm --resource-group contoso-rg
"""

helps['scvmm vm extension show'] = """
type: command
short-summary: "The operation to get the extension."
examples:
- name: Get VM Extension
text: |-
az scvmm vm extension show --name contoso-extension --vm-name contoso-vm \
--resource-group contoso-rg
"""

helps['scvmm vm extension create'] = """
type: command
short-summary: "The operation to create the extension."
examples:
- name: Create a VM Extension
text: |-
az scvmm vm extension create --name contoso-extension --location eastus2euap --type \
CustomScriptExtension --publisher Microsoft.Compute --settings "{\\"commandToExecute\\":\\"powershell.exe -c \
\\\\\\"Get-Process | Where-Object { $_.CPU -gt 10000 }\\\\\\"\\"}" --type-handler-version 1.10 --vm-name \
contoso-vm --resource-group contoso-rg
"""

helps['scvmm vm extension update'] = """
type: command
short-summary: "The operation to update the extension."
examples:
- name: Update a VM Extension
text: |-
az scvmm vm extension update --name contoso-extension --type CustomScriptExtension \
--publisher Microsoft.Compute --settings "{\\"commandToExecute\\":\\"powershell.exe -c \\\\\\"Get-Process | \
Where-Object { $_.CPU -lt 100 }\\\\\\"\\"}" --type-handler-version 1.10 --vm-name contoso-vm --resource-group \
contoso-rg
"""

helps['scvmm vm extension delete'] = """
type: command
short-summary: "The operation to delete the extension."
examples:
- name: Delete a VM Extension
text: |-
az scvmm vm extension delete --name contoso-extension --vm-name contoso-vm --resource-group \
contoso-rg
"""

# endregion
Loading