0.8.1: switch dropdown shows type, interface and IP; chosen switch is written into the new VM config
This commit is contained in:
1 parent
dd395dfe76
commit
81b4d6a63e
5 files changed
+54
-10
No files matched your search
@@ -173,6 +173,23 @@ fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
$rc = proc_close($proc);
|
||||
|
||||
// the wizard may pick a switch; vm-bhyve takes it from the template, so patch it in
|
||||
if ($verb === 'create' && !empty($job['switch'])) {
|
||||
$conf = vmm_vm_conf_path($name);
|
||||
if ($conf !== '' && is_file($conf)) {
|
||||
$text = (string)file_get_contents($conf);
|
||||
$want = 'network0_switch="' . $job['switch'] . '"';
|
||||
if (preg_match('/^network0_switch="[^"]*"/m', $text)) {
|
||||
$text = preg_replace('/^network0_switch="[^"]*"/m', $want, $text, 1);
|
||||
} else {
|
||||
$text = rtrim($text) . "\n" . $want . "\n";
|
||||
}
|
||||
if (file_put_contents($conf, $text) !== false) {
|
||||
joblog($log, 'network0_switch set to ' . $job['switch']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vm-bhyve often returns 0 even when it refused the operation, so the
|
||||
// resulting state is what counts. Some states are transitional (a guest that
|
||||
// just booted reports "bootloader" for a moment), so wait a little.
|
||||
|
||||
Reference in new issue
Block a user