VMware Cloud Community
jason_davis
Enthusiast
Enthusiast
Jump to solution

How to specify number of instances of a machine via REST API

I am using the following vRA Rest API's to provision a blueprint

template = Get  ("/catalog-service/api/consumer/entitledCatalogItems/" + catalogID + "/requests/template");

Post ("/catalog-service/api/consumer/entitledCatalogItems/" + entitledCatalogID + "/requests", template.ToString())

It works fine.

Now I am trying to specify the # of instances of a given machine within the template.

By default the number of instances is set to 1, like so:

{

  "type": "com.vmware.vcac.catalog.domain.request.CatalogItemProvisioningRequest",

  "catalogItemId": "2c79ed7e-30d7-4ff3-8d38-bb790d62b405",

  "requestedFor": "xyz",

  "businessGroupId": "6538a56e-9986-42c8-82d1-4a55f267654c",

  "description": null,

  "reasons": null,

  "data": {

....

    },

    "_leaseDays": 1,

   "_number_of_instances": 1

  }

If I change that to anything other than 1, I get the following error:

{ "errors": [ { "code": 20117, "source": null, "message": "The data specified within the request is invalid.", "systemMessage": "The data specified within the request is invalid.", "moreInfoUrl": null }, { "code": 11003, "source": null, "message": "The value of the '_number_of_instances' field cannot be more than 1.", "systemMessage": "The value of the field with id _number_of_instances cannot be more than 1.", "moreInfoUrl": null } ] }

even though my blueprint allows # of machines to be more than 1

Can the API support this capability?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
daphnissov
Immortal
Immortal
Jump to solution

You cannot set number of instances to zero if you have an object on the blueprint canvas, otherwise that object would essentially be null.

View solution in original post

0 Kudos
5 Replies
jason_davis
Enthusiast
Enthusiast
Jump to solution

So I found the answer in a different post:

VRA 7.1 What is the JSON content to request multiple instances in a deployment

Now, I am going to be greedy.  Is there any way to set the # of instances of a machine to ZERO?  I have blueprints with multiple machine types.  In order to save resource, I would like the ability programmatically to set ZERO for certain machines if requested by my user.  So far I cannot seem to set _cluster = 0.

I get this error:

<The value of the '_cluster' field cannot be less than 1>

If anyone has a suggestion how to do this, it would be appreciated.

0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

You cannot set number of instances to zero if you have an object on the blueprint canvas, otherwise that object would essentially be null.

0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

Hi Daphnissov,

Thanks for clarifying. 

I have a blueprint with over 20 different machine types,  and I was hoping there could be some workaround to disable some machines from being created when they are not needed by the requesting user.  I guess the best I can do is to turn the machine off and/or destroy it via vCenter API after it gets created.  That will free up some resource.

Cheers,

Jason

0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

I think there are better ways to go about achieving what I believe your goal is, but they all don't include having 20 different machines types in one blueprint. I don't know what you're trying to do here, but you'll want to apply some sort of logic-based selection (wherever that needs to be) which choose the right blueprint for the right condition. If that's in an external CI tool then great.

0 Kudos
jason_davis
Enthusiast
Enthusiast
Jump to solution

We are creating virtual 'labs' where test teams can collaborate on a common testing mission.   The machines within the deployment are connected and may interact with each other.

Some test missions are large which require a full deployment of machines, and others are more narrow and focussed.

I don't want to create a different blueprint type for each size test lab.  So I plan to create a FULL lab, but allow users to make smaller labs when needed to save space in the data center.

In any case I think there are some options, so we can make it work.

Thanks again for the feedback

0 Kudos