@@ -79,29 +79,28 @@ base_boxes[:arm_bento] = "bento/ubuntu-22.04-arm64"
7979base_boxes [ :libvirt ] = "generic/ubuntu2204"
8080base_boxes [ :arm_mac_qemu ] = "perk/ubuntu-2204-arm64"
8181
82-
83- def mount_folders ( config , mount_options , type = nil )
82+ def mount_folders ( config , mount_options , type = nil , host = '10.0.2.2' )
8483 # ideally we would use submitty_daemon or something as the owner/group, but since that user doesn't exist
8584 # till post-provision (and this is mounted before provisioning), we want the group to be 'vagrant'
8685 # which is guaranteed to exist and that during install_system.sh we add submitty_daemon/submitty_php/etc to the
8786 # vagrant group so that they can write to this shared folder, primarily just for the log files
8887 owner = 'root'
8988 group = 'vagrant'
90- config . vm . synced_folder '.' , '/usr/local/submitty/GIT_CHECKOUT/Submitty' , create : true , owner : owner , group : group , mount_options : mount_options , smb_host : '10.0.2.2' , smb_username : `whoami` . chomp , type : type
89+ config . vm . synced_folder '.' , '/usr/local/submitty/GIT_CHECKOUT/Submitty' , create : true , owner : owner , group : group , mount_options : mount_options , smb_host : host , smb_username : `whoami` . chomp , type : type
9190
9291 optional_repos = %w( AnalysisTools AnalysisToolsTS Lichen RainbowGrades Tutorial CrashCourseCPPSyntax IntroQuantumComputing LichenTestData DockerImages DockerImagesRPI )
9392 optional_repos . each { |repo |
9493 repo_path = File . expand_path ( "../" + repo )
9594 if File . directory? ( repo_path )
96- config . vm . synced_folder repo_path , "/usr/local/submitty/GIT_CHECKOUT/" + repo , owner : owner , group : group , mount_options : mount_options , smb_host : '10.0.2.2' , smb_username : `whoami` . chomp , type :type
95+ config . vm . synced_folder repo_path , "/usr/local/submitty/GIT_CHECKOUT/" + repo , owner : owner , group : group , mount_options : mount_options , smb_host : host , smb_username : `whoami` . chomp , type : type
9796 end
9897 }
9998end
10099
101100def get_workers ( )
102101 worker_file = File . join ( __dir__ , '.vagrant' , 'workers.json' )
103102 if File . file? ( worker_file )
104- return JSON . parse ( File . read ( worker_file ) , symbolize_names : true )
103+ return JSON . parse ( File . read ( worker_file ) , symbolize_names : true ) [ :workers ]
105104 else
106105 return Hash [ ]
107106 end
@@ -144,22 +143,44 @@ Vagrant.configure(2) do |config|
144143 # that one) as well as making sure all non-primary ones have "autostart: false" set
145144 # so that when we do "vagrant up", it doesn't spin up those machines.
146145
147- get_workers . map do |worker_name , data |
148- config . vm . define worker_name do |ubuntu |
149- ubuntu . vm . network 'private_network' , ip : data [ :ip_addr ]
150- ubuntu . vm . network 'forwarded_port' , guest : 22 , host : data [ :ssh_port ] , id : 'ssh'
151- ubuntu . vm . provision 'shell' , inline : gen_script ( worker_name , worker : true , base : base_box )
146+ if ARGV [ 0 ] == 'workers'
147+ if apple_silicon
148+ exec ( "arch" , "-arm64" , "python3" , "vagrant-workers/workers.py" , *ARGV [ 1 ..] )
152149 end
150+ exec ( "python3" , "vagrant-workers/workers.py" , *ARGV [ 1 ..] )
153151 end
154152
155- vm_name = 'ubuntu-22.04'
156- config . vm . define vm_name , primary : true do |ubuntu |
157- ubuntu . vm . network 'forwarded_port' , guest : 1511 , host : ENV . fetch ( 'VM_PORT_SITE' , 1511 )
158- ubuntu . vm . network 'forwarded_port' , guest : 8443 , host : ENV . fetch ( 'VM_PORT_WS' , 8443 )
159- ubuntu . vm . network 'forwarded_port' , guest : 5432 , host : ENV . fetch ( 'VM_PORT_DB' , 16442 )
160- ubuntu . vm . network 'forwarded_port' , guest : 7000 , host : ENV . fetch ( 'VM_PORT_SAML' , 7001 )
161- ubuntu . vm . network 'forwarded_port' , guest : 22 , host : ENV . fetch ( 'VM_PORT_SSH' , 2222 ) , id : 'ssh'
162- ubuntu . vm . provision 'shell' , inline : gen_script ( vm_name , base : base_box )
153+ if ENV . fetch ( 'WORKER_MODE' , '0' ) == '1'
154+ get_workers . map do |worker_name , data |
155+ config . vm . define worker_name do |ubuntu |
156+ ubuntu . vm . network 'private_network' , ip : data [ :ip_addr ]
157+ ubuntu . vm . network 'forwarded_port' , guest : 22 , host : data [ :ssh_port ] , id : 'ssh' unless data [ :ssh_port ] . nil?
158+ ubuntu . vm . provision 'shell' , inline : gen_script ( worker_name , worker : true , base : true )
159+
160+ ubuntu . vm . provider "qemu" do |qe , override |
161+ qe . ssh_host = data [ :ip_addr ]
162+ qe . ssh_port = 22
163+ qe . socket_fd = 3
164+ qe . mac_address = data [ :mac_addr ]
165+ mount_folders ( override , [ ] , 'smb' , ENV . fetch ( 'GATEWAY_IP' , '10.0.2.2' ) )
166+ end
167+ end
168+ end
169+ else
170+ vm_name = 'ubuntu-22.04'
171+ config . vm . define vm_name , primary : true do |ubuntu |
172+ ubuntu . vm . network 'forwarded_port' , guest : 1511 , host : ENV . fetch ( 'VM_PORT_SITE' , 1511 )
173+ ubuntu . vm . network 'forwarded_port' , guest : 8443 , host : ENV . fetch ( 'VM_PORT_WS' , 8443 )
174+ ubuntu . vm . network 'forwarded_port' , guest : 5432 , host : ENV . fetch ( 'VM_PORT_DB' , 16442 )
175+ ubuntu . vm . network 'forwarded_port' , guest : 7000 , host : ENV . fetch ( 'VM_PORT_SAML' , 7001 )
176+ ubuntu . vm . network 'forwarded_port' , guest : 22 , host : ENV . fetch ( 'VM_PORT_SSH' , 2222 ) , id : 'ssh'
177+ ubuntu . vm . provision 'shell' , inline : gen_script ( vm_name , base : base_box )
178+
179+ ubuntu . vm . provider "qemu" do |qe , override |
180+ qe . ssh_port = ENV . fetch ( 'VM_PORT_SSH' , 2222 )
181+ mount_folders ( override , [ ] , 'smb' )
182+ end
183+ end
163184 end
164185
165186 config . vm . provider 'virtualbox' do |vb , override |
@@ -264,10 +285,6 @@ Vagrant.configure(2) do |config|
264285
265286 qe . memory = "2G"
266287 qe . smp = 2
267-
268- qe . ssh_port = ENV . fetch ( 'VM_PORT_SSH' , 2222 )
269-
270- mount_folders ( override , [ ] )
271288 end
272289
273290 config . vm . provision :shell , :inline => " sudo timedatectl set-timezone America/New_York" , run : "once"
0 commit comments