Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Call a vRA Resource Actions on a provisioned resource #26

Closed
Marcvd316 opened this issue Dec 7, 2017 · 30 comments
Closed

Call a vRA Resource Actions on a provisioned resource #26

Marcvd316 opened this issue Dec 7, 2017 · 30 comments

Comments

@Marcvd316
Copy link

I think this could be a great functionality to have.

An example use case is that I create a VM and once it is created, I then run a Resource Action on it.

Maybe this could be implemented in the form of a Terraform Provisioner of type "null_resource"?
https://www.terraform.io/docs/provisioners/null_resource.html

@Marcvd316 Marcvd316 changed the title Discussion : Shoud the plugin allow us to call vRA Resource Actions on a provisioned resource? Call a vRA Resource Actions on a provisioned resource? Dec 7, 2017
@Marcvd316 Marcvd316 changed the title Call a vRA Resource Actions on a provisioned resource? Call a vRA Resource Actions on a provisioned resource Dec 7, 2017
@cars
Copy link
Contributor

cars commented Dec 7, 2017

I've been kind of wondering about this too, and about how this would be represented in Terraform esp wrt to #23 . It looks like there's some thought about this in the code... but it's not clear to me whether it's intended to be a general purpose way to call actions (much less how it's actually activated) or specifically just destroy and poweroff. https://github.com/vmware/terraform-provider-vra7/blob/083b54e79ab4c84022eb3b36f1d528beb5768420/vrealize/actions.go#L7-L20

I'm not familiar enough with Terraform to know if any other providers have a similar idea of actions and/or how they're referenced/presented?

@Marcvd316
Copy link
Author

I did a bit of research already and didn't find much, every object for other providers (AWS/Azure/Others) are represented by a Resource Type. However a vRA Resource Action seems more like a one time execution kind of thing that we might/might now want to track in the tfstate file and that fits much better into the mold of a Terraform Provisioner.

image

This seems to be a good fit for Resource Actions in my opinion.

@Marcvd316
Copy link
Author

Hi,

Would anyone happen to have made progress on this?
I'm finding more and more use cases for this feature, would be great to have it.

Thanks to all

@cars
Copy link
Contributor

cars commented Feb 26, 2018

I haven't really looked at doing any work around this but wonder if maybe provisioners aren't the right approach since it looks like they're invoked at creation or destruction of the resource? I think it'd be better if you were able to call the action at any/some point during the lifecycle of the resource. This might entail a new resource type that would maybe leverage depends_on or be targeted at a deployed vRA resource.
so you'd see something like:

resource "vra7_resource" "apache01" {
  count            = 1
  catalog_name = "CentOS 7.0 x64"
  resource_configuration = {
    Linux.cpu = "2"
  }
}

resource "vra7_action" "poweroff_apache01" {
deployment = "vra7_resource.apache01" 
action = "poweroff"
action_configuration = {
  description = "PowerOff for snapshot"
 reasons = "Snapshot"
   } 
}

A quick look at the code makes it seem like this isn't a trivial undertaking since actions (esp custom ones might be complicated)?

@Marcvd316
Copy link
Author

Hey Carlos, what you're suggesting makes sense. Maybe it could be simpified if running the resource action could be completely detached from a resource and in the action's configuration block, you would specify the action name and the resource type and resource name you want to run it on. That way you could potentially run actions on items that are provisioned outside of the current TF deployment.

@afurlani24
Copy link

Hello,
Has anyone figured out how call a vRA Resource Actions on a provisioned resource? Looking to add cpu to already provisioned resource?
Thanks,
Tony

@virajindasrao
Copy link
Contributor

virajindasrao commented Mar 29, 2018

@afurlani24 I have created a PR-27 which is under review now. It has same feature extension what you are expecting.
If you are looking for the resource update feature which is not provisioned using terraform then I am working on import infra feature to fetch existing resources in terraform. Will update you shortly on the same.

@afurlani24
Copy link

Thank You!

@Marcvd316
Copy link
Author

That's awesome Viraj, thanks! Would you be able to show an example of code that calls a resource action?

@virajindasrao
Copy link
Contributor

@Marcvd316 Simply update the values of resource_configuration schema and it will update the deployment accordingly. No need to add any extra action parameter.

@afurlani24
Copy link

Viraj,
There looks like there are no reviewers assigned for your pull request? Do you know how long that will take?
Thanks!

@VincenzoDo
Copy link

Hello,

I'm also very interested in this feature, would this also allow the update of storage to say extend the disk for a VM?

Thank you,

Vincenzo

@afurlani24
Copy link

@markpeek Hello do you know when you will be able to review PR-27? Excited to be able to start using these features.
Thanks,
Tony

@afurlani24
Copy link

@virajindasrao Any update on this been sitting in Review for a long time?

Thanks,
Tony

@afurlani24
Copy link

@virajindasrao Hello will be able to use this anytime soon? Thanks

@virajindasrao
Copy link
Contributor

@afurlani24 PR is under review right now. It will probably get merged by EOW or earlier next week.

@afurlani24
Copy link

@virajindasrao So is this feature completed now? I noticed the PR was merged.
Thanks,
Tony

@afurlani24
Copy link

@virajindasrao Hello should this be now working? I have provisioned a server using terraform then went in and change CPU count from 2 to 4 and says it changed however when I go out to vRA it still says 2 CPU.. is there something that I missing here? Thanks for your help!

@virajindasrao
Copy link
Contributor

@afurlani24 Did you see any request placed on vRA against the CPU update?

@afurlani24
Copy link

@virajindasrao Hello so had to place the binary in that Roaming folder under plugins so that it would work however now when I run my apply it kicks off the build in vRA and the build actually finishes in vRA but the command line throws an error.. so if I try and run a Plan again thinks it is not finished. When I used to run an apply it would say created pretty quickly and return the command prompt now it gives me the Still creating messages..
vra7_resource.Linux: Still creating... (14m0s elapsed)
vra7_resource.Linux: Still creating... (14m10s elapsed)
vra7_resource.Linux: Still creating... (14m20s elapsed)
vra7_resource.Linux: Still creating... (14m30s elapsed)
vra7_resource.Linux: Still creating... (14m40s elapsed)
vra7_resource.Linux: Still creating... (14m50s elapsed)
vra7_resource.Linux: Still creating... (15m0s elapsed)
vra7_resource.Linux: Still creating... (15m10s elapsed)
Error applying plan:

1 error(s) occurred:

  • vra7_resource.Linux: 1 error(s) occurred:

  • vra7_resource.Linux: resource is still being created

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

C:\terraformvra>terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

vra7_resource.Linux: Refreshing state... (ID: c548882e-7a1c-43c1-a120-bd005401c945)
Error refreshing state: 1 error(s) occurred:

  • vra7_resource.Linux: 1 error(s) occurred:

  • vra7_resource.Linux: vra7_resource.Linux: resource is not yet ready to show up

C:\terraformvra>

@afurlani24
Copy link

@virajindasrao Seems to always fail at the 15m10s mark so something timing out?
vra7_resource.Linux: Still creating... (15m10s elapsed)
Error applying plan:

1 error(s) occurred:

  • vra7_resource.Linux: 1 error(s) occurred:

  • vra7_resource.Linux: resource is still being created

@afurlani24
Copy link

@virajindasrao I also added the wait_timeout and put it too 120 and it goes that long that fails..

@virajindasrao
Copy link
Contributor

@afurlani24 What do you see on vRA request tab? Is provisioning went through for the same request which is failed after 120 mins?
If the request got failed in vRA then kindly let me know the details of it.
Thanks.

@afurlani24
Copy link

@virajindasrao The requests always complete successfully on the vRA side regardless of the wait_timeout however I am never getting my terraform command line back it just keeps saying vra7_resource.Linux: Still creating... until it reaches the timeout set. I am never getting the creation complete message that I have always gotten "vra7_resource.RHEL_7_Full_Support: Creation complete (ID: 504686b1-83e3-4a14-aebc-a83cb4706137)

@virajindasrao
Copy link
Contributor

virajindasrao commented Jul 24, 2018

@afurlani24 I tried and it went through for me.
I am assuming that you are creating two resources and one is working fine, but second.
I don't see any issue in plugin flow. I will try a few corner cases and let you know.
I am closing this issue for now.

@afurlani24
Copy link

@virajindasrao No I am only creating one resource and the server builds in vRA but the command line never comes back and says Creation Complete it goes on until it reaches the timeout. So even when the server is done in vRA the terraform command line keeps going and does not think the build is done. Never had this problem before until downloaded new plugin. I will keep testing. Thanks

@virajindasrao
Copy link
Contributor

virajindasrao commented Jul 24, 2018

Thanks for the updates @afurlani24
May I know the specifications of blueprint you are using right now?

@afurlani24
Copy link

@virajindasrao Here is my config..
resource "vra7_resource" "Linux" {
catalog_name = "RHEL 7 Full-Support"
resource_configuration {
RHEL_7_Full_Support.Optum.Environment = "PROD"
RHEL_7_Full_Support.Optum.Network.Zone = "intranet"
RHEL_7_Full_Support.Optum.Interface.Zone = "Intranet"
RHEL_7_Full_Support.Optum.Server.Type = "APP"
RHEL_7_Full_Support.Optum.DataCenter = "CTC"
RHEL_7_Full_Support.Optum.ResilienceZone = "None"
RHEL_7_Full_Support.Optum.ReservationPolicyName = ""
RHEL_7_Full_Support.Optum.AskID = "UHGWM110-018404"
RHEL_7_Full_Support.Optum.DR.code = "DR-101"
RHEL_7_Full_Support.Optum.UnixID.Search = "ID"
RHEL_7_Full_Support.Optum.UnixID.SearchResult = "ID"
RHEL_7_Full_Support.cpu = "2"
RHEL_7_Full_Support.memory = "4096"
RHEL_7_Full_Support.VirtualMachine.Disk1="105"
}
count = 1
wait_timeout = 120
catalog_configuration {
Optum.rules.use.agreement = "yes"
lease_days = ""
}

@afurlani24
Copy link

@virajindasrao I just ran one now and the server is complete in vRA and successful however my command line is still going..
image

@afurlani24
Copy link

@Marcvd316 Have you used the new plugin without any issues?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants