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: 4 additions & 0 deletions src/vm-repair/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release History
===============

0.4.7
++++++
Setting subscription account for reset-nic

0.4.6
++++++
Updating the fetch_repair_vm to use the small letters in the query instead of capital letters
Expand Down
6 changes: 3 additions & 3 deletions src/vm-repair/azext_vm_repair/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
- name: Reset the VM guest NIC. Specify VM resource group and name.
text: >
az vm repair reset-nic -g MyResourceGroup -n MyVM --verbose
- name: Reset the VM guest NIC. Specify subscription id, VM resource group and name.
text: >
az vm repair reset-nic -g MyResourceGroup -n MyVM --subscription mySub --verbose
- name: Reset the VM guest NIC and auto-start the VM if it is not in running state.
text: >
az vm repair reset-nic -g MyResourceGroup -n MyVM --yes --verbose
- name: Reset the VM guest NIC. Specify VM resource id.
text: >
az vm repair reset-nic --ids /subscriptions/MySubscriptionId/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM --verbose
"""
1 change: 1 addition & 0 deletions src/vm-repair/azext_vm_repair/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ def load_arguments(self, _):
c.argument('preview', help="URL of forked repair script library's map.json https://github.com/{user}/repair-script-library/blob/master/map.json")

with self.argument_context('vm repair reset-nic') as c:
c.argument('subscriptionid', help='Subscription id to default subscription using `az account set -s NAME_OR_ID`.')
c.argument('yes', help='Do not prompt for confirmation to start VM if it is not running.')
9 changes: 9 additions & 0 deletions src/vm-repair/azext_vm_repair/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ def validate_run(cmd, namespace):

def validate_reset_nic(cmd, namespace):
check_extension_version(EXTENSION_NAME)
if namespace._subscription:
# setting subscription Id
try:
set_sub_command = 'az account set --subscription {sid}'.format(sid=namespace._subscription)
logger.info('Setting the subscription...\n')
_call_az_command(set_sub_command)
except AzCommandError as azCommandError:
logger.error(azCommandError)
raise CLIError('Unexpected error occured while setting the subscription..')
_validate_and_get_vm(cmd, namespace.resource_group_name, namespace.vm_name)


Expand Down
1 change: 1 addition & 0 deletions src/vm-repair/azext_vm_repair/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ def reset_nic(cmd, vm_name, resource_group_name, yes=False):
try:
# 0) Check if VM is deallocated or off. If it is, ask to run start the VM.
VM_OFF_MESSAGE = 'VM is not running. The VM must be in running to reset its NIC.\n'

vm_instance_view = get_vm(cmd, resource_group_name, vm_name, 'instanceView')
VM_started = _check_n_start_vm(vm_name, resource_group_name, not yes, VM_OFF_MESSAGE, vm_instance_view)
if not VM_started:
Expand Down
2 changes: 1 addition & 1 deletion src/vm-repair/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "0.4.6"
VERSION = "0.4.7"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down