-
Notifications
You must be signed in to change notification settings - Fork 24
VIRTWINKVM-1882: Read VM names from config #1041
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| $VMNAMES = @("STUDIO", "CL1", "CL2") | ||
| $KITTYPE = "HLK" | ||
| $HLKKITVER = 2004 | ||
| $REMOVEGUI = $false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,8 @@ module Helper | |
| hlk_kit_ver: '', | ||
| remove_gui: '', | ||
| debug: '', | ||
| no_reboot_after_bugcheck: '' | ||
| no_reboot_after_bugcheck: '', | ||
| vmnames: [] | ||
| }.freeze | ||
|
|
||
| sig { params(workspace_hlk_setup_scripts_path: Pathname, hck_setup_scripts_template_path: Pathname).void } | ||
|
|
@@ -71,6 +72,9 @@ def create_setup_scripts_config(workspace_hlk_setup_scripts_path, config) | |
| value = "'#{v}'" | ||
| when Integer | ||
| value = v | ||
| when Array | ||
| items = v.map { |item| "'#{item.to_s.gsub("'", "''")}'" }.join(', ') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason why in example
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry by mistake will change this to single case |
||
| value = "@(#{items})" | ||
| else | ||
| @logger.fatal("Unexpected value #{v} for config") | ||
| Kernel.raise(AutoHCKError, "Unexpected value #{v} for config") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,9 +25,13 @@ def initialize(setup_manager, scope, studio, name, run_opts) | |
| @replacement_map = @project.project_replacement_map.merge(setup_manager.client_replacement_map(name)) | ||
| end | ||
|
|
||
| def machine_name_match?(machine_name) | ||
| machine_name.casecmp?(@name) | ||
| end | ||
|
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If def machine_name_match?(machine_name)
machine_name && machine_name.casecmp?(@name)
end |
||
|
|
||
| def pool | ||
| @studio.list_pools.each do |pool| | ||
| return pool['name'] if pool['machines'].any? { |machine| machine['name'].eql?(@name) } | ||
| return pool['name'] if pool['machines'].any? { |machine| machine_name_match?(machine['name']) } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just replace |
||
| end | ||
| end | ||
|
|
||
|
|
@@ -152,8 +156,8 @@ def copy_dvl | |
| end | ||
|
|
||
| def machine_info | ||
| @studio.list_pools.flat_map { |pool| pool['machines'] } | ||
| .detect { |machine| machine['name'].eql?(@name) } | ||
| machines = @studio.list_pools.flat_map { |pool| pool['machines'] } | ||
| machines.detect { |machine| machine_name_match?(machine['name']) } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
| end | ||
|
|
||
| def recognize_client_wait | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
$clientNumberis out of bounds of the$VMNAMESarray (for example, due to an unexpected MAC address or mismatched configuration),$clientNamewill be$null. Passing$nulltoRename-Computer -NewNamewill result in an empty string argument error. Adding a check to ensure$clientNameis valid before proceeding improves robustness and error reporting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be useful