-
Notifications
You must be signed in to change notification settings - Fork 24
Add external control bridge related infra #851
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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env ruby | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../lib/auto_hck' | ||
|
|
||
| module AutoHCK | ||
| run do | ||
| require 'English' | ||
| require 'fileutils' | ||
|
|
||
| side = ARGV[0] | ||
| case side | ||
| when 'host' | ||
| pid = ARGV[1] | ||
| run_id = ARGV[2] | ||
| veth_bridge = ARGV[3] | ||
|
|
||
| command = [ | ||
| # *veth* pair for *control* *external* communication bridge | ||
| # one end (vce_#{run_id}) in host connected to veth_bridge | ||
| # other in namespace (ctrl_ext_ns) connected to br_ctrl_ext | ||
| %W[ip link add vce_#{run_id} type veth peer ctrl_ext_ns netns #{pid}], | ||
| %W[ip link set vce_#{run_id} master #{veth_bridge}], | ||
| %W[ip link set vce_#{run_id} up] | ||
| ] | ||
| when 'ns' | ||
| command = [ | ||
| # External control bridge for communication with Controller / Studio PCs in lab | ||
| %w[ip link set ctrl_ext_ns up], | ||
| %w[ip link add br_ctrl_ext type bridge], | ||
| %w[ip link set ctrl_ext_ns master br_ctrl_ext], | ||
| %w[ip link set br_ctrl_ext up] | ||
| ] | ||
| else | ||
| raise "Unknown side: #{side}" | ||
| end | ||
|
|
||
| command.each do |cmd| | ||
| $stderr.write "[ns_veth #{side}] Running (wait spawn): #{cmd.join(' ')}\n" | ||
| Process.wait spawn(*cmd, out: :err) | ||
| raise $CHILD_STATUS.to_s unless $CHILD_STATUS.success? | ||
| rescue StandardError | ||
| raise "#{cmd}: command failed" | ||
| end | ||
|
Comment on lines
+38
to
+44
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. There are a couple of issues with this error handling block:
To fix this, the command.each do |cmd|
begin
$stderr.write "[ns_veth #{side}] Running (wait spawn): #{cmd.join(' ')}\n"
Process.wait spawn(*cmd, out: :err)
raise "command failed with status #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
rescue StandardError => e
raise "Command '#{cmd.join(' ')}' failed: #{e.message}"
end
end |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,14 @@ | |
| "name": "CL1", | ||
| "cpus": 4, | ||
| "memory_gb": 4, | ||
| "winrm_port": 4002, | ||
| "winrm_addr": "192.168.100.2", | ||
|
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. The json update doesn't match the commit message. Maybe should be separate commit |
||
| "image": "HLK2004-C1-Win10_2004x64.qcow2" | ||
| }, | ||
| "c2": { | ||
| "name": "CL2", | ||
| "cpus": 4, | ||
| "memory_gb": 4, | ||
| "winrm_port": 4003, | ||
| "winrm_addr": "192.168.100.3", | ||
| "image": "HLK2004-C2-Win10_2004x64.qcow2" | ||
| } | ||
| } | ||
|
|
||
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.
For reproducible builds, it's better to pin a dependency to a specific commit hash rather than a branch name. Branch refs can be updated, leading to different versions of the gem being installed over time. Please use the full commit hash from
Gemfile.lockto ensure that builds are consistent.