@@ -79,29 +79,28 @@ base_boxes[:arm_bento] = "bento/ubuntu-22.04-arm64"
79
79
base_boxes [ :libvirt ] = "generic/ubuntu2204"
80
80
base_boxes [ :arm_mac_qemu ] = "perk/ubuntu-2204-arm64"
81
81
82
-
83
- def mount_folders ( config , mount_options , type = nil )
82
+ def mount_folders ( config , mount_options , type = nil , host = '10.0.2.2' )
84
83
# ideally we would use submitty_daemon or something as the owner/group, but since that user doesn't exist
85
84
# till post-provision (and this is mounted before provisioning), we want the group to be 'vagrant'
86
85
# which is guaranteed to exist and that during install_system.sh we add submitty_daemon/submitty_php/etc to the
87
86
# vagrant group so that they can write to this shared folder, primarily just for the log files
88
87
owner = 'root'
89
88
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
91
90
92
91
optional_repos = %w( AnalysisTools AnalysisToolsTS Lichen RainbowGrades Tutorial CrashCourseCPPSyntax IntroQuantumComputing LichenTestData DockerImages DockerImagesRPI )
93
92
optional_repos . each { |repo |
94
93
repo_path = File . expand_path ( "../" + repo )
95
94
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
97
96
end
98
97
}
99
98
end
100
99
101
100
def get_workers ( )
102
101
worker_file = File . join ( __dir__ , '.vagrant' , 'workers.json' )
103
102
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 ]
105
104
else
106
105
return Hash [ ]
107
106
end
@@ -144,22 +143,44 @@ Vagrant.configure(2) do |config|
144
143
# that one) as well as making sure all non-primary ones have "autostart: false" set
145
144
# so that when we do "vagrant up", it doesn't spin up those machines.
146
145
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 ..] )
152
149
end
150
+ exec ( "python3" , "vagrant-workers/workers.py" , *ARGV [ 1 ..] )
153
151
end
154
152
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
163
184
end
164
185
165
186
config . vm . provider 'virtualbox' do |vb , override |
@@ -264,10 +285,6 @@ Vagrant.configure(2) do |config|
264
285
265
286
qe . memory = "2G"
266
287
qe . smp = 2
267
-
268
- qe . ssh_port = ENV . fetch ( 'VM_PORT_SSH' , 2222 )
269
-
270
- mount_folders ( override , [ ] )
271
288
end
272
289
273
290
config . vm . provision :shell , :inline => " sudo timedatectl set-timezone America/New_York" , run : "once"
0 commit comments