mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
get_vdc implemented
This commit is contained in:
parent
180b29caad
commit
27a925c44a
3 changed files with 139 additions and 2 deletions
92
lib/fog/vcloudng/parsers/compute/get_vdc.rb
Normal file
92
lib/fog/vcloudng/parsers/compute/get_vdc.rb
Normal file
|
@ -0,0 +1,92 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Vcloudng
|
||||
module Compute
|
||||
|
||||
|
||||
class GetVdc < VcloudngParser
|
||||
|
||||
def reset
|
||||
@in_storage_capacity = false
|
||||
@in_cpu = false
|
||||
@in_memory = false
|
||||
@in_instantiated_vms_quota = false
|
||||
@in_deployed_vms_quota = false
|
||||
@response = {
|
||||
'links' => [],
|
||||
'AvailableNetworks' => [],
|
||||
'ComputeCapacity' => {
|
||||
'Cpu' => {},
|
||||
'DeployedVmsQuota' => {},
|
||||
'InstantiatedVmsQuota' => {},
|
||||
'Memory' => {}
|
||||
},
|
||||
'StorageCapacity' => {},
|
||||
'ResourceEntities' => []
|
||||
}
|
||||
end
|
||||
|
||||
def start_element(name, attributes)
|
||||
super
|
||||
case name
|
||||
when 'Cpu'
|
||||
@in_cpu = true
|
||||
when 'DeployedVmsQuota'
|
||||
@in_deployed_vms_quota = true
|
||||
when 'InstantiatedVmsQuota'
|
||||
@in_instantiated_vms_quota = true
|
||||
when 'Link'
|
||||
link = extract_attributes(attributes)
|
||||
@response['links'] << link
|
||||
when 'Memory'
|
||||
@in_memory = true
|
||||
when 'Network'
|
||||
network = extract_attributes(attributes)
|
||||
@response['AvailableNetworks'] << network
|
||||
when 'ResourceEntity'
|
||||
resource_entity = extract_attributes(attributes)
|
||||
@response['ResourceEntities'] << resource_entity
|
||||
when 'StorageCapacity'
|
||||
@in_storage_capacity = true
|
||||
when 'Vdc'
|
||||
vdc = extract_attributes(attributes)
|
||||
@response['href'] = vdc['href']
|
||||
@response['name'] = vdc['name']
|
||||
end
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'Allocated', 'Limit', 'Units', 'Used'
|
||||
if @in_cpu
|
||||
@response['ComputeCapacity']['Cpu'][name] = value
|
||||
elsif @in_deployed_vms_quota
|
||||
@response['ComputeCapacity']['DeployedVmsQuota'][name] = value
|
||||
elsif @in_instantiated_vms_quota
|
||||
@response['ComputeCapacity']['InstantiatedVmsQuota'][name] = value
|
||||
elsif @in_memory
|
||||
@response['ComputeCapacity']['Memory'][name] = value
|
||||
elsif @in_storage_capacity
|
||||
@response['StorageCapacity'][name] = value
|
||||
end
|
||||
when 'Cpu'
|
||||
@in_cpu = false
|
||||
when 'DeployedVmsQuota'
|
||||
@in_deployed_vms_quota = false
|
||||
when 'InstantiatedVmsQuota'
|
||||
@in_instantiated_vms_quota = false
|
||||
when 'Memory'
|
||||
@in_memory = false
|
||||
when 'StorageCapacity'
|
||||
@in_storage_capacity = false
|
||||
when 'Type'
|
||||
@response[name] = value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
46
lib/fog/vcloudng/requests/compute/get_vdc.rb
Normal file
46
lib/fog/vcloudng/requests/compute/get_vdc.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
module Fog
|
||||
module Vcloudng
|
||||
module Compute
|
||||
class Real
|
||||
|
||||
require 'fog/vcloudng/parsers/compute/get_vdc'
|
||||
|
||||
# Get details of a vdc
|
||||
#
|
||||
# ==== Parameters
|
||||
# * vdc_id<~Integer> - Id of vdc to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
|
||||
# FIXME
|
||||
|
||||
# * 'CatalogItems'<~Array>
|
||||
# * 'href'<~String> - linke to item
|
||||
# * 'name'<~String> - name of item
|
||||
# * 'type'<~String> - type of item
|
||||
# * 'description'<~String> - Description of catalog
|
||||
# * 'name'<~String> - Name of catalog
|
||||
#
|
||||
# === How to get the catalog_uuid?
|
||||
#
|
||||
# org_uuid = vcloud.get_organizations.data[:body]["OrgList"].first["href"].split('/').last
|
||||
# org = vcloud.get_organization(org_uuid)
|
||||
# vdc_id = org.data[:body]["Links"].detect {|l| l["type"] =~ /vcloud.vdc/ }["href"].split('/').last
|
||||
#
|
||||
def get_vdc(vdc_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:headers => { 'Accept' => 'application/*+xml;version=1.5' },
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Vcloudng::Compute::GetVdc.new,
|
||||
:path => "vdc/#{vdc_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -258,7 +258,6 @@ module Fog
|
|||
#require 'fog/vcloudng/parsers/compute/get_public_ips'
|
||||
#require 'fog/vcloudng/parsers/compute/get_tasks_list'
|
||||
#require 'fog/vcloudng/parsers/compute/get_keys_list'
|
||||
#require 'fog/vcloudng/parsers/compute/get_vdc'
|
||||
#require 'fog/vcloudng/parsers/compute/instantiate_vapp_template'
|
||||
#require 'fog/vcloudng/parsers/compute/internet_service'
|
||||
#require 'fog/vcloudng/parsers/compute/network'
|
||||
|
@ -289,8 +288,8 @@ module Fog
|
|||
#require 'fog/vcloudng/requests/compute/get_keys_list'
|
||||
#require 'fog/vcloudng/requests/compute/get_vapp'
|
||||
require 'fog/vcloudng/requests/compute/get_vapp_template'
|
||||
#require 'fog/vcloudng/requests/compute/get_vdc'
|
||||
#require 'fog/vcloudng/requests/compute/instantiate_vapp_template'
|
||||
require 'fog/vcloudng/requests/compute/get_vdc'
|
||||
#require 'fog/vcloudng/requests/compute/configure_vapp'
|
||||
#require 'fog/vcloudng/requests/compute/power_off'
|
||||
#require 'fog/vcloudng/requests/compute/power_on'
|
||||
|
|
Loading…
Add table
Reference in a new issue