diff --git a/lib/fog/vcloud/compute.rb b/lib/fog/vcloud/compute.rb index 8ce660f0c..8accf6dc3 100644 --- a/lib/fog/vcloud/compute.rb +++ b/lib/fog/vcloud/compute.rb @@ -139,6 +139,7 @@ module Fog request :undeploy request :get_metadata request :delete_metadata + request :configure_metadata class Mock diff --git a/lib/fog/vcloud/models/compute/tags.rb b/lib/fog/vcloud/models/compute/tags.rb index 82ffe2fde..68a03d601 100644 --- a/lib/fog/vcloud/models/compute/tags.rb +++ b/lib/fog/vcloud/models/compute/tags.rb @@ -22,6 +22,10 @@ module Fog rescue Fog::Errors::NotFound nil end + + def create(opts) + service.configure_metadata(opts.merge(href: href)) + end end end end diff --git a/lib/fog/vcloud/requests/compute/configure_metadata.rb b/lib/fog/vcloud/requests/compute/configure_metadata.rb new file mode 100644 index 000000000..cd59b62b7 --- /dev/null +++ b/lib/fog/vcloud/requests/compute/configure_metadata.rb @@ -0,0 +1,36 @@ +module Fog + module Vcloud + class Compute + class Real + + def configure_metadata(opts= {}) + valid_opts = [:key, :value, :href] + unless valid_opts.all? { |opt| opts.has_key?(opt) } + raise ArgumentError.new("Required data missing: #{(valid_opts - opts.keys).map(&:inspect).join(", ")}") + end + + body = < + + #{opts[:key]} + #{opts[:value]} + + +EOF + + request( + :body => body, + :expects => 202, # it returns a task object + :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml' }, + :method => 'POST', + :uri => opts[:href], + :parse => true + ) + end + + end + end + end +end