Skip to content

Commit

Permalink
feat: Add resource cloudavenue_backup
Browse files Browse the repository at this point in the history
  • Loading branch information
David MICHENEAU committed Oct 6, 2023
1 parent 13aa297 commit 163db6e
Show file tree
Hide file tree
Showing 11 changed files with 487 additions and 171 deletions.
3 changes: 3 additions & 0 deletions .changelog/544.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
`resource/cloudavenue_backup` - New resource to manage NetBackup feature.
```
82 changes: 82 additions & 0 deletions docs/resources/backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
page_title: "cloudavenue_backup Resource - cloudavenue"
subcategory: "Backup"
description: |-
The cloudavenue_backup resource allows you to manage backup from NetBackup solution.
---

# cloudavenue_backup (Resource)

The `cloudavenue_backup` resource allows you to manage backup from NetBackup solution.

## Examples
### Example Usage of a VDC Backup with 2 policy sets
```hcl
resource "cloudavenue_backup" "example-vdc" {
type = "vdc"
target_name = cloudavenue_vdc.example.name
policies = [{
policy_name = "D6"
} ,{
policy_name = "M3"
}
]
}
```

### Example Usage of a VAPP Backup with a policy set
```hcl
resource "cloudavenue_backup" "example-vapp" {
type = "vapp"
target_name = cloudavenue_vapp.example.name
policies = [{
policy_name = "D6"
}]
}
```

### Example Usage of a VM Backup with a policy set
```hcl
resource "cloudavenue_backup" "example-vm" {
type = "vm"
target_name = "vmdemo"
policies = [{
policy_name = "D6"
}]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `policies` (Attributes Set) The backup policies of the target. Set must contain at least 1 elements. (see [below for nested schema](#nestedatt--policies))
- `type` (String) (ForceNew) Scope of the backup. Value must be one of : `vdc`, `vapp`, `vm`.

### Optional

- `target_id` (String) (ForceNew) The ID of the target. A target can be a VDC, a VApp or a VM. Ensure that one and only one attribute from this collection is set : `target_id`, `target_name`.
- `target_name` (String) (ForceNew) The name of the target. A target can be a VDC, a VApp or a VM. Ensure that one and only one attribute from this collection is set : `target_id`, `target_name`.

### Read-Only

- `id` (Number) The ID of the backup.

<a id="nestedatt--policies"></a>
### Nested Schema for `policies`

Required:

- `policy_name` (String) The name of the backup policy. D = Daily, W = Weekly, M = Monthly, X = Replication, The number is the retention period. Please refer to the documentation for more information. https://wiki.cloudavenue.orange-business.com/wiki/Sauvegarde. Value must be one of : `D6`, `D30`, `D30NQ`, `D60`, `W4`, `M3`, `M12`, `XD6`, `XD30`, `XD60`, `XW4`, `XM3`, `XM12`.

Read-Only:

- `policy_id` (Number) The ID of the backup policy.

## Import

Import is supported using the following syntax:
```shell
terraform import cloudavenue_backup.example type.targetName
```
1 change: 1 addition & 0 deletions examples/resources/cloudavenue_backup/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import cloudavenue_backup.example type.targetName
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ require (
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

replace github.com/orange-cloudavenue/netbackup-sdk-go => /Users/micheneaudavid/go/src/github.com/orange-cloudavenue/netbackup-sdk-go
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/orange-cloudavenue/infrapi-sdk-go v0.1.4-0.20231005074857-89878ea119fb h1:1/Wc21Tp9RnDOUTjKBm9x3wi+UgUkDc2bv0fHJc5f2o=
github.com/orange-cloudavenue/infrapi-sdk-go v0.1.4-0.20231005074857-89878ea119fb/go.mod h1:pGa9mB6s+weCi5QtNe5nicp7yL0C/e+i+3wHRh4cjBE=
github.com/orange-cloudavenue/netbackup-sdk-go v0.0.2-0.20230928095122-108fd1ec28ae h1:eOxAQKxWiC1iJzhhLW2bD4UCe55viWa0v3IejsbKjdE=
github.com/orange-cloudavenue/netbackup-sdk-go v0.0.2-0.20230928095122-108fd1ec28ae/go.mod h1:KaxPSw6c1JNm+F9YRydHVEhoNjIfrjadKl0BPhRLPvM=
github.com/peterhellberg/link v1.2.0 h1:UA5pg3Gp/E0F2WdX7GERiNrPQrM1K6CVJUUWfHa4t6c=
github.com/peterhellberg/link v1.2.0/go.mod h1:gYfAh+oJgQu2SrZHg5hROVRQe1ICoK0/HHJTcE0edxc=
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
Expand Down
6 changes: 3 additions & 3 deletions internal/client/netbackup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type NetBackup struct {
// NewNetBackup creates a new NetBackup client.
func (c *CloudAvenue) NewNetBackupClient() (err error) {
c.NetBackup.Client, err = netbackupclient.New(netbackupclient.Opts{
APIEndpoint: c.URL,
Username: c.User,
Password: c.Password,
APIEndpoint: c.NetBackup.URL,
Username: c.NetBackup.User,
Password: c.NetBackup.Password,
Debug: false,
})
if err != nil {
Expand Down
Loading

0 comments on commit 163db6e

Please sign in to comment.