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 source_file to incus_storage_volume #159

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

SpiffyEight77
Copy link
Contributor

@SpiffyEight77 SpiffyEight77 commented Nov 12, 2024

Description

Close #126

Add source_file to incus_storage_volume

  • source code
  • document
  • test case

Testing

Export the backup volume

root@playground:~/backup# incus storage volume list mypool
+--------+----------+-------------+--------------+---------+
|  TYPE  |   NAME   | DESCRIPTION | CONTENT-TYPE | USED BY |
+--------+----------+-------------+--------------+---------+
| custom | myvolume |             | filesystem   | 0       |
+--------+----------+-------------+--------------+---------+

root@playground:~/backup# incus storage volume export mypool myvolume
Backup exported successfully!
root@playground:~/backup# ls
backup.tar.gz

Import the backup volume by terraform with source_file argument

root@playground:~/terraform-incus# terraform apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - lxc/incus in /root/terraform-provider-incus
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the
│ state to become incompatible with published releases.
╵
incus_storage_pool.pool1: Refreshing state... [name=mypool]
incus_storage_volume.volume1: Refreshing state... [name=myvolume]
incus_storage_volume.volume1_copy: Refreshing state... [name=myvolume_copy]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
  + create

Terraform will perform the following actions:

  # incus_storage_volume.volume_from_backup will be created
  + resource "incus_storage_volume" "volume_from_backup" {
      + config       = {}
      + content_type = "filesystem"
      + description  = ""
      + location     = (known after apply)
      + name         = "restored-volume"
      + pool         = "mypool"
      + source_file  = "/root/backup/backup.tar.gz"
      + target       = (known after apply)
      + type         = "custom"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

root@playground:~/backup# incus storage volume list mypool
+--------+-----------------+-------------+--------------+---------+
|  TYPE  |      NAME       | DESCRIPTION | CONTENT-TYPE | USED BY |
+--------+-----------------+-------------+--------------+---------+
| custom | myvolume        |             | filesystem   | 0       |
+--------+-----------------+-------------+--------------+---------+
| custom | restored-volume |             | filesystem   | 0       |
+--------+-----------------+-------------+--------------+---------+

@SpiffyEight77 SpiffyEight77 changed the title Add source_file resource to incus_storage_volume Add source_file to incus_storage_volume Nov 12, 2024
@SpiffyEight77 SpiffyEight77 force-pushed the feat/import-storage-volume branch 4 times, most recently from 676c66a to 921774e Compare November 19, 2024 15:03
@SpiffyEight77
Copy link
Contributor Author

I'm sorry, but I currently don't have a solution for creating a backup volume for testacc. As a result, I will temporarily skip the TestAccStorageVolume_sourceFile test.

@SpiffyEight77 SpiffyEight77 marked this pull request as ready for review November 19, 2024 15:13
@stgraber
Copy link
Member

@SpiffyEight77 can you have the test do something like this as a prep step:

  • incus storage volume create default test_volume_create
  • incus storage volume export default test_volume_create
  • incus storage volume delete default test_volume_create

The second command should give you a backup.tar.gz that's suitable for importing.

@stgraber stgraber merged commit 5118735 into lxc:main Nov 22, 2024
10 checks passed
@SpiffyEight77 SpiffyEight77 deleted the feat/import-storage-volume branch November 22, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add source_file to incus_storage_volume
3 participants