diff --git a/lib/fog/vcloud/compute.rb b/lib/fog/vcloud/compute.rb index 4cc393460..89b00bfbc 100644 --- a/lib/fog/vcloud/compute.rb +++ b/lib/fog/vcloud/compute.rb @@ -105,6 +105,8 @@ module Fog collection :vdcs model :organization collection :organizations + model :tag + collection :tags request_path 'fog/vcloud/requests/compute' request :clone_vapp @@ -135,6 +137,7 @@ module Fog request :power_reset request :power_shutdown request :undeploy + request :get_metadata class Mock diff --git a/lib/fog/vcloud/models/compute/server.rb b/lib/fog/vcloud/models/compute/server.rb index 8d9a75736..212c9e47f 100644 --- a/lib/fog/vcloud/models/compute/server.rb +++ b/lib/fog/vcloud/models/compute/server.rb @@ -27,6 +27,12 @@ module Fog attribute :tasks, :aliases => :Tasks, :type => :array has_up :vapp + + def tags + @tags ||= Fog::Vcloud::Compute::Tags. + new( :service => service, + :href => href + '/metadata' ) + end def computer_name load_unless_loaded! diff --git a/lib/fog/vcloud/models/compute/tag.rb b/lib/fog/vcloud/models/compute/tag.rb new file mode 100644 index 000000000..e941b60be --- /dev/null +++ b/lib/fog/vcloud/models/compute/tag.rb @@ -0,0 +1,16 @@ +module Fog + module Vcloud + class Compute + class Tag < Fog::Vcloud::Model + identity :href, :aliases => :Href + attribute :links, :aliases => :Link, :type => :array + ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd + + attribute :key, :aliases => :Key + attribute :value, :aliases => :Value + + + end + end + end +end diff --git a/lib/fog/vcloud/models/compute/tags.rb b/lib/fog/vcloud/models/compute/tags.rb new file mode 100644 index 000000000..82ffe2fde --- /dev/null +++ b/lib/fog/vcloud/models/compute/tags.rb @@ -0,0 +1,28 @@ +require 'fog/vcloud/models/compute/tag' + +module Fog + module Vcloud + class Compute + + class Tags < Fog::Vcloud::Collection + + undef_method :create + + model Fog::Vcloud::Compute::Tag + + attribute :href, :aliases => :Href + + def all + metadata = service.get_metadata(self.href) + load(metadata.body[:MetadataEntry]) if metadata.body[:MetadataEntry] + end + + def get(uri) + service.get_metadata(uri) + rescue Fog::Errors::NotFound + nil + end + end + end + end +end \ No newline at end of file diff --git a/lib/fog/vcloud/requests/compute/get_metadata.rb b/lib/fog/vcloud/requests/compute/get_metadata.rb new file mode 100644 index 000000000..5f585d914 --- /dev/null +++ b/lib/fog/vcloud/requests/compute/get_metadata.rb @@ -0,0 +1,10 @@ +module Fog + module Vcloud + class Compute + + class Real + basic_request :get_metadata + end + end + end +end