mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
server.tags implemented
This commit is contained in:
parent
71af3a7ec2
commit
08fc2f1eac
5 changed files with 63 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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!
|
||||
|
|
16
lib/fog/vcloud/models/compute/tag.rb
Normal file
16
lib/fog/vcloud/models/compute/tag.rb
Normal file
|
@ -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
|
28
lib/fog/vcloud/models/compute/tags.rb
Normal file
28
lib/fog/vcloud/models/compute/tags.rb
Normal file
|
@ -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
|
10
lib/fog/vcloud/requests/compute/get_metadata.rb
Normal file
10
lib/fog/vcloud/requests/compute/get_metadata.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
|
||||
class Real
|
||||
basic_request :get_metadata
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue