Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Local iso upload in content library item #1665

Merged
merged 3 commits into from
Jun 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,17 @@ func CreateLibraryItem(c *rest.Client, l *library.Library, name string, desc str

isOva := false
isLocal := true
isIso := false

if strings.HasPrefix(file, "http") {
isLocal = false
}
if strings.HasSuffix(file, ".ova") {
isOva = true
}
if strings.HasSuffix(file, ".iso") {
isIso = true
}

ovfDescriptor, err := ovfdeploy.GetOvfDescriptor(file, isOva, isLocal, true)
if err != nil {
Expand All @@ -207,8 +211,10 @@ func CreateLibraryItem(c *rest.Client, l *library.Library, name string, desc str
switch {
case isLocal && isOva:
return &id, uploadSession.deployLocalOva(file, ovfDescriptor)
case isLocal && !isOva:
case isLocal && !isOva && !isIso:
return &id, uploadSession.deployLocalOvf(file, ovfDescriptor)
case isLocal && isIso:
return &id, uploadSession.deployLocalIso(file)
case !isLocal && isOva:
return &id, uploadSession.deployRemoteOva(file, ovfDescriptor)
case !isLocal && !isOva:
Expand Down Expand Up @@ -274,6 +280,13 @@ func (uploadSession *libraryUploadSession) deployLocalOva(file string, ovfDescri
return uploadSession.uploadOvaDisksFromLocal(file, e)
}

func (uploadSession *libraryUploadSession) deployLocalIso(file string) error {
if err := uploadSession.uploadLocalFile(file); err != nil {
return err
}
return nil
}

type libraryUploadSession struct {
ContentLibraryManager *library.Manager
RestClient *rest.Client
Expand Down