Skip to content

Commit

Permalink
[Vm-repair] Fix in az vm repair run --preview parameter (#6973)
Browse files Browse the repository at this point in the history
  • Loading branch information
haagha committed Nov 29, 2023
1 parent ba5e622 commit 3f54159
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/vm-repair/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

Release History
===============

0.5.8
++++++
Fix az vm repair run --preview parameter to take in fork and branch name of User's repository.

0.5.7
++++++
Remove VM-repair SUSE image check
Expand Down
4 changes: 2 additions & 2 deletions src/vm-repair/azext_vm_repair/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
az vm repair run -g MyResourceGroup -n MySourceWinVM --custom-script-file ./file.ps1 --verbose
- name: Run unverified script from your fork of https://github.com/Azure/repair-script-library
text: >
az vm repair run -g MyResourceGroup -n MySourceWinVM --preview "https://github.com/haagha/repair-script-library/blob/master/map.json" --run-id test
az vm repair run -g MyResourceGroup -n MySourceWinVM --preview "https://github.com/User/repair-script-library/blob/main/map.json" --run-id test
"""

helps['vm repair list-scripts'] = """
Expand All @@ -75,7 +75,7 @@
az vm repair list-scripts --query "[?contains(description, 'test')]"
- name: List unverified script from your fork of https://github.com/Azure/repair-script-library
text: >
az vm repair list-scripts --preview "https://github.com/haagha/repair-script-library/blob/master/map.json"
az vm repair list-scripts --preview "https://github.com/User/repair-script-library/blob/main/map.json"
"""

helps['vm repair reset-nic'] = """
Expand Down
8 changes: 8 additions & 0 deletions src/vm-repair/azext_vm_repair/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,14 @@ def run(cmd, vm_name, resource_group_name, run_id=None, repair_vm_id=None, custo
# Fetch run path from GitHub
repair_script_path = _fetch_run_script_path(run_id)
run_command_params.append('script_path="./{}"'.format(repair_script_path))
if preview:
parts = preview.split('/')
if len(parts) != 7:
raise Exception('Invalid preview url. Write full URL of map.json file. example https://github.com/Azure/repair-script-library/blob/main/map.json')
fork_name = parts[3]
branch_name = parts[6]
run_command_params.append('repo_fork="{}"'.format(fork_name))
run_command_params.append('repo_branch="{}"'.format(branch_name))

# Custom script scenario for script testers
else:
Expand Down
6 changes: 4 additions & 2 deletions src/vm-repair/azext_vm_repair/scripts/win-run-driver.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Param([Parameter(Mandatory=$true)][string]$script_path,[Parameter(Mandatory=$false)][bool]$init=$true,[Parameter(Mandatory=$false)][string]$params='')
Param([Parameter(Mandatory=$true)][string]$script_path,[Parameter(Mandatory=$false)][string]$repo_fork, [Parameter(Mandatory=$false)][string]$repo_branch, [Parameter(Mandatory=$false)][bool]$init=$true,[Parameter(Mandatory=$false)][string]$params='')
if ($init)
{
try {
Expand All @@ -11,7 +11,9 @@ if ($init)
$logFileName = "logs-$curDate.txt"
Set-Content -Path "./$logFileName" -Value "[Log-Start $(Get-Date)]"
$logFile = (Resolve-Path "./$logFileName").Path
(new-object net.webclient).DownloadFile('https://github.com/Azure/repair-script-library/zipball/master/', (Join-Path $pwd 'repair-script-library.zip'))

$url = "https://github.com/$repo_fork/repair-script-library/zipball/$repo_branch/"
(new-object net.webclient).DownloadFile($url, (Join-Path $pwd 'repair-script-library.zip'))
Expand-Archive -Path 'repair-script-library.zip' -DestinationPath 'repair-script-library'
$reponame = dir repair-script-library -n
Set-Location (Join-Path 'repair-script-library' $reponame)
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.5.7"
VERSION = "0.5.8"

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

0 comments on commit 3f54159

Please sign in to comment.