Use VMWare upload implementation from osbuild/images (HMS-9026)
Delete the VMWare upload implementation from osbuild-composer and use the one from osbuild/images. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
parent
a75f2b95fd
commit
fe840e1ddf
4 changed files with 3 additions and 2 deletions
65
vendor/github.com/osbuild/images/pkg/upload/vmware/vmware.go
generated
vendored
Normal file
65
vendor/github.com/osbuild/images/pkg/upload/vmware/vmware.go
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
package vmware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/vmware/govmomi/cli"
|
||||
_ "github.com/vmware/govmomi/cli/importx"
|
||||
)
|
||||
|
||||
type Credentials struct {
|
||||
Host string
|
||||
Username string
|
||||
Password string
|
||||
Datacenter string
|
||||
Cluster string
|
||||
Datastore string
|
||||
Folder string
|
||||
}
|
||||
|
||||
func commonOptions(creds Credentials) []string {
|
||||
args := []string{
|
||||
fmt.Sprintf("-u=%s:%s@%s", creds.Username, creds.Password, creds.Host),
|
||||
"-k=true",
|
||||
fmt.Sprintf("-pool=%s/Resources", creds.Cluster),
|
||||
fmt.Sprintf("-dc=%s", creds.Datacenter),
|
||||
fmt.Sprintf("-ds=%s", creds.Datastore),
|
||||
}
|
||||
if creds.Folder != "" {
|
||||
args = append(args, fmt.Sprintf("-folder=%s", creds.Folder))
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
// ImportVmdk is a function that uploads a stream optimized vmdk image to vSphere
|
||||
// uploaded image will be present in a directory of the same name
|
||||
func ImportVmdk(creds Credentials, imagePath string) error {
|
||||
args := []string{
|
||||
"import.vmdk",
|
||||
}
|
||||
args = append(args, commonOptions(creds)...)
|
||||
args = append(args, imagePath)
|
||||
retcode := cli.Run(args)
|
||||
|
||||
if retcode != 0 {
|
||||
return fmt.Errorf("importing %s into vSphere failed", imagePath)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ImportOva(creds Credentials, imagePath, targetName string) error {
|
||||
args := []string{
|
||||
"import.ova",
|
||||
fmt.Sprintf("-name=%s", targetName),
|
||||
}
|
||||
args = append(args, commonOptions(creds)...)
|
||||
args = append(args, imagePath)
|
||||
retcode := cli.Run(args)
|
||||
|
||||
if retcode != 0 {
|
||||
return fmt.Errorf("importing %s into vSphere failed", imagePath)
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
1
vendor/modules.txt
vendored
1
vendor/modules.txt
vendored
|
|
@ -1016,6 +1016,7 @@ github.com/osbuild/images/pkg/rpmmd
|
|||
github.com/osbuild/images/pkg/runner
|
||||
github.com/osbuild/images/pkg/sbom
|
||||
github.com/osbuild/images/pkg/upload/koji
|
||||
github.com/osbuild/images/pkg/upload/vmware
|
||||
# github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d
|
||||
## explicit; go 1.21
|
||||
github.com/osbuild/osbuild-composer/pkg/splunk_logger
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue