I'd like to share a more complete answer from Paul Howard based on work he is 
presenting at the next CloudStack Collab ( 
http://cloudstackcollabconference2014.sched.org/event/081a5eb4cbd3f3f48aea9f2d8d96ff47#.Ux79zD9_t8E
 ):

"I don't have experience of using the templatetag field itself, because this is 
a specialized field that is actually distinct from the general purpose tags 
that can be added to templates. I think it's just a straight string that can be 
used to match the template against tags on the hosts. It seems to be some kind 
of affinity system, allowing you to ensure that certain templates will always 
get deployed to certain hosts.

However, if you actually want to tag the template with general-purpose 
key/value pairs (as per our volume worker templates, for instance), then you 
actually want the createTags method, which you'd call separately after 
createTemplate():-

http://cloudstack.apache.org/docs/api/apidocs-4.2/user/createTags.html

(where the resourceid is your template ID, and the resource type is the 
hard-coded string "template"). The tags are then supplied as a hashtable. They 
end up in the HTTP request like this:-

   
tags[0].key=mykey1&tags[0].value=myvalue1&tags[1].key=mykey2&tags[1].value=myvalue2


> -----Original Message-----
> From: Rajesh Battala [mailto:[email protected]]
> Sent: 10 March 2014 11:31
> To: [email protected]
> Subject: RE: Sample of templatetag field from RegisterTemplate?
> 
> From the api command template tag will be read from json "templatetag="
> its string value.
> 
> Here is the cmd for updating a template key/value
> 
> http://10.102.192.186:8080/client/api?command=createTags&response=json
> &sessionkey=8%2BkoU3B23zkrfZtcZlrZ1noRuHc%3D&tags%5B0%5D.key=my
> key&tags%5B0%5D.value=myvalue&resourceIds=1a19d378-a83d-11e3-85ae-
> 8a4fc6ef9475&resourceType=Template&_=1394450761248
> 
> Thanks
> Rajesh Battala
> 
> 
> -----Original Message-----
> From: Donal Lafferty [mailto:[email protected]]
> Sent: Monday, March 10, 2014 4:25 PM
> To: [email protected]
> Subject: Sample of templatetag field from RegisterTemplate?
> 
> Does anyone have a sample of the templatetage field of RegisterTemplate?
> (see https://cloudstack.apache.org/docs/api/apidocs-
> 4.2/user/registerTemplate.html)
> 
> This string field should hold a key/value, but it's unclear whether the format
> is JSON or some other format.
> 
> DL

Reply via email to