1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

- make tags model to use post_undeploy_vapp

- fix syntax error in post_undeploy_vapp method
- remove post_vm_metadata
This commit is contained in:
Rodrigo Estebanez 2013-10-14 17:21:56 +02:00
parent ed54f452ef
commit d5dadbca74
4 changed files with 9 additions and 48 deletions

View file

@ -223,7 +223,6 @@ module Fog
request :post_upgrade_hw_version
request :post_upload_media
request :post_upload_vapp_template
request :post_vm_metadata # deprecated
request :put_catalog_item_metadata_item_metadata
request :put_cpu
request :put_disk_metadata_item_metadata

View file

@ -13,17 +13,14 @@ module Fog
def get_by_name(tag_name)
get(tag_name)
end
def get_by_id(item_id)
item_list unless @items
@items.detect{ |i| i[:id] == item_id}
end
def create(key,value)
item_list unless @tags
metadata_klass = case service.api_version
when '5.1' ; Fog::Generators::Compute::VcloudDirector::MetadataV51
when '1.5' ; Fog::Generators::Compute::VcloudDirector::MetadataV15
else raise "API version: #{api_version} not supported"
end
data = metadata_klass.new(@tags)
data.add_item(key, value)
response = service.post_vapp_metadata_item_metadata(vm.id, data.attrs)
response = service.post_update_vapp_metadata(vm.id, { key => value} )
service.process_task(response.body)
end
@ -32,19 +29,14 @@ module Fog
@tags[:metadata]
end
# private
private
def item_list
@items =[]
hash_items.each_pair{ |k,v| @items << {:id => k, :value => v }.merge(:vm => vm) }
@items
end
def get_by_id(item_id)
item_list unless @items
@items.detect{ |i| i[:id] == item_id}
end
end
end
end

View file

@ -37,7 +37,7 @@ module Fog
:xmlns => 'http://www.vmware.com/vcloud/v1.5'
}
UndeployVAppParams(attrs) {
if options.key?[:UndeployPowerAction]
if options[:UndeployPowerAction]
UndeployPowerAction options[:UndeployPowerAction]
end
}

View file

@ -1,30 +0,0 @@
module Fog
module Compute
class VcloudDirector
class Real
require 'fog/vcloud_director/generators/compute/metadata'
# @deprecated Use {#post_update_vapp_metadata} instead.
def post_vm_metadata(vm_id, metadata={})
Fog::Logger.deprecation("#{self} => ##{post_vm_metadata} is deprecated, use ##{post_update_vapp_metadata} instead [light_black](#{caller.first})[/]")
metadata_klass = case api_version
when '5.1' ; Fog::Generators::Compute::VcloudDirector::MetadataV51
when '1.5' ; Fog::Generators::Compute::VcloudDirector::MetadataV15
else raise "API version: #{api_version} not supported"
end
data = metadata_klass.new(metadata)
request(
:body => data.generate_xml,
:expects => 202,
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
:method => 'POST',
:parser => Fog::ToHashDocument.new,
:path => "vApp/#{vm_id}/metadata/"
)
end
end
end
end
end