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

template: volatile disk #115

Closed
Yenya opened this issue Apr 24, 2021 · 4 comments · Fixed by #155
Closed

template: volatile disk #115

Yenya opened this issue Apr 24, 2021 · 4 comments · Fixed by #155

Comments

@Yenya
Copy link
Contributor

Yenya commented Apr 24, 2021

Hello,

is there any way how to specify a volatile disk in the template?

For a template created with Sunstone, I use the following template section to specify 2GB swap as a volatile disk:

DISK = [
  FORMAT = "raw",
  SIZE = "2048",
  TYPE = "swap" ]

Is it possible to do the same in the terraform provider? If so, how? I tried guessing:

resource "opennebula_template" "mytemplate" {
   ...
   disk {
      format = "raw"
      type = "swap"
      size = 2048
   }
   ...
}

But it did not work (An argument named "type" is not expected here.).

@jaypif
Copy link
Collaborator

jaypif commented Apr 26, 2021

Hi @Yenya

Disk in VM or templates are OpenNebula Images.
Adding a disk in a template or a VM suppose the Image already exist.

In your case you have to create the swap Image before using it in your VM template.

Disk are not created automatically by the template resource for the moment.

Best regards

@Yenya
Copy link
Contributor Author

Yenya commented Apr 26, 2021

@jaypif - thanks for your reply.

In fact, not all disks in OpenNebula VM or template are OpenNebula images. Volatile disks are not images living in an existing datastore. They are defined in the template (or a VM), and created on the fly during the template instantiation (or during Deploy of a previously undeployed VM). They get destroyed during Undeploy or a VM destruction. They do not have image ID nor datastore ID. They can have type (e.g "swap"), and OpenNebula initializes them accordingly before handing them to the VM, and contextualization scripts then can directly use them (e.g. enabling swapping on them) without any further configuration inside the VM. They usually live on a physical disk of the physical host machine.

So, what would be needed is to recognize that a particular DISK = [ ] section in OpenNebula template refers to a volatile disk instead of an image with ID and datastore ID, and keep this part untouched (including the type = "..." section).

Could this please be supported in future versions of Terraform provider? Thanks!

-Yenya

@Yenya
Copy link
Contributor Author

Yenya commented Apr 26, 2021

It is possible to try volatile disks in base opennebula the following way: have a running VM, preferably Linux with the contextualization package (https://github.com/OpenNebula/addon-context-linux) installed. Then run the following:

$ cat <<EOF > volatile_disk.txt
DISK = [
  FORMAT = "raw",
  SIZE = "2048",
  TYPE = "swap" ]
EOF
$ onevm disk-attach <vmid> --file volatile_disk.txt
$ onevm show <vmid>
[...]
VM DISKS                                                                        
 ID DATASTORE  TARGET IMAGE                               SIZE      TYPE SAVE
  2 system     sda    2G                                  -/2G      swap   NO
[...]

After that, you should be able to log into the VM and see the new swap space being enabled automatically.

It would be nice if the Terraform provider can support this as well. Thanks,

-Yenya

@jaypif
Copy link
Collaborator

jaypif commented Apr 26, 2021

Hi @Yenya

OK thanks, We never though about that becauase we do not use this feature.

We can think about adding this feature in the provider in a future release.
I can't give you an ETA as we develop the provider when we have some bandwidth.

Regards

@jaypif jaypif added this to the 0.4.0 milestone Apr 26, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 20, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 20, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 20, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 20, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 20, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Sep 24, 2021
@treywelsh treywelsh linked a pull request Sep 28, 2021 that will close this issue
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 12, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 12, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 12, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 12, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 25, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 25, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 25, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 25, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Oct 25, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 16, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 16, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 16, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 16, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 16, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 19, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 19, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 19, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 19, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 19, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 30, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 30, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 30, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Nov 30, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit to treywelsh/terraform-provider-opennebula that referenced this issue Dec 2, 2021
treywelsh added a commit that referenced this issue Dec 2, 2021
treywelsh added a commit that referenced this issue Dec 2, 2021
treywelsh added a commit that referenced this issue Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants