mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud_director] whitespace cleanup
This commit is contained in:
parent
0130f4b21c
commit
bf38e751ac
67 changed files with 778 additions and 803 deletions
|
@ -3,7 +3,6 @@ require 'fog/compute'
|
|||
require 'fog/vcloud_director/requests/compute/helper'
|
||||
|
||||
class VcloudDirectorParser < Fog::Parsers::Base
|
||||
|
||||
def extract_attributes(attributes_xml)
|
||||
attributes = {}
|
||||
until attributes_xml.empty?
|
||||
|
@ -19,8 +18,6 @@ class VcloudDirectorParser < Fog::Parsers::Base
|
|||
end
|
||||
attributes
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
class NonLoaded
|
||||
|
@ -42,13 +39,11 @@ module Fog
|
|||
class Task < ServiceError; end
|
||||
end
|
||||
|
||||
|
||||
requires :vcloud_director_username, :vcloud_director_password, :vcloud_director_host
|
||||
recognizes :vcloud_director_api_version
|
||||
|
||||
secrets :vcloud_director_password
|
||||
|
||||
|
||||
model_path 'fog/vcloud_director/models/compute'
|
||||
model :catalog
|
||||
collection :catalogs
|
||||
|
@ -75,7 +70,6 @@ module Fog
|
|||
model :tag # this is called metadata in vcloud
|
||||
collection :tags
|
||||
|
||||
|
||||
request_path 'fog/vcloud_director/requests/compute'
|
||||
request :get_organizations
|
||||
request :get_organization
|
||||
|
@ -118,7 +112,7 @@ module Fog
|
|||
attributes[attr]= NonLoaded if attributes[attr].nil?
|
||||
make_lazy_load_method(attr)
|
||||
end
|
||||
self.class.attributes.each{|attr| make_attr_loaded_method(attr) }
|
||||
self.class.attributes.each {|attr| make_attr_loaded_method(attr)}
|
||||
end
|
||||
|
||||
def lazy_load_attrs
|
||||
|
@ -134,7 +128,8 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
# it adds an attr_loaded? method to know if the value has been loaded yet or not: ie description_loaded?
|
||||
# it adds an attr_loaded? method to know if the value has been loaded
|
||||
# yet or not: ie description_loaded?
|
||||
def make_attr_loaded_method(attr)
|
||||
self.class.instance_eval do
|
||||
define_method("#{attr}_loaded?") do
|
||||
|
@ -163,7 +158,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get_by_name(item_name)
|
||||
item_found = item_list.detect{|item| item[:name] == item_name }
|
||||
item_found = item_list.detect {|item| item[:name] == item_name}
|
||||
return nil unless item_found
|
||||
get(item_found[:id])
|
||||
end
|
||||
|
@ -173,7 +168,7 @@ module Fog
|
|||
end
|
||||
|
||||
def get_everyone
|
||||
items = item_list.map {|item| get_by_id(item[:id]) }
|
||||
items = item_list.map {|item| get_by_id(item[:id])}
|
||||
load(items)
|
||||
end
|
||||
end
|
||||
|
@ -304,5 +299,3 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
# "has_customization_script"=>true,
|
||||
# "computer_name"=>"DEVWEB-001"}
|
||||
#
|
||||
#
|
||||
# This is what it generates
|
||||
#
|
||||
# <vcloud:GuestCustomizationSection
|
||||
|
@ -66,7 +65,6 @@ module Fog
|
|||
http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd
|
||||
http://www.vmware.com/vcloud/v1.5
|
||||
http://zone01.bluelock.com/api/v1.5/schema/master.xsd">'
|
||||
|
||||
end
|
||||
|
||||
# the order maters http://communities.vmware.com/thread/448760?start=0&tstart=0
|
||||
|
@ -75,7 +73,6 @@ module Fog
|
|||
# CustomizationScript
|
||||
# Script to run on guest customization. You could use xml escape sequence to make multiple lines script. The script could contain any UNICODE symbol by specifying its number in format &#xxxx; where xxxx is the number. The predefined symbols in the XML are: * & & * < < * > > * " " * ' '
|
||||
|
||||
|
||||
def body(opts={})
|
||||
body = "
|
||||
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
|
||||
|
@ -96,6 +93,7 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -98,6 +98,7 @@ EOF
|
|||
EOF
|
||||
end
|
||||
end
|
||||
#
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -94,7 +94,6 @@ module Fog
|
|||
|
||||
end
|
||||
|
||||
|
||||
def body(opts={})
|
||||
body = <<EOF
|
||||
<ovf:Info>#{opts[:info]}</ovf:Info>
|
||||
|
@ -116,6 +115,7 @@ EOF
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,6 @@ module Fog
|
|||
service.process_task(response.body[:Tasks][:Task])
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,17 +5,13 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
|
||||
|
||||
class Catalogs < Collection
|
||||
model Fog::Compute::VcloudDirector::Catalog
|
||||
|
||||
|
||||
attribute :organization
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def get_by_id(item_id)
|
||||
item = service.get_catalog(item_id).body
|
||||
%w(:CatalogItems :Link).each {|key_to_delete| item.delete(key_to_delete) }
|
||||
|
|
|
@ -25,7 +25,6 @@ module Fog
|
|||
items
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,6 @@ module Fog
|
|||
class Organizations < Collection
|
||||
model Fog::Compute::VcloudDirector::Organization
|
||||
|
||||
|
||||
private
|
||||
|
||||
def get_by_id(org_id)
|
||||
|
|
|
@ -45,7 +45,6 @@ module Fog
|
|||
@items.detect{ |i| i[:id] == item_id}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,6 @@ module Fog
|
|||
|
||||
class Vapp < Model
|
||||
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
|
|
|
@ -27,7 +27,6 @@ module Fog
|
|||
service.vapps(:vdc => self)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'fog/core/model'
|
||||
require 'fog/vcloud_director/models/compute/vm_customization'
|
||||
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class VcloudDirector
|
||||
|
@ -21,7 +20,6 @@ module Fog
|
|||
attribute :memory
|
||||
attribute :hard_disks, :aliases => :disks
|
||||
|
||||
|
||||
def reload
|
||||
# when collection.vapp is nil, it means it's fatherless,
|
||||
# vms from different vapps are loaded in the same collection.
|
||||
|
@ -90,7 +88,6 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,6 @@ module Fog
|
|||
|
||||
class VmCustomization < Model
|
||||
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :type
|
||||
|
|
|
@ -10,7 +10,6 @@ module Fog
|
|||
|
||||
attribute :vm
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,7 +6,6 @@ module Fog
|
|||
|
||||
class VmNetwork < Model
|
||||
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :type
|
||||
|
|
|
@ -3,8 +3,6 @@ module Fog
|
|||
module Compute
|
||||
module VcloudDirector
|
||||
|
||||
|
||||
|
||||
class Disks < VcloudDirectorParser
|
||||
|
||||
def reset
|
||||
|
@ -51,7 +49,6 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -46,7 +46,6 @@ module Fog
|
|||
@response[:has_customization_script] = !value.empty?
|
||||
@response[:customization_script] = CGI::unescapeHTML(value) if @response[:has_customization_script]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -33,7 +33,6 @@ module Fog
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -12,7 +12,6 @@ module Fog
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
require 'fog/vcloud_director/parsers/compute/network'
|
||||
|
||||
def get_network(network_id)
|
||||
|
|
|
@ -4,7 +4,6 @@ module Fog
|
|||
class Real
|
||||
|
||||
def get_organization(organization_id)
|
||||
|
||||
request({
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
@ -14,8 +13,6 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,6 @@ module Fog
|
|||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
|
||||
def get_organizations
|
||||
request({
|
||||
:expects => 200,
|
||||
|
@ -14,8 +13,6 @@ module Fog
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,6 +10,7 @@ module Fog
|
|||
:path => uri
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,9 +12,7 @@ module Fog
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,9 +12,7 @@ module Fog
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -12,9 +12,7 @@ module Fog
|
|||
)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,6 +2,7 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
require 'fog/vcloud_director/parsers/compute/vm'
|
||||
|
||||
def get_vm(vm_id)
|
||||
|
|
|
@ -2,6 +2,7 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
require 'fog/vcloud_director/parsers/compute/vm_customization'
|
||||
|
||||
def get_vm_customization(vm_id)
|
||||
|
|
|
@ -2,8 +2,8 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
require 'fog/vcloud_director/parsers/compute/disks'
|
||||
|
||||
require 'fog/vcloud_director/parsers/compute/disks'
|
||||
|
||||
def get_vm_disks(vm_id)
|
||||
request(
|
||||
|
|
|
@ -3,9 +3,9 @@ module Fog
|
|||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
def get_vm_network(vm_id)
|
||||
require 'fog/vcloud_director/parsers/compute/vm_network'
|
||||
|
||||
def get_vm_network(vm_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
|
@ -2,6 +2,7 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
require 'fog/vcloud_director/parsers/compute/vms'
|
||||
|
||||
def get_vms(vapp_id)
|
||||
|
|
|
@ -3,9 +3,9 @@ module Fog
|
|||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
def get_vms_by_metadata(key,value)
|
||||
require 'fog/vcloud_director/parsers/compute/vms_by_metadata'
|
||||
|
||||
def get_vms_by_metadata(key,value)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
|
|
|
@ -91,4 +91,3 @@ module Fog
|
|||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -3,7 +3,7 @@ module Fog
|
|||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
#TODO move all the logic to a generator
|
||||
# TODO move all the logic to a generator
|
||||
|
||||
def instantiate_vapp_template(vapp_name, template_id, options = {})
|
||||
params = populate_uris(options.merge(:vapp_name => vapp_name, :template_id => template_id))
|
||||
|
@ -72,9 +72,9 @@ module Fog
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
def xmlns
|
||||
{ 'xmlns' => "http://www.vmware.com/vcloud/v1.5",
|
||||
{
|
||||
'xmlns' => "http://www.vmware.com/vcloud/v1.5",
|
||||
"xmlns:ovf" => "http://schemas.dmtf.org/ovf/envelope/1",
|
||||
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
||||
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema"
|
||||
|
|
|
@ -22,6 +22,7 @@ module Fog
|
|||
:path => "vApp/#{vm_id}/metadata/"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,6 @@ module Fog
|
|||
class Real
|
||||
|
||||
def post_vm_poweron(vm_id)
|
||||
|
||||
request(
|
||||
:expects => 202,
|
||||
:method => 'POST',
|
||||
|
@ -12,6 +11,7 @@ module Fog
|
|||
:path => "vApp/#{vm_id}/power/action/powerOn"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,6 @@ module Fog
|
|||
<Value>#{metadata_value}</Value>
|
||||
</MetadataValue>"
|
||||
|
||||
|
||||
request(
|
||||
:body => body,
|
||||
:expects => 202,
|
||||
|
@ -19,6 +18,7 @@ module Fog
|
|||
:path => "vApp/#{vm_id}/metadata/#{URI.escape(metadata_key)}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@ module Fog
|
|||
<Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="#{endpoint}vApp/#{vm_id}/virtualHardwareSection/cpu"/>
|
||||
</Item>
|
||||
EOF
|
||||
|
||||
request(
|
||||
:body => data,
|
||||
:expects => 202,
|
||||
|
@ -26,6 +27,7 @@ EOF
|
|||
:path => "vApp/#{vm_id}/virtualHardwareSection/cpu"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
require 'fog/vcloud_director/generators/compute/customization'
|
||||
|
||||
def put_vm_customization(vm_id, customization={})
|
||||
|
@ -16,6 +17,7 @@ module Fog
|
|||
:path => "vApp/#{vm_id}/guestCustomizationSection"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
require 'fog/vcloud_director/generators/compute/disks'
|
||||
|
||||
# disks is the body of get_vm_disks
|
||||
|
@ -17,6 +18,7 @@ module Fog
|
|||
:path => "vApp/#{vm_id}/virtualHardwareSection/disks"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@ module Fog
|
|||
<Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="#{endpoint}vApp/#{vm_id}/virtualHardwareSection/memory"/>
|
||||
</Item>
|
||||
EOF
|
||||
|
||||
request(
|
||||
:body => data,
|
||||
:expects => 202,
|
||||
|
@ -26,6 +27,7 @@ EOF
|
|||
:path => "vApp/#{vm_id}/virtualHardwareSection/memory"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,9 +3,9 @@ module Fog
|
|||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
def put_vm_network(vm_id, network={})
|
||||
require 'fog/vcloud_director/generators/compute/vm_network'
|
||||
|
||||
def put_vm_network(vm_id, network={})
|
||||
data = Fog::Generators::Compute::VcloudDirector::VmNetwork.new(network)
|
||||
|
||||
request(
|
||||
|
@ -17,6 +17,7 @@ module Fog
|
|||
:path => "vApp/#{vm_id}/networkConnectionSection/"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,14 @@ module Fog
|
|||
module Compute
|
||||
class VcloudDirector
|
||||
class Real
|
||||
|
||||
def undeploy(vapp_id)
|
||||
body = <<EOF
|
||||
<UndeployVAppParams xmlns="http://www.vmware.com/vcloud/v1.5">
|
||||
<UndeployPowerAction>shutdown</UndeployPowerAction>
|
||||
</UndeployVAppParams>
|
||||
EOF
|
||||
|
||||
request(
|
||||
:body => body,
|
||||
:expects => 202,
|
||||
|
@ -17,6 +19,7 @@ EOF
|
|||
:path => "vApp/#{vapp_id}/action/undeploy"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue