VMware Cloud Community
pizzle85
Expert
Expert
Jump to solution

Provision VM from ASD

I have set up an ASD service blueprint to clone off a template. The vRO workflow uses the vCenter clone workflow to clone the machine. Im not able to select the existing IaaS VC:VritualMachine mapping as the provisioned resouce. I was able to create a new custom resource for the VC:VirtualMahcine type and use the as the provisioned object. However because its a different object i no longer get any of the default resource actions and when i write new ASD resource actions i have to create two, one for each object type. These are the same vRO object types, is there a way to just use one so all my resource actions work for each of them?

0 Kudos
1 Solution

Accepted Solutions
sbeaver
Leadership
Leadership
Jump to solution

I think I am doing something along the lines that you are looking for.  During the BuildingStub Workflow I have alot of processing going on and one of the processes is to make the choice of what template to use. Below you will find the code from part of the process that selects the template to use.

Now with that said it sounds like the templates are not going to be static in nature with your users able to create their own templates dynamically.  I found an action called "getAllTemplateConfigFile" that you might be able to use to get all the templates.

Here is part of my code that selects the template...

var entity = virtualMachineEntity

var virtualMachine = virtualMachineEntity.getInventoryObject();

if (virtualMachine == null)

{

    throw "The virtual machine ID is invalid";

}

var MachineProperties = new Properties();

var virtualMachinePropertyEntities = virtualMachineEntity.getLink(vCACHost, "VirtualMachineProperties");

for each (var virtualMachinePropertyEntity in virtualMachinePropertyEntities)

{

  var propertyName = virtualMachinePropertyEntity.getProperty("PropertyName");

  var propertyValue = virtualMachinePropertyEntity.getProperty("PropertyValue");

  MachineProperties.put(propertyName, propertyValue);

  if (propertyName == "operating.system.selection") {

  var os = MachineProperties.get("operating.system.selection");

  System.log("Found this Operating System: " +os)};

  if (propertyName == "Server.Function") {;

  var NameFunc = MachineProperties.get("Server.Function");

  System.log("Found this Server Function: " +NameFunc)};

  if (propertyName == "VirtualMachine.Network.Environment") {;

  var NetEnv = MachineProperties.get("VirtualMachine.Network.Environment")

  var NetEnv = NetEnv.replace(/-.*/g, "");

  System.log("Found this network environment: " +NetEnv)};

  if (propertyName == "os.type") {;

  var osType = MachineProperties.get("os.type");

  System.log("Found this OS type: " +osType)};

  if (propertyName == "VirtualMachine.Network0.DnsSuffix") {;

  var domain = MachineProperties.get("VirtualMachine.Network0.DnsSuffix");

  System.log("Found this DNS Domain: " +domain)};

  if (propertyName == "VirtualMachine.Memory.Size") {;

  var memory = MachineProperties.get("VirtualMachine.Memory.Size");

  System.log("Found this amount of memory: " +memory)};

  if (propertyName == "VirtualMachine.Disk0.Size") {;

  var disksize = MachineProperties.get("VirtualMachine.Disk0.Size");

  System.log("Found this disk size: " +disksize)};

  if (propertyName == "VirtualMachine.CPU.Count") {;

  var cpu = MachineProperties.get("VirtualMachine.CPU.Count");

  System.log("Number of CPU's: " +cpu)};

}

var ouos

if (os == "Red Hat Enterprise 6.5" || os == "Red Hat Enterprise 6.5 Lease"){

  template = "rh6u5x64-70gb"

  ouos = "Red Hat"}

if (os == "Red Hat Enterprise 6.4" || os == "Red Hat Enterprise 6.4 Lease"){

  template = "rh6u4x64-70gb"

  ouos = "Red Hat"}

if (os == "Red Hat Enterprise 6.2" || os == "Red Hat Enterprise 6.2 Lease"){

  template = "rh6u2x64-70gb"

  ouos = "Red Hat"}

if (os == "Red Hat Enterprise 5.8" || os == "Red Hat Enterprise 5.8 Lease"){

  template = "rh5u8x64-70gb"

  ouos = "Red Hat"}

if (os == "Windows 2008 R2 Standard" || os == "Windows 2008 R2 Standard Lease"){

  template = "WIN2K8R2-STD-SP1-AXIOM"

  ouos = "Servers 2008"}

if (os == "Windows 2008 R2 Enterprise" || os == "Windows 2008 R2 Enterprise Lease"){

  template = "WIN2K8R2-ENT-SP1-AXIOM"

  ouos = "Servers 2008"}

if (os == "Windows 2012 Standard" || os == "Windows 2012 Standard Lease"){

  template = "WIN2K12-STD-AXIOM"

  ouos = "Servers 2012"}

if (os == "Windows 2012 R2 Standard" || os == "Windows 2012 R2 Standard Lease"){

  template = "WIN2K12R2-STD-AXIOM"

  ouos = "Servers 2012"}

System.log("Template to use: " +template)

var virtualMachinePropertiesEntities = virtualMachineEntity.getLink(vCACHost, "VirtualMachineProperties");

var model = "ManagementModelEntities.svc";

var entitySet = "VirtualMachineProperties";

var virtualMachineProperties = new Properties();

var links = new Properties();

links.put("VirtualMachineProperties",virtualMachineEntity); //The property needs to link back to the blueprint

var entityKey = virtualMachinePropertyEntity.entityKey;

var entityKeyId = entityKey.get("Id");

var vmprops = new Properties();

vmprops =

{

  PropertyName : "CloneFrom",

  PropertyValue : template,

};

var templateEntity = vCACEntityManager.updateModelEntityBySerializedKey(vCACHost.id , model , entitySet , entityKeyId , vmprops, links)

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**

View solution in original post

0 Kudos
12 Replies
SeanKohler
Expert
Expert
Jump to solution

So all of this is just my two cents... most of the time I am only partially right, and some of the time I am mostly right.

I am curious why you are not using ASD to provision an actual machine resource (through a machine blueprint catalog request)?

You are kind of reinventing the wheel with this process.  It is cool, but the work of creating a machine resource is already done for you in vRA.  In my opinion, it makes better sense to use ASD as a dynamic form provider for your Request Process into the vRA catalog service request.

As I understand it, the machine resource actions that exist in vRA are for that "Type" of resource.  Since you created a custom resource type, only actions you build relative to that custom type (then entitled) would be useable.  You wouldn't get the builtin actions for the machine-based catalog resource type by nature of the apps design. You also will not get lifecycle management (lease), costs, machine custom properties, reservation management, etc.  Though, I do wish we had a way to be able to add at least LEASE and COST  in a meaningful way to ANY custom resource, and if we did... then you would be closer to what appears to be your goal of bypassing IaaS side of vRA entirely.

If you are doing these actions for learning purposes... awesome.  But, I think you shouldn't lightly throw away the benefits that you get out of vRA (base) to use a self-implemented process.  vRA builds machines and manages their lifecycle very effectively: so that you don't have to.  Create dynamic forms in ASD that call vRA machine blueprints (via REST or though plugin extensions).  I think you will have better success with that approach.

0 Kudos
pizzle85
Expert
Expert
Jump to solution

So, we provide a hosting service for everyone in my university. Customers wanted the ability to Clone a deployed VM to a template then clone a VM from those templates. In IaaS i couldnt find a clean way to dynamically choose the template being deployed by the blueprint, i would have to create a blueprint for each customers template they want to deploy and entitle it to them. When a hosting customer deploys a VM through vRA its put into their own vCenter folder. I wrote some vRO actions that will get the vRA business group custom property for vCenter Folder that then gets all the Templates from that folder and present them in a drop down box in the ASD form. This gives them the flexibility to clone and re-clone to their hearts content and prevents me from having to build and manage hundreds of blueprints.

If i could find a clean way to modify the template being used by the blueprint during the IaaS Building phase i would definitely use that instead. I went down that road and ultimately failed so i took this approach.

0 Kudos
SeanKohler
Expert
Expert
Jump to solution

That is an interesting challenge.

So you give your customer the ability to create templates... can you not give them the Business Group manager Role so they can then create a blueprint off the template? Which they can then publish as part of a service in the Business group and request that way.  Effectively... you provide some blueprints (core or base) and allow them to extend that with their own blueprints off their own templates (built from the core blueprints you manage).  They are already managing a bunch of templates and could just attach a blueprint on top of them and manage both the template and the blueprint themselves.  Just a thought you have probably already considered, but perhaps not.

>>modify the template being used by the blueprint during the IaaS Building phase

Yeah.  I am with you here in general.  Tying the blueprints one-to-one to a vm template for cloning makes things less flexible by way of blueprint sprawl.  Another option you might have is to provide them a way to "create a vm template and blueprint."  Basically automate your blueprint creation to a template that they just created.  You could do this leveraging a service account that has the BGM role, and it would be published/entitled to users with the SU role.  I am not near a system right now, and I am not certain that this is entirely possible, but it might be worth looking into.  Basically, I can see why you ran into issues while trying to find a runtime (build) mechanism to select a template... but it is probable that you would be able to select a template during automated blueprint creation. (not runtime)

This equals blueprint sprawl... but you are already allowing the backend action of template sprawl by allowing the customers to leverage self-saved templates that are not automated (software) builds off golden images.  I hope you would agree that the defined operational practices are generating sprawl to some extent. 1 blueprint on 100 templates... 100 blueprints on 100 templates.  Either way you still have 100 templates  Smiley Happy.

0 Kudos
sbeaver
Leadership
Leadership
Jump to solution

I think I am doing something along the lines that you are looking for.  During the BuildingStub Workflow I have alot of processing going on and one of the processes is to make the choice of what template to use. Below you will find the code from part of the process that selects the template to use.

Now with that said it sounds like the templates are not going to be static in nature with your users able to create their own templates dynamically.  I found an action called "getAllTemplateConfigFile" that you might be able to use to get all the templates.

Here is part of my code that selects the template...

var entity = virtualMachineEntity

var virtualMachine = virtualMachineEntity.getInventoryObject();

if (virtualMachine == null)

{

    throw "The virtual machine ID is invalid";

}

var MachineProperties = new Properties();

var virtualMachinePropertyEntities = virtualMachineEntity.getLink(vCACHost, "VirtualMachineProperties");

for each (var virtualMachinePropertyEntity in virtualMachinePropertyEntities)

{

  var propertyName = virtualMachinePropertyEntity.getProperty("PropertyName");

  var propertyValue = virtualMachinePropertyEntity.getProperty("PropertyValue");

  MachineProperties.put(propertyName, propertyValue);

  if (propertyName == "operating.system.selection") {

  var os = MachineProperties.get("operating.system.selection");

  System.log("Found this Operating System: " +os)};

  if (propertyName == "Server.Function") {;

  var NameFunc = MachineProperties.get("Server.Function");

  System.log("Found this Server Function: " +NameFunc)};

  if (propertyName == "VirtualMachine.Network.Environment") {;

  var NetEnv = MachineProperties.get("VirtualMachine.Network.Environment")

  var NetEnv = NetEnv.replace(/-.*/g, "");

  System.log("Found this network environment: " +NetEnv)};

  if (propertyName == "os.type") {;

  var osType = MachineProperties.get("os.type");

  System.log("Found this OS type: " +osType)};

  if (propertyName == "VirtualMachine.Network0.DnsSuffix") {;

  var domain = MachineProperties.get("VirtualMachine.Network0.DnsSuffix");

  System.log("Found this DNS Domain: " +domain)};

  if (propertyName == "VirtualMachine.Memory.Size") {;

  var memory = MachineProperties.get("VirtualMachine.Memory.Size");

  System.log("Found this amount of memory: " +memory)};

  if (propertyName == "VirtualMachine.Disk0.Size") {;

  var disksize = MachineProperties.get("VirtualMachine.Disk0.Size");

  System.log("Found this disk size: " +disksize)};

  if (propertyName == "VirtualMachine.CPU.Count") {;

  var cpu = MachineProperties.get("VirtualMachine.CPU.Count");

  System.log("Number of CPU's: " +cpu)};

}

var ouos

if (os == "Red Hat Enterprise 6.5" || os == "Red Hat Enterprise 6.5 Lease"){

  template = "rh6u5x64-70gb"

  ouos = "Red Hat"}

if (os == "Red Hat Enterprise 6.4" || os == "Red Hat Enterprise 6.4 Lease"){

  template = "rh6u4x64-70gb"

  ouos = "Red Hat"}

if (os == "Red Hat Enterprise 6.2" || os == "Red Hat Enterprise 6.2 Lease"){

  template = "rh6u2x64-70gb"

  ouos = "Red Hat"}

if (os == "Red Hat Enterprise 5.8" || os == "Red Hat Enterprise 5.8 Lease"){

  template = "rh5u8x64-70gb"

  ouos = "Red Hat"}

if (os == "Windows 2008 R2 Standard" || os == "Windows 2008 R2 Standard Lease"){

  template = "WIN2K8R2-STD-SP1-AXIOM"

  ouos = "Servers 2008"}

if (os == "Windows 2008 R2 Enterprise" || os == "Windows 2008 R2 Enterprise Lease"){

  template = "WIN2K8R2-ENT-SP1-AXIOM"

  ouos = "Servers 2008"}

if (os == "Windows 2012 Standard" || os == "Windows 2012 Standard Lease"){

  template = "WIN2K12-STD-AXIOM"

  ouos = "Servers 2012"}

if (os == "Windows 2012 R2 Standard" || os == "Windows 2012 R2 Standard Lease"){

  template = "WIN2K12R2-STD-AXIOM"

  ouos = "Servers 2012"}

System.log("Template to use: " +template)

var virtualMachinePropertiesEntities = virtualMachineEntity.getLink(vCACHost, "VirtualMachineProperties");

var model = "ManagementModelEntities.svc";

var entitySet = "VirtualMachineProperties";

var virtualMachineProperties = new Properties();

var links = new Properties();

links.put("VirtualMachineProperties",virtualMachineEntity); //The property needs to link back to the blueprint

var entityKey = virtualMachinePropertyEntity.entityKey;

var entityKeyId = entityKey.get("Id");

var vmprops = new Properties();

vmprops =

{

  PropertyName : "CloneFrom",

  PropertyValue : template,

};

var templateEntity = vCACEntityManager.updateModelEntityBySerializedKey(vCACHost.id , model , entitySet , entityKeyId , vmprops, links)

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
pizzle85
Expert
Expert
Jump to solution

No, one has the business group manager role. We have a single tenant with hundreds of business groups. We are the only ones who manage blueprints as customers would destroy our existing blueprints. Im ok with template sprawl because i don't see them, have to touch them or manage them. The customers pay for the resources they consume, so if they want to have 100 templates IDC. Its all a self contained self service structure that we don't have to worry about, the users have full control and pay for what they do.

0 Kudos
pizzle85
Expert
Expert
Jump to solution

sbeaver, could you explain what you're actually doing in that script? It looks like the part of it that's determining which template to use during the IaaS deployment is populating the vCAC VM Entity VirtualMachineProperty.clonefrom property with the appropriate template name. Is that correct?

0 Kudos
SeanKohler
Expert
Expert
Jump to solution

>>>We are the only ones who manage blueprints as customers would destroy our existing blueprints.


AFAIK, this isn't true.  Blueprints that are built at the tenant level cannot be modified by business group managers. Business group managers can leverage shared blueprints, and they can create their own based off of machine templates. That is within the nature of the tool.


Still, not specifically saying that you should do this. I'm just trying to give you some alternative options that you might consider. I think Steve's approach is also a good one. I need to try that as well because there is certainly value in selecting a template during build.


As far as your initial question goes....


I am pretty sure you will not be able to get the default actions on your custom resource type as the product stands now. I would definitely be interested in hearing how you get around these challenges and the approaches that you take.


It is very interesting to hear how other people are leveraging the product.


0 Kudos
sbeaver
Leadership
Leadership
Jump to solution

Yes that is correct, based on some of the answers that were given in the form, in this case the Operating System selection, the logic will return the correct template (cloneFrom) to use.  All my logic processing is done during the building stub which other things like determining the servername, select the template, select with OU to add the server to. determine which domain to join by selecting which custom spec to use and select which service account to use based on the domain that it is to join

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
pizzle85
Expert
Expert
Jump to solution

So i ended up creating an ASD Service Blueprint very similar to my existing one that just calls a vRA catalog item that uses a blueprint that clones a template. I used this post to get the catalog items visible to deploy from:

Re: Use Case Failures - Support Request

and this post to figure out how to call the vRA catalog item from vRO:

How to use and extend the workflow "Request a catalog item" from the vCAC plug-in for vCO

During the workflow i go and fetch the reservation policy and storage reservation policy to place it in the correct vCenter, DRS Cluster, and Storage.

I used your code above to select the template to clone from.

It appears to be working.

sbeaver
Leadership
Leadership
Jump to solution

Now, want to have some fun?  Take the code that you are using and create an action where it takes your inputs and then returns the template that you want.  Create an Input in your VCO workflow called template or something.  Go to the Presentation tab for that workflow and select the template input.  You will have two tabs at the bottom called General and Properties.  In the Properties tab you have the choice to add properties.  Select and add "Predefined Answers" on the far right of the value area there is a button to help create action call.  Select that and choice the action that you created earlier and now once the user has selected the proper inputs the template input should be automatically populated.  Can actually have a choice to do this from vRO presentation or in the vCAC ASD form designer.

I am not quite sure if anyone has pointed this technique out to you and in case you had not seen or knew you could do this, I wanted to share because the presentation tab is where you have a great deal of power to do some really cool things.

Cheers

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
pizzle85
Expert
Expert
Jump to solution

All customer vms get created in a vcenter folder that matches the group name. I have an existing action that fetched the templates using the group name and displays them as an array of string in a drop down list in my asd service bluepprint.

0 Kudos
sbeaver
Leadership
Leadership
Jump to solution

Sweet!

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos