-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DCaaS] add new resource and datasource for `opentelekomcloud_direct_…
…connect_v2` (#2287) [DCaaS] add new resource and datasource for `opentelekomcloud_direct_connect_v2` Summary of the Pull Request PR Checklist Refers to: #2215 Tests added/passed. Documentation added. Schema updated. Release notes added. Acceptance Steps Performed === RUN TestDirectConnectV2Datasource_basic --- PASS: TestDirectConnectV2Datasource_basic (32.31s) PASS Process finished with the exit code 0 === RUN TestDirectConnectV2Resource_basic --- PASS: TestDirectConnectV2Resource_basic (52.84s) PASS Process finished with the exit code 0 Reviewed-by: Anton Sidelnikov Reviewed-by: Artem Lifshits
- Loading branch information
1 parent
8f3ce88
commit 5a5a2db
Showing
10 changed files
with
972 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
subcategory: "Direct Connect (DCaaS)" | ||
--- | ||
# opentelekomcloud_direct_connect_v2 (Data Source) | ||
|
||
Use this data source to get details about a specific Direct Connect (DCaaS) connection. | ||
|
||
Example usage | ||
----------------- | ||
|
||
```hcl | ||
data "opentelekomcloud_direct_connect_v2" "direct_connect" { | ||
id = "direct_connect_id" | ||
} | ||
``` | ||
|
||
|
||
## Argument Reference | ||
|
||
- `id` (String) - Specifies the direct connection ID. | ||
|
||
## Attributes Reference | ||
* `bandwidth` (Number) - Specifies the bandwidth of the connection in Mbit/s. | ||
* `location` (String) - Specifies the connection access location. | ||
* `provider_name` (String) - Specifies the carrier who provides the leased line. | ||
* `port_type` (String) - Specifies the type of the port used by the connection. The value can be 1G, 10G, 40G, or 100G. | ||
* `admin_state_up` (Boolean) - Specifies the administrative status of the connection. The value can be true or false. | ||
* `charge_mode` (String) - Specifies the billing mode. The value can only be port for operations connections. | ||
* `description` (String) - Provides supplementary information about the connection. | ||
* `device_id` (String) - Specifies the gateway device ID of the connection. | ||
* `hosting_id` (String) - Specifies the ID of the operations connection on which the hosted connection is created. | ||
* `interface_name` (String) - Specifies the name of the interface accessed by the connection. | ||
* `name` (String) - Specifies the connection name. | ||
* `order_id` (String) - Specifies the connection order ID, which is used to support duration-based billing and identify user orders. | ||
* `peer_location` (String) - Specifies the physical location of the peer device accessed by the connection, specific to the street or data center name. | ||
* `product_id` (String) - Specifies the product ID corresponding to the connection's order, which is used to custom billing policies such as duration-based packages. | ||
* `provider_status` (String) - Specifies the status of the carrier's leased line. The value can be ACTIVE or DOWN. | ||
* `redundant_id` (String) - Specifies the ID of the redundant connection using the same gateway. | ||
* `status` (String) - Specifies the connection status. | ||
The value can be ACTIVE, DOWN, BUILD, ERROR, PENDING_DELETE, DELETED, APPLY, DENY, PENDING_PAY, PAID, ORDERING, ACCEPT, or REJECTED. | ||
* `tenant_id` (String) - Specifies the project ID. | ||
* `type` (String) - Specifies the connection type. The value can only be hosted. | ||
* `vlan` (Number) - Specifies the VLAN ID of the connection. | ||
* `applicant` (String) - This is a reserved field, which is not used currently. | ||
* `apply_time` (String) - Specifies the time when the connection was requested. | ||
* `building_line_product_id` (String) - This is a reserved field, which is not used currently. | ||
* `cable_label` (String) - This is a reserved field, which is not used currently. | ||
* `create_time` (String) - Specifies the time when the connection is created. | ||
* `delete_time` (String) - Specifies the time when the connection was deleted. | ||
* `email` (String) - This is a reserved field, which is not used currently. | ||
* `id` (String) - Specifies the connection ID. | ||
* `lag_id` (String) - This is a reserved field, which is not used currently. | ||
* `last_onestop_product_id` (String) - This is a reserved field, which is not used currently. | ||
* `mobile` (String) - This is a reserved field, which is not used currently. | ||
* `onestop_product_id` (String) - This is a reserved field, which is not used currently. | ||
* `peer_port_type` (String) - This is a reserved field, which is not used currently. | ||
* `peer_provider` (String) - This is a reserved field, which is not used currently. | ||
* `period_num` (Number) - This is a reserved field, which is not used currently. | ||
* `period_type` (Number) - This is a reserved field, which is not used currently. | ||
* `reason` (String) - This is a reserved field, which is not used currently. | ||
* `region_id` (String) - Specifies the region ID. | ||
* `service_key` (String) - This is a reserved field, which is not used currently. | ||
* `spec_code` (String) - This is a reserved field, which is not used currently. | ||
* `vgw_type` (String) - Specifies the type of the gateway. Currently, only the default type is supported. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
subcategory: "Direct Connect (DCaaS)" | ||
--- | ||
# opentelekomcloud_direct_connect_v2 (Resource) | ||
|
||
Up-to-date reference of API arguments for Direct Connect (DCaaS) you can get at | ||
`https://docs.otc.t-systems.com/direct-connect/api-ref/apis/connection/creating_a_connection.html`. | ||
|
||
Example usage | ||
----------------- | ||
```hcl | ||
resource "opentelekomcloud_direct_connect_v2" "direct_connect" { | ||
name = "direct_connect" | ||
bandwidth = 100 | ||
location = "location" | ||
provider_name = "provider_name" | ||
port_type = "port_type" | ||
admin_state_up = true | ||
} | ||
``` | ||
|
||
|
||
## Argument Reference | ||
|
||
### Required | ||
|
||
* `bandwidth` (Number) - Specifies the bandwidth of the connection in Mbit/s. | ||
* `location` (String, ForceNew) - Specifies the connection access location. | ||
* `provider_name` (String, ForceNew) - Specifies the carrier who provides the leased line. | ||
* `port_type` (String, ForceNew) - Specifies the type of the port used by the connection. The value can be 1G, 10G, 40G, or 100G. | ||
|
||
### Optional | ||
|
||
* `admin_state_up` (Boolean, ForceNew) - Specifies the administrative status of the connection. The value can be true or false. | ||
* `charge_mode` (String, ForceNew) - Specifies the billing mode. The value can only be port for operations connections. | ||
* `description` (String) - Provides supplementary information about the connection. | ||
* `device_id` (String, ForceNew) - Specifies the gateway device ID of the connection. | ||
* `hosting_id` (String, ForceNew) - Specifies the ID of the operations connection on which the hosted connection is created. | ||
* `interface_name` (String, ForceNew) - Specifies the name of the interface accessed by the connection. | ||
* `name` (String) - Specifies the connection name. | ||
* `order_id` (String, ForceNew) - Specifies the connection order ID, which is used to support duration-based billing and identify user orders. | ||
* `peer_location` (String, ForceNew) - Specifies the physical location of the peer device accessed by the connection, specific to the street or data center name. | ||
* `product_id` (String, ForceNew) - Specifies the product ID corresponding to the connection's order, which is used to custom billing policies such as duration-based packages. | ||
* `provider_status` (String) - Specifies the status of the carrier's leased line. The value can be ACTIVE or DOWN. | ||
* `redundant_id` (String, ForceNew) - Specifies the ID of the redundant connection using the same gateway. | ||
* `status` (String, ForceNew) - Specifies the connection status. | ||
The value can be: `ACTIVE, DOWN, BUILD, ERROR, PENDING_DELETE, DELETED, APPLY, DENY, PENDING_PAY, PAID, ORDERING, ACCEPT, or REJECTED.` | ||
* `tenant_id` (String, ForceNew) - Specifies the project ID. | ||
* `type` (String, ForceNew) - Specifies the connection type. The value can only be `hosted`. | ||
* `vlan` (Number, ForceNew) - Specifies the VLAN ID of the connection. | ||
|
||
## Attributes Reference | ||
|
||
* `applicant` (String) - This is a reserved field, which is not used currently. | ||
* `apply_time` (String) - Specifies the time when the connection was requested. | ||
* `building_line_product_id` (String) - This is a reserved field, which is not used currently. | ||
* `cable_label` (String) - This is a reserved field, which is not used currently. | ||
* `create_time` (String) - Specifies the time when the connection is created. | ||
* `delete_time` (String) - Specifies the time when the connection was deleted. | ||
* `email` (String) - This is a reserved field, which is not used currently. | ||
* `id` (String) - Specifies the connection ID. | ||
* `lag_id` (String) - This is a reserved field, which is not used currently. | ||
* `last_onestop_product_id` (String) - This is a reserved field, which is not used currently. | ||
* `mobile` (String) - This is a reserved field, which is not used currently. | ||
* `onestop_product_id` (String) - This is a reserved field, which is not used currently. | ||
* `peer_port_type` (String) - This is a reserved field, which is not used currently. | ||
* `peer_provider` (String) - This is a reserved field, which is not used currently. | ||
* `period_num` (Number) - This is a reserved field, which is not used currently. | ||
* `period_type` (Number) - This is a reserved field, which is not used currently. | ||
* `reason` (String) - This is a reserved field, which is not used currently. | ||
* `region_id` (String) - Specifies the region ID. | ||
* `service_key` (String) - This is a reserved field, which is not used currently. | ||
* `spec_code` (String) - This is a reserved field, which is not used currently. | ||
* `vgw_type` (String) - Specifies the type of the gateway. Currently, only the default type is supported. |
45 changes: 45 additions & 0 deletions
45
opentelekomcloud/acceptance/dcaas/datasource_opentelekomcloud_direct_connect_v2_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package dcaas | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/common" | ||
) | ||
|
||
func TestDirectConnectV2Datasource_basic(t *testing.T) { | ||
var directConnectName = fmt.Sprintf("dc-%s", acctest.RandString(5)) | ||
const dc = "opentelekomcloud_direct_connect_v2.direct_connect" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { common.TestAccPreCheck(t) }, | ||
ProviderFactories: common.TestAccProviderFactories, | ||
CheckDestroy: testAccCheckDirectConnectV2Destroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDirectConnectV2Datasource_basic(directConnectName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(dc, "bandwidth", "100"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDirectConnectV2Datasource_basic(directConnectName string) string { | ||
return fmt.Sprintf(` | ||
resource "opentelekomcloud_direct_connect_v2" "direct_connect" { | ||
name = "%s" | ||
port_type = "1G" | ||
location = "Biere" | ||
bandwidth = 100 | ||
provider_name = "OTC" | ||
} | ||
data "opentelekomcloud_direct_connect_v2" "direct_connect" { | ||
id = opentelekomcloud_direct_connect_v2.direct_connect.id | ||
} | ||
`, directConnectName) | ||
} |
93 changes: 93 additions & 0 deletions
93
opentelekomcloud/acceptance/dcaas/resource_opentelekomcloud_direct_connect_v2_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package dcaas | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform" | ||
golangsdk "github.com/opentelekomcloud/gophertelekomcloud" | ||
dcaas "github.com/opentelekomcloud/gophertelekomcloud/openstack/dcaas/v2/direct-connect" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/common" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/acceptance/env" | ||
"github.com/opentelekomcloud/terraform-provider-opentelekomcloud/opentelekomcloud/common/cfg" | ||
) | ||
|
||
func TestDirectConnectV2Resource_basic(t *testing.T) { | ||
directConnectName := fmt.Sprintf("dc-%s", acctest.RandString(5)) | ||
directConnectNameUpdated := fmt.Sprintf("dc-updated-%s", acctest.RandString(5)) | ||
|
||
const dc = "opentelekomcloud_direct_connect_v2.direct_connect" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { common.TestAccPreCheck(t) }, | ||
ProviderFactories: common.TestAccProviderFactories, | ||
CheckDestroy: testAccCheckDirectConnectV2Destroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDirectConnectV2Resource_basic(directConnectName), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(dc, "bandwidth", "50"), | ||
resource.TestCheckResourceAttrSet(dc, "id"), | ||
), | ||
}, | ||
{ | ||
Config: testAccDirectConnectV2ResourceUpdate_basic(directConnectNameUpdated), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(dc, "bandwidth", "100"), | ||
resource.TestCheckResourceAttrSet(dc, "id"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDirectConnectV2Resource_basic(directConnectName string) string { | ||
return fmt.Sprintf(` | ||
resource "opentelekomcloud_direct_connect_v2" "direct_connect" { | ||
name = "%s" | ||
port_type = "1G" | ||
location = "Biere" | ||
bandwidth = 50 | ||
provider_name = "OTC" | ||
} | ||
`, directConnectName) | ||
} | ||
|
||
func testAccDirectConnectV2ResourceUpdate_basic(directConnectName string) string { | ||
return fmt.Sprintf(` | ||
resource "opentelekomcloud_direct_connect_v2" "direct_connect" { | ||
name = "%s" | ||
port_type = "1G" | ||
location = "Biere" | ||
bandwidth = 100 | ||
provider_name = "OTC" | ||
} | ||
`, directConnectName) | ||
} | ||
|
||
func testAccCheckDirectConnectV2Destroy(s *terraform.State) error { | ||
config := common.TestAccProvider.Meta().(*cfg.Config) | ||
dcaasClient, err := config.DCaaSV2Client(env.OS_REGION_NAME) | ||
if err != nil { | ||
return fmt.Errorf("Error creating DCaaS client: %s", err) | ||
} | ||
|
||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "opentelekomcloud_direct_connect_v2" { | ||
continue | ||
} | ||
|
||
_, err := dcaas.Get(dcaasClient, rs.Primary.ID) | ||
if err == nil { | ||
return fmt.Errorf("DirectConnect still exists") | ||
} | ||
var errDefault404 golangsdk.ErrDefault404 | ||
if !errors.As(err, &errDefault404) { | ||
return err | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dcaas | ||
|
||
const ( | ||
errCreateClient = "error creating OpenTelekomCloud DCaaSv2 client: %w" | ||
keyClientV2 = "dcaas-v2-client" | ||
) |
Oops, something went wrong.