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

VM Repair: Improve vm reset nic command #5226

Merged
merged 3 commits into from
Aug 15, 2022
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.5
++++++
Improve az vm repair reset-nic command to use subnet list available ips command

0.4.4
++++++
Add az vm repair reset-nic command
Expand Down
9 changes: 5 additions & 4 deletions src/vm-repair/azext_vm_repair/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,17 @@ def reset_nic(cmd, vm_name, resource_group_name, yes=False):
ip_config_object = json.loads(ip_config_string)

subnet_id = ip_config_object['subnet']['id']
vnet_name = subnet_id.split('/')[-3]
subnet_id_tokens = subnet_id.split('/')
subnet_name = subnet_id_tokens[-1]
vnet_name = subnet_id_tokens[-3]
ipconfig_name = ip_config_object['name']
orig_ip_address = ip_config_object['privateIpAddress']
# Dynamic | Static
orig_ip_allocation_method = ip_config_object['privateIpAllocationMethod']

# Get aviailable ip address within subnet
# Change to az network vnet subnet list-available-ips when it is available
get_available_ip_command = 'az network vnet list-available-ips -g {g} -n {vnet} --query [0] -o tsv' \
.format(g=resource_group_name, vnet=vnet_name)
get_available_ip_command = 'az network vnet subnet list-available-ips -g {g} --vnet-name {vnet} --name {subnet} --query [0] -o tsv' \
.format(g=resource_group_name, vnet=vnet_name, subnet=subnet_name)
swap_ip_address = _call_az_command(get_available_ip_command)
if not swap_ip_address:
# Raise available IP not found
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.4"
VERSION = "0.4.5"

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