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

Publish to external VCD ORG and subscribe attributes on OrgGeneralSettings struct #444

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .changes/v2.15.0/444-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Add `CanPublishExternally` and `CanSubscribe` attributes to `OrgGeneralSettings` struct. [GH-444]
33 changes: 24 additions & 9 deletions govcd/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,32 +105,42 @@ func (vcd *TestVCD) Test_UpdateOrg(check *C) {
check.Skip(fmt.Sprintf(TestRequiresSysAdminPrivileges, check.TestName()))
}
type updateSet struct {
orgName string
enabled bool
canPublishCatalogs bool
orgName string
enabled bool
canPublishCatalogs bool
canPublishExternally bool
canSubscribe bool
}

// Tests a combination of enabled and canPublishCatalogs to see
// whether they are updated correctly
var updateOrgs = []updateSet{
{TestUpdateOrg + "1", true, false},
{TestUpdateOrg + "2", false, false},
{TestUpdateOrg + "3", true, true},
{TestUpdateOrg + "4", false, true},
{TestUpdateOrg + "1", true, false, false, false},
{TestUpdateOrg + "2", false, false, false, false},
{TestUpdateOrg + "3", true, true, true, false},
{TestUpdateOrg + "4", false, true, false, true},
}

for _, uo := range updateOrgs {

fmt.Printf("Org %s - enabled %v - catalogs %v\n", uo.orgName, uo.enabled, uo.canPublishCatalogs)
task, err := CreateOrg(vcd.client, uo.orgName, uo.orgName, uo.orgName, &types.OrgSettings{
OrgGeneralSettings: &types.OrgGeneralSettings{CanPublishCatalogs: uo.canPublishCatalogs},
OrgLdapSettings: &types.OrgLdapSettingsType{OrgLdapMode: "NONE"},
OrgGeneralSettings: &types.OrgGeneralSettings{
CanPublishCatalogs: uo.canPublishCatalogs,
CanPublishExternally: uo.canPublishExternally,
CanSubscribe: uo.canSubscribe,
},
OrgLdapSettings: &types.OrgLdapSettingsType{OrgLdapMode: "NONE"},
}, uo.enabled)

check.Assert(err, IsNil)
check.Assert(task, Not(Equals), Task{})

err = task.WaitTaskCompletion()
check.Assert(err, IsNil)

AddToCleanupList(uo.orgName, "org", "", "TestUpdateOrg")

// fetch newly created org
adminOrg, err := vcd.client.GetAdminOrgByName(uo.orgName)
check.Assert(err, IsNil)
Expand All @@ -144,6 +154,9 @@ func (vcd *TestVCD) Test_UpdateOrg(check *C) {
adminOrg.AdminOrg.Description = updatedDescription
adminOrg.AdminOrg.FullName = updatedFullName
adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishCatalogs = !uo.canPublishCatalogs
adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishExternally = !uo.canPublishExternally
adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanSubscribe = !uo.canSubscribe

adminOrg.AdminOrg.IsEnabled = !uo.enabled

task, err = adminOrg.Update()
Expand All @@ -160,6 +173,8 @@ func (vcd *TestVCD) Test_UpdateOrg(check *C) {

check.Assert(updatedAdminOrg.AdminOrg.IsEnabled, Equals, !uo.enabled)
check.Assert(updatedAdminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishCatalogs, Equals, !uo.canPublishCatalogs)
check.Assert(updatedAdminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishExternally, Equals, !uo.canPublishExternally)
check.Assert(updatedAdminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanSubscribe, Equals, !uo.canSubscribe)
if testVerbose {
fmt.Printf("[updated] Org %s - enabled %v (expected %v) - catalogs %v (expected %v)\n",
updatedAdminOrg.AdminOrg.Name,
Expand Down
2 changes: 2 additions & 0 deletions types/v56/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ type OrgGeneralSettings struct {
Link LinkList `xml:"Link,omitempty"` // A reference to an entity or operation associated with this object.

CanPublishCatalogs bool `xml:"CanPublishCatalogs,omitempty"`
CanPublishExternally bool `xml:"CanPublishExternally,omitempty"`
CanSubscribe bool `xml:"CanSubscribe,omitempty"`
DeployedVMQuota int `xml:"DeployedVMQuota,omitempty"`
StoredVMQuota int `xml:"StoredVmQuota,omitempty"`
UseServerBootSequence bool `xml:"UseServerBootSequence,omitempty"`
Expand Down