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

Add udf support #479

Merged
merged 34 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d05517b
add main implementation
vbauzys Aug 25, 2020
3faee0a
git push origin master
vbauzys Aug 25, 2020
a497ca1
git push origin master
vbauzys Sep 3, 2020
71d524d
git push origin master
vbauzys Sep 22, 2020
879296d
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Oct 21, 2020
02a4d81
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Oct 21, 2020
b365d6c
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Oct 27, 2020
808752b
removed not needed after merge
vbauzys Oct 29, 2020
29c17ae
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 5, 2020
9073403
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 12, 2020
9efad14
Merge branch 'vmware:master' into master
vbauzys Oct 11, 2021
dabfd82
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 8, 2021
be532a2
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Nov 10, 2021
6cf856a
git push origin masterMerge branch 'master' of github.com:vmware/go-v…
vbauzys Nov 23, 2021
144ef18
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Nov 25, 2021
8c0217f
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Dec 8, 2021
05ac73e
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Dec 17, 2021
9056c05
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Dec 20, 2021
cb919b2
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 5, 2022
253df2d
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 13, 2022
a1bccce
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 17, 2022
2fa708c
Merge branch 'master' of github.com:vmware/go-vcloud-director
vbauzys Jan 17, 2022
5161390
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Jan 19, 2022
7c0cf81
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Jan 19, 2022
cf4c3fe
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Feb 18, 2022
f7be576
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Feb 22, 2022
f672000
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Mar 24, 2022
60b5e90
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Mar 29, 2022
ccdf254
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Apr 1, 2022
9e4d117
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Apr 4, 2022
eda7368
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys Apr 25, 2022
85ae9ed
Merge branch 'main' of github.com:vmware/go-vcloud-director into main
vbauzys May 26, 2022
6ba01f8
added udf form ISO files support
vbauzys May 26, 2022
ba90880
add changelog
vbauzys May 26, 2022
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
1 change: 1 addition & 0 deletions .changes/v2.16.0/479-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add additional support for UDF type ISO files in `catalog.UploadMediaImage` [GH-479]
7 changes: 4 additions & 3 deletions govcd/api_vcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ type TestConfig struct {
OvfUrl string `yaml:"ovfUrl,omitempty"`
} `yaml:"ova"`
Media struct {
MediaPath string `yaml:"mediaPath,omitempty"`
Media string `yaml:"mediaName,omitempty"`
PhotonOsOvaPath string `yaml:"photonOsOvaPath,omitempty"`
MediaPath string `yaml:"mediaPath,omitempty"`
Media string `yaml:"mediaName,omitempty"`
PhotonOsOvaPath string `yaml:"photonOsOvaPath,omitempty"`
MediaUdfTypePath string `yaml:"mediaUdfTypePath,omitempty"`
} `yaml:"media"`
Misc struct {
LdapContainer string `yaml:"ldapContainer,omitempty"`
Expand Down
28 changes: 28 additions & 0 deletions govcd/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,31 @@ func (vcd *TestVCD) Test_CatalogQueryMediaList(check *C) {
// Check that media name is what it should be
check.Assert(medias[0].Name, Equals, vcd.config.Media.Media)
}

// Tests System function UploadMediaImage by checking if provided UDF type standard iso file uploaded.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if provided UDF type standard iso file uploaded.

This part of the sentence doesn't make sense. Can you fix it on the way in some of your open PRs?

Copy link
Contributor Author

@vbauzys vbauzys Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UDF type of ISO file uploaded sounds better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed on:

// Tests System function UploadMediaImage by using provided ISO file of UDF type.

While in commit:

// Tests System function UploadMediaImage by checking if provided ISO file of UDF type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeletux updated his PR.

func (vcd *TestVCD) Test_CatalogUploadMediaImageWihUdfTypeIso(check *C) {
fmt.Printf("Running: %s\n", check.TestName())

if vcd.config.Media.MediaUdfTypePath == "" {
check.Skip("Skipping test because no UDF type iso path given")
}

catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)

mediaName := check.TestName()

uploadTask, err := catalog.UploadMediaImage(mediaName, "upload from test", vcd.config.Media.MediaUdfTypePath, 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(mediaName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, mediaName)

catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
verifyCatalogItemUploaded(check, catalog, mediaName)

// Delete testing catalog item
deleteCatalogItem(check, catalog, mediaName)
}
23 changes: 17 additions & 6 deletions govcd/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,32 @@ func readHeader(reader io.Reader) (bool, error) {
if headerOk {
return true, nil
} else {
return false, errors.New("file header didn't match ISO standard")
return false, errors.New("file header didn't match ISO or UDF standard")
}
}

// Verify file header info: https://www.garykessler.net/library/file_sigs.html
// Verify file header for ISO or UDF type. Info: https://www.garykessler.net/library/file_sigs.html
func verifyHeader(buf []byte) bool {
// search for CD001(43 44 30 30 31) in specific file places.
//This signature usually occurs at byte offset 32769 (0x8001),
//34817 (0x8801), or 36865 (0x9001).
// ISO verification - search for CD001(43 44 30 30 31) in specific file places.
// This signature usually occurs at byte offset 32769 (0x8001),
// 34817 (0x8801), or 36865 (0x9001).
// UDF verification - search for BEA01(42 45 41 30 31) in specific file places.
// This signature usually occurs at byte offset 32769 (0x8001),
// 34817 (0x8801), or 36865 (0x9001).

return (buf[32769] == 0x43 && buf[32770] == 0x44 &&
buf[32771] == 0x30 && buf[32772] == 0x30 && buf[32773] == 0x31) ||
(buf[34817] == 0x43 && buf[34818] == 0x44 &&
buf[34819] == 0x30 && buf[34820] == 0x30 && buf[34821] == 0x31) ||
(buf[36865] == 0x43 && buf[36866] == 0x44 &&
buf[36867] == 0x30 && buf[36868] == 0x30 && buf[36869] == 0x31)
buf[36867] == 0x30 && buf[36868] == 0x30 && buf[36869] == 0x31) ||
(buf[32769] == 0x42 && buf[32770] == 0x45 &&
buf[32771] == 0x41 && buf[32772] == 0x30 && buf[32773] == 0x31) ||
(buf[34817] == 0x42 && buf[34818] == 0x45 &&
buf[34819] == 41 && buf[34820] == 0x30 && buf[34821] == 0x31) ||
(buf[36865] == 42 && buf[36866] == 45 &&
buf[36867] == 41 && buf[36868] == 0x30 && buf[36869] == 0x31)

}

// Reference for API usage http://pubs.vmware.com/vcloud-api-1-5/wwhelp/wwhimpl/js/html/wwhelp.htm#href=api_prog/GUID-9356B99B-E414-474A-853C-1411692AF84C.html
Expand Down
Binary file added test-resources/udf_test.iso
Binary file not shown.