Skip to content

Commit 60a702f

Browse files
committed
Create guestfish upload directory for coreos ignition
Now #629 added support for s390x on coreos ignition, but it didn't create the upload directory before uploading ignition file. Goal of this PR is creating the upload directory, and make sure #629 works regardless of whether the /ignition directory exists.
1 parent 05f2d9e commit 60a702f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

libvirt/domain.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,13 @@ func guestfishExecution(rootPath string, fileToUpload string) error {
351351
return fmt.Errorf("Mount failed: %v, %s", err, getStderr(stderr))
352352
}
353353

354+
// guestfish --remote -- mkdir-p /ignition
355+
cmd = execCommand("guestfish", "--remote", "--", "mkdir-p", "/ignition")
356+
err = cmd.Run()
357+
if err != nil {
358+
return fmt.Errorf("Mkdir failed: %v, %s", err, getStderr(stderr))
359+
}
360+
354361
// This is the real command that upload the file from current location (the local file system)
355362
// to remote file location (the coreos file system)
356363
// guestfish --remote -- upload $4 $3/$4

libvirt/guestfish_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ var supportedCommands = [][]string{
3939
{
4040
"guestfish", "--remote", "--", "mount", "*", "/",
4141
},
42+
{
43+
"guestfish", "--remote", "--", "mkdir-p", "/ignition",
44+
},
4245
{
4346
"guestfish", "--remote", "--", "upload", "*.ign", "/ignition/config.ign",
4447
},
@@ -68,6 +71,9 @@ var supportedCommandTree = map[string]interface{}{
6871
"/": nil,
6972
},
7073
},
74+
"mkdir-p": map[string]interface{}{
75+
"/ignition": nil,
76+
},
7177
"upload": map[string]interface{}{
7278
".*.ign": map[string]interface{}{
7379
"/ignition/config.ign": nil,
@@ -189,6 +195,13 @@ func validateCommandSemanticsAndGenerateOutput(args ...string) (bool, string) {
189195
return false, errMsg
190196
}
191197

198+
if newArgs[3] == "mkdir-p" {
199+
if Mounted == currentGuestfishStatus {
200+
return true, ""
201+
}
202+
return false, errMsg
203+
}
204+
192205
if newArgs[3] == "upload" {
193206
if Mounted == currentGuestfishStatus {
194207
return true, ""

0 commit comments

Comments
 (0)