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

Site and Org associations #1260

Open
wants to merge 60 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d38a160
WIP
dataclouder Apr 25, 2024
08d0e1c
WIP Add site/org association entities
dataclouder Apr 30, 2024
4c3891e
Update ID handling in association resources
dataclouder Apr 30, 2024
25353a1
Update error message
dataclouder Apr 30, 2024
c00ba9a
Update vcd_resource_list for site associations
dataclouder Apr 30, 2024
1e6a668
Remove unnecessary association_data_file in vcd_org data source
dataclouder Apr 30, 2024
dc68643
Update docs
dataclouder Apr 30, 2024
eb6850a
Add Import and update funcs to associations
dataclouder May 4, 2024
92a4d97
Update go.mod
dataclouder May 6, 2024
6b2e8db
Merge branch 'main' into site-org-associations
dataclouder May 6, 2024
e5442e7
Adapt resource/data source names to suggestions
dataclouder May 9, 2024
a88f68d
Add all-at-once example
dataclouder May 9, 2024
eb537f2
[skip-ci] Update examples version
dataclouder May 9, 2024
166fdf0
Merge branch 'main' into site-org-associations
dataclouder May 14, 2024
a39a6a4
WIP
dataclouder May 17, 2024
761bc01
Merge branch 'main' into site-org-associations
dataclouder May 17, 2024
ec89936
Merge branch 'main' into site-org-associations
dataclouder May 22, 2024
e5f3763
Update Org association test
dataclouder May 28, 2024
c74400b
Add skip for short test
dataclouder May 28, 2024
1ff9c51
Update Org association test
dataclouder May 28, 2024
0e3e4ca
Add skip for Org association binary test
dataclouder May 28, 2024
f129a3c
Add comprehensive test for site/org association
dataclouder May 31, 2024
be00b8a
Improve tests
dataclouder May 31, 2024
3c24236
Update tests
dataclouder Jun 3, 2024
b03ddfa
Add some documentation
dataclouder Jun 3, 2024
f1e257a
Update govcd
dataclouder Jun 3, 2024
f121f12
Merge branch 'main' into site-org-associations
dataclouder Jun 3, 2024
b205c08
Add more documentation
dataclouder Jun 6, 2024
b50382e
Update association data sources
dataclouder Jun 6, 2024
32f5ca7
Update docs
dataclouder Jun 6, 2024
b3490a5
Merge branch 'main' into site-org-associations
dataclouder Jun 6, 2024
3a8e0ab
Add example of multi-org association
dataclouder Jun 10, 2024
7a5d6c1
Add multi-site resources docs
dataclouder Jun 10, 2024
253349f
Add first draft of site and org association guide
dataclouder Jun 10, 2024
1cdcbb2
Update example path
dataclouder Jun 11, 2024
7956f85
Improve DataSourceNotFound test
dataclouder Jun 12, 2024
040e13a
Update docs
dataclouder Jun 12, 2024
57df3c9
Update test DatasourceNotFound
dataclouder Jun 12, 2024
4bd5ae5
Add unified site association test
dataclouder Jun 12, 2024
0a42519
Update tests
dataclouder Jun 12, 2024
4183aed
Add Changelog entries
dataclouder Jun 12, 2024
1400754
Update docs
dataclouder Jun 12, 2024
ff88eb8
Merge branch 'main' into site-org-associations
dataclouder Jun 12, 2024
dc38aff
Remove unnecessary comment
dataclouder Jun 13, 2024
d940316
Merge branch 'main' into site-org-associations
dataclouder Jun 13, 2024
4358e86
Update go.mod
dataclouder Jun 13, 2024
7a03986
Update examples
dataclouder Jun 13, 2024
4cb44b3
Remove leftover comments
dataclouder Jun 13, 2024
1b23238
Merge branch 'main' into site-org-associations
dataclouder Jun 13, 2024
2e8fe78
Merge branch 'main' into site-org-associations
dataclouder Jun 14, 2024
948cd88
Merge branch 'main' into site-org-associations
dataclouder Jun 17, 2024
5127f96
Update govcd
dataclouder Jun 17, 2024
06e8d1b
Update documentation
dataclouder Jun 18, 2024
a47de96
Update documentation
dataclouder Jun 18, 2024
10cced0
Update documentation
dataclouder Jun 18, 2024
7dffe09
Merge branch 'main' into site-org-associations
dataclouder Jun 19, 2024
5cbb4a5
Merge branch 'main' into site-org-associations
dataclouder Jun 20, 2024
5b0afe1
Merge branch 'main' into site-org-associations
dataclouder Jun 20, 2024
108040d
Merge branch 'main' into site-org-associations
dataclouder Jun 21, 2024
dc2c3e2
Fix test formatting
dataclouder Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/v3.13.0/1260-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* **New Data Source:** `vcd_multisite_site` to read the state and associations of current site [GH-1260]
* **New Data Source:** `vcd_multisite_site_data` to produce the association data needed to start a site association [GH-1260]
* **New Data Source:** `vcd_multisite_site_association` to read the details of a site association [GH-1260]
* **New Resource:** `vcd_multisite_site_association` to associate the current site with a remote one [GH-1260]
* **New Data Source:** `vcd_multisite_org_data` to produce the association data needed to start an organization association [GH-1260]
* **New Data Source:** `vcd_multisite_org_association` to read the details of an organization association [GH-1260]
* **New Resource:** `vcd_multisite_org_association` to associate a local organization with a remote one [GH-1260]
* **New Guide** `Site and Org associations` to describe association operations for sites and organizations [GH-1260]
1 change: 1 addition & 0 deletions .changes/v3.13.0/1260-improvements.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Data source `vcd_resource_list` can now list site and organization associations [GH-1260]
61 changes: 61 additions & 0 deletions examples/multi-site/org-all-at-once/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
provider "vcd" {
user = var.vcd_admin
password = var.vcd_password
token = ""
api_token = ""
auth_type = "integrated"
saml_adfs_rpt_id = ""
url = var.vcd_url
sysorg = var.vcd_sysorg
org = var.vcd_org1
allow_unverified_ssl = "true"
max_retry_timeout = 600
logging = true
logging_file = "go-vcloud-director.log"
}

data "vcd_org" "org1" {
name = var.vcd_org1
}
data "vcd_org" "org2" {
name = var.vcd_org2
}

data "vcd_multisite_org_data" "org1-data" {
org_id = data.vcd_org.org1.id
}

data "vcd_multisite_org_data" "org2-data" {
org_id = data.vcd_org.org2.id
}

data "vcd_resource_list" "orgs" {
name = "org_associations"
resource_type = "vcd_multisite_org_association"
list_mode = "name_id"
}

resource "vcd_multisite_org_association" "org1-org2" {
org_id = data.vcd_org.org1.id
association_data = data.vcd_multisite_org_data.org2-data.association_data
connection_timeout_mins = 2
}

resource "vcd_multisite_org_association" "org2-org1" {
org_id = data.vcd_org.org2.id
association_data = data.vcd_multisite_org_data.org1-data.association_data
connection_timeout_mins = 2
}

output "org2-org1" {
value = vcd_multisite_org_association.org2-org1
}


output "org1-org2" {
value = vcd_multisite_org_association.org1-org2
}

output "org_associations" {
value = data.vcd_resource_list.orgs
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Rename this file to 'terraform.tfvars' and update the variables to their intended values
vcd_url = "https://example1.com/api"
vcd_admin = "administrator"
vcd_password = "myPassword"
vcd_sysorg = "System"
vcd_org1 = "nameOfMyOrg"
vcd_org2 = "nameOfMyOtherOrg"
26 changes: 26 additions & 0 deletions examples/multi-site/org-all-at-once/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

variable "vcd_url" {
type = string
}

variable "vcd_admin" {
type = string
default = "administrator"
}

variable "vcd_sysorg" {
type = string
default = "System"
}

variable "vcd_password" {
type = string
}

variable "vcd_org1" {
type = string
}

variable "vcd_org2" {
type = string
}
9 changes: 9 additions & 0 deletions examples/multi-site/org-all-at-once/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
vcd = {
source = "vmware/vcd"
version = ">=3.13.0"
}
}
}

45 changes: 45 additions & 0 deletions examples/multi-site/site-all-at-once/config1.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
provider "vcd" {
alias = "vcd1"
user = var.vcd_admin1
password = var.vcd_password1
token = ""
api_token = ""
auth_type = "integrated"
saml_adfs_rpt_id = ""
url = var.vcd_url1
sysorg = var.vcd_sysorg1
org = var.vcd_org1
allow_unverified_ssl = "true"
max_retry_timeout = 600
logging = true
logging_file = "go-vcloud-director-1.log"
}

data "vcd_org" "org1" {
provider = vcd.vcd1
name = var.vcd_org1
}

data "vcd_multisite_org_data" "org1-data" {
provider = vcd.vcd1
org_id = data.vcd_org.org1.id
download_to_file = "${var.vcd_org1}.xml"
}

data "vcd_multisite_site_data" "site1-data" {
provider = vcd.vcd1
download_to_file = "${var.site_name1}-site.xml"
}

# The data files are needed because the data will be read by resources handled by a different user, which can't read
# directly the data source that is the origin of these files

data "local_file" "site1" {
filename = "${var.site_name1}-site.xml"
depends_on = [data.vcd_multisite_site_data.site1-data]
}

data "local_file" "org1" {
filename = "${var.vcd_org1}.xml"
depends_on = [data.vcd_multisite_org_data.org1-data]
}
43 changes: 43 additions & 0 deletions examples/multi-site/site-all-at-once/config1a.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

data "vcd_resource_list" "sites" {
provider = vcd.vcd1
name = "site_associations"
resource_type = "vcd_multisite_site_association"
list_mode = "name_id"
}

data "vcd_resource_list" "orgs" {
provider = vcd.vcd1
name = "org_associations"
resource_type = "vcd_multisite_org_association"
list_mode = "name_id"
}

resource "vcd_multisite_site_association" "site1-site2" {
provider = vcd.vcd1
association_data = data.local_file.site2.content
connection_timeout_mins = 2
}

resource "vcd_multisite_org_association" "org1-org2" {
provider = vcd.vcd1
org_id = data.vcd_org.org1.id
association_data = data.local_file.org2.content
connection_timeout_mins = 2
depends_on = [vcd_multisite_site_association.site1-site2]
}

output "site1-site2" {
value = vcd_multisite_site_association.site1-site2
}

output "org1-org2" {
value = vcd_multisite_org_association.org1-org2
}

output "site_associations" {
value = data.vcd_resource_list.sites
}
output "org_associations" {
value = data.vcd_resource_list.orgs
}
45 changes: 45 additions & 0 deletions examples/multi-site/site-all-at-once/config2.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
provider "vcd" {
alias = "vcd2"
user = var.vcd_admin2
password = var.vcd_password2
token = ""
api_token = ""
auth_type = "integrated"
saml_adfs_rpt_id = ""
url = var.vcd_url2
sysorg = var.vcd_sysorg2
org = var.vcd_org2
allow_unverified_ssl = "true"
max_retry_timeout = 600
logging = true
logging_file = "go-vcloud-director-2.log"
}

data "vcd_org" "org2" {
provider = vcd.vcd2
name = var.vcd_org2
}

data "vcd_multisite_org_data" "org2-data" {
provider = vcd.vcd2
org_id = data.vcd_org.org2.id
download_to_file = "${var.vcd_org2}.xml"
}

data "vcd_multisite_site_data" "site2-data" {
provider = vcd.vcd2
download_to_file = "${var.site_name2}-site.xml"
}

# The data files are needed because the data will be read by resources handled by a different user, which can't read
# directly the data source that is the origin of these files

data "local_file" "site2" {
filename = "${var.site_name2}-site.xml"
depends_on = [data.vcd_multisite_site_data.site2-data]
}

data "local_file" "org2" {
filename = "${var.vcd_org2}.xml"
depends_on = [data.vcd_multisite_org_data.org2-data]
}
22 changes: 22 additions & 0 deletions examples/multi-site/site-all-at-once/config2a.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

resource "vcd_multisite_site_association" "site2-site1" {
provider = vcd.vcd2
association_data = data.local_file.site1.content
connection_timeout_mins = 2
}

resource "vcd_multisite_org_association" "org2-org1" {
provider = vcd.vcd2
org_id = data.vcd_org.org2.id
association_data = data.local_file.org1.content
connection_timeout_mins = 2
depends_on = [vcd_multisite_site_association.site2-site1]
}

output "site2-site1" {
value = vcd_multisite_site_association.site2-site1
}

output "org2-org1" {
value = vcd_multisite_org_association.org2-org1
}
14 changes: 14 additions & 0 deletions examples/multi-site/site-all-at-once/terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Rename this file to 'terraform.tfvars' and update the variables to their intended values
vcd_site_name1 = "SITE1"
vcd_url1 = "https://example1.com/api"
vcd_admin1 = "administrator"
vcd_password1 = "myPassword"
vcd_sysorg1 = "System"
vcd_org1 = "nameOfMyOrg"

vcd_site_name2 = "SITE2"
vcd_url2 = "https://example2.com/api"
vcd_admin2 = "administrator"
vcd_password2 = "anotherPassword"
vcd_sysorg2 = "System"
vcd_org2 = "nameOfMyOtherOrg"
62 changes: 62 additions & 0 deletions examples/multi-site/site-all-at-once/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# -----------------------
# site 1
# -----------------------

variable "site_name1" {
type = string
default = "site1"
}

variable "vcd_url1" {
type = string
}

variable "vcd_admin1" {
type = string
default = "administrator"
}

variable "vcd_sysorg1" {
type = string
default = "System"
}

variable "vcd_password1" {
type = string
}

variable "vcd_org1" {
type = string
}

# -----------------------
# site 2
# -----------------------

variable "site_name2" {
type = string
default = "site2"
}

variable "vcd_url2" {
type = string
}

variable "vcd_admin2" {
type = string
default = "administrator"
}

variable "vcd_sysorg2" {
type = string
default = "System"
}

variable "vcd_password2" {
type = string
}

variable "vcd_org2" {
type = string
}
9 changes: 9 additions & 0 deletions examples/multi-site/site-all-at-once/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
vcd = {
source = "vmware/vcd"
version = ">=3.13.0"
}
}
}

4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ require (
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
)

replace github.com/vmware/go-vcloud-director/v2 => github.com/dataclouder/go-vcloud-director/v2 v2.17.0-alpha.3.0.20240617070637-7f67778da98f

// replace github.com/vmware/go-vcloud-director/v2 => ../go-vcloud-director
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reminder to remove this replacement before merging

4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
github.com/dataclouder/go-vcloud-director/v2 v2.17.0-alpha.3.0.20240617070637-7f67778da98f h1:qqS7RHF5dHrARPfn1ayw8zgC+dRVqn2uUu3CFiKKsKM=
github.com/dataclouder/go-vcloud-director/v2 v2.17.0-alpha.3.0.20240617070637-7f67778da98f/go.mod h1:vbuNYzuADDBFhi9i2dIKWeNxMK1VFF0dACq01amYBIM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -148,8 +150,6 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
github.com/vmware/go-vcloud-director/v2 v2.25.0-alpha.8 h1:I0ZSGT0kFe4HF1s9JTS6Z2GyeuipVOpwuSczwj72sEk=
github.com/vmware/go-vcloud-director/v2 v2.25.0-alpha.8/go.mod h1:vbuNYzuADDBFhi9i2dIKWeNxMK1VFF0dACq01amYBIM=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down