template-update: define an update method in API.md document

Define an PUT method for template update

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
template-update: resouce support update method

add PUT method for Resouce class
implement update attribute for sub-class Template

We need a common of update method.
We should also support edit the name of resource.
If we edit the name of resource, we had better raise a 301 redirection,
that means the resource is moved permanent.

add a field 'uri_fmt' that each Resource instance needs to define that
can construct the redirect uri:
self.uri_fmt = "/Collections/%s/Collections/%s"

Then in the common redirect we can just do:
raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(list(self.model_args[:-1])
                            + [ident]). 301)

In the code of kimchi, somewhere, the self.model_args is defined as
list, and somewhere it is defined tuple.
so we should change it to list: list(self.model_args[:-1])

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
template-update: mock model support implement update method

implement template_update by calling template_delete followed by
template_create.
As Adam Litke suggested: save the original template so update will
rollback if something fails.

In mockmodel the info of template is stored in memory.
So the update can be this process: lookup -> copy -> delete -> create.
But this process can not by apply to VM create.
There is some specific data for a VM and we can't simply delete it and
then recreate it.

We should support this template update first, and then support VM update.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
template-update: add the test case for update

test case for update template parameters
test case for update template name

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Reviewed-by: Aline Manera <alinefm@br.ibm.com>
template-update: real model support implement update method

implement template_update by calling template_delete followed by
template_create.
As Adam Litke suggested: save the original template so update will
rollback if something fails.

In model the info of template is stored in DB.
So the update can be this process: lookup -> copy -> delete -> create.
But this process can not by apply to VM create.
There is some specific data for a VM and we can't simply delete it and
then recreate it.

We should support this template update first, and then support VM update.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>