Skip to content

Commit

Permalink
Bug 1882649: Determine Glance disk format based on file extension
Browse files Browse the repository at this point in the history
Now we always use "qcow2" disk format for Glance images. This is not
correct if a user wants to upload a raw format image (with "raw" file
extension).
This commit checks the extension and allows to set disk format
accordingly.
  • Loading branch information
Fedosin committed Oct 19, 2020
1 parent cf57c06 commit 733e8e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/tfvars/openstack/rhcos_image.go
Expand Up @@ -3,6 +3,7 @@ package openstack
import (
"fmt"
"os"
"path/filepath"
"time"

"github.com/gophercloud/gophercloud"
Expand Down Expand Up @@ -33,10 +34,17 @@ func uploadBaseImage(cloud string, localFilePath string, imageName string, clust
return err
}

// By default we use "qcow2" disk format, but if the file extension is "raw",
// then we set the disk format as "raw".
diskFormat := "qcow2"
if extension := filepath.Ext(localFilePath); extension == "raw" {
diskFormat = "raw"
}

imageCreateOpts := images.CreateOpts{
Name: imageName,
ContainerFormat: "bare",
DiskFormat: "qcow2",
DiskFormat: diskFormat,
Tags: []string{fmt.Sprintf("openshiftClusterID=%s", clusterID)},
// TODO(mfedosin): add Description when gophercloud supports it.
}
Expand Down

0 comments on commit 733e8e5

Please sign in to comment.