From cc9ee787ac8402ac0f44f1fbfc8d20ccd9878999 Mon Sep 17 00:00:00 2001 From: Jon Perritt Date: Fri, 2 Jan 2015 12:40:42 -0700 Subject: [PATCH] update openstack server metadata --- .../resource_openstack_compute_instance.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/builtin/providers/openstack/resource_openstack_compute_instance.go b/builtin/providers/openstack/resource_openstack_compute_instance.go index 07bf040e9..e4d1407d7 100644 --- a/builtin/providers/openstack/resource_openstack_compute_instance.go +++ b/builtin/providers/openstack/resource_openstack_compute_instance.go @@ -221,7 +221,21 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err _, err := servers.Update(osClient, d.Id(), updateOpts).Extract() if err != nil { - return fmt.Errorf("Error updating Openstack server: %s", err) + return fmt.Errorf("Error updating OpenStack server: %s", err) + } + } + + if d.HasChange("metadata") { + var metadataOpts servers.MetadataOpts + metadataOpts = make(servers.MetadataOpts) + newMetadata := d.Get("metadata").(map[string]interface{}) + for k, v := range newMetadata { + metadataOpts[k] = v.(string) + } + + _, err := servers.UpdateMetadata(osClient, d.Id(), metadataOpts).Extract() + if err != nil { + return fmt.Errorf("Error updating OpenStack server (%s) metadata: %s", d.Id(), err) } }