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

[vcloud_director] Add #get_org_settings and #get_vcloud.

This commit is contained in:
Nick Osborn 2013-10-15 22:41:08 +01:00
parent 74b6dfc902
commit 16db605f9a
8 changed files with 175 additions and 6 deletions

View file

@ -135,6 +135,7 @@ module Fog
request :get_network_section_vapp
request :get_network_section_vapp_template
request :get_operating_system_section
request :get_org_settings
request :get_org_vdc_gateways
request :get_organization
request :get_organization_metadata
@ -168,6 +169,7 @@ module Fog
request :get_vapp_template_owner
request :get_vapp_templates_from_query
request :get_vapps_in_lease_from_query
request :get_vcloud
request :get_vdc
request :get_vdc_metadata
request :get_vdc_metadata_item_metadata

View file

@ -22,13 +22,13 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-Entity.html
# @since vCloud API version 1.5
def get_entity(id)
response = request({
response = request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => "entity/#{id}"
})
)
ensure_list! response.body, :Link
response
end

View file

@ -0,0 +1,38 @@
module Fog
module Compute
class VcloudDirector
class Real
# Retrieve settings for this organization.
#
# Organization settings are divided into categories. This request
# retrieves all categories of organization settings.
#
# @param [String] id Object identitifier of the organization.
# @return [Excon:Response]
# * body<~Hash>:
# * :href<~String> - The URI of the entity.
# * :type<~String> - The MIME type of the entity.
# * :OrgGeneralSettings<~Hash>:
# * :VAppLeaseSettings<~Hash>:
# * :VAppTemplateLeaseSettings<~Hash>:
# * :OrgLdapSettings<~Hash>:
# * :OrgEmailSettings<~Hash>:
# * :OrgPasswordPolicySettings<~Hash>:
# * :OrgOperationLimitsSettings<~Hash>:
# * :OrgFederationSettings<~Hash>:
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-OrgSettings.html
# @since vCloud API version 0.9
def get_org_settings(id)
request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => "admin/org/#{id}/settings"
)
end
end
end
end
end

View file

@ -13,13 +13,13 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-Organization.html
# @since vCloud API version 0.9
def get_organization(id)
response = request({
response = request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => "org/#{id}"
})
)
ensure_list! response.body, :Tasks, :Task
response
end

View file

@ -18,13 +18,13 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-Organizations.html
# @since vCloud API version 0.9
def get_organizations
response = request({
response = request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'org'
})
)
ensure_list! response.body, :Org
response
end

View file

@ -0,0 +1,76 @@
module Fog
module Compute
class VcloudDirector
class Real
# Retrieve an administrative view of a cloud.
#
# The VCloud element provides access to cloud-wide namespace of objects
# that an administrator can view and, in most cases, modify.
#
# @return [Excon:Response]
# * body<~Hash>:
# * :href<~String> - The URI of the entity.
# * :type<~String> - The MIME type of the entity.
# * :name<~String> - The name of the entity.
# * :Description<~String> - Optional description.
# * :OrganizationReferences<Hash>:
# * :OrganizationReference<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :name<~String> - Contains the name of the entity.
# * :type<~String> - Contains the type of the entity.
# * :ProviderVdcReferences<~Hash>:
# * :ProviderVdcReferences<~Array<Hash>>:
# * :RightReferences<~Hash>:
# * :RightReferences<~Array<Hash>>:
# * :RoleReferences<~Hash>:
# * :RoleReferences<~Array<Hash>>:
# * :Networks<~Hash>:
# * :Network<~Array<Hash>>:
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-Vcloud.html
# @since vCloud API version 0.9
def get_vcloud
response = request(
:expects => 200,
:idempotent => true,
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'admin/'
)
ensure_list! response.body, :OrganizationReferences, :OrganizationReference
ensure_list! response.body, :ProviderVdcReferences, :ProviderVdcReference
ensure_list! response.body, :RightReferences, :RightReference
ensure_list! response.body, :RoleReferences, :RoleReference
ensure_list! response.body, :Networks, :Network
response
end
end
class Mock
def get_vcloud
body =
{:href=>make_href('admin/'),
:type=>"application/vnd.vmware.admin.vcloud+xml",
:name=>'VMware vCloud Director',
:Description=>'5.1.2.1377223 Tue Oct 15 20:56:05 GMT 2013',
:Tasks=>{:Task=>[]},
:OrganizationReferences=>
{:OrganizationReference=>
[{:type=>"application/vnd.vmware.admin.organization+xml",
:name=>data[:org][:name],
:href=>make_href("api/admin/org/#{data[:org][:uuid]}")}]},
:ProviderVdcReferences=>{:ProviderVdcReference=>[]},
:RightReferences=>{:RightReference=>[]},
:RoleReferences=>{:RoleReference=>[]},
:Networks=>{:Network=>[]}}
Excon::Response.new(
:body => body,
:headers => {'Content-Type' => "#{body[:type]};version=#{api_version}"},
:status => 200
)
end
end
end
end
end

View file

@ -0,0 +1,16 @@
Shindo.tests('Compute::VcloudDirector | admin requests', ['vclouddirector']) do
@service = Fog::Compute::VcloudDirector.new
tests('#get_vcloud').data_matches_schema(VcloudDirector::Compute::Schema::VCLOUD_TYPE) do
@service.get_vcloud.body
end
@org = VcloudDirector::Compute::Helper.current_org(@service)
tests('#get_org_settings').returns(Hash) do
pending if Fog.mocking?
@service.get_org_settings(@org[:href].split('/').last).body.class
end
end

View file

@ -583,6 +583,43 @@ class VcloudDirector
:Configuration => GATEWAY_CONFIGURATION_TYPE
}
ORGANIZATION_REFERENCE_TYPE = REFERENCE_TYPE
PROVIDER_VDC_REFERENCE_TYPE = REFERENCE_TYPE
RIGHT_REFERENCE_TYPE = REFERENCE_TYPE
ROLE_REFERENCE_TYPE = REFERENCE_TYPE
# Represents the admin view of this cloud.
ORGANIZATION_REFERENCES_TYPE = {
:OrganizationReference => [REFERENCE_TYPE]
}
# Container for references to Provider vDCs.
PROVIDER_VDC_REFERENCES_TYPE = {
:ProviderVdcReference => [PROVIDER_VDC_REFERENCE_TYPE]
}
# Container for references to rights.
RIGHT_REFERENCES_TYPE = {
:RightReference => [RIGHT_REFERENCE_TYPE]
}
# Container for references to roles.
ROLE_REFERENCES_TYPE = {
:RoleReference => [ROLE_REFERENCE_TYPE]
}
# Container for references to ExternalNetwork objects.
NETWORKS_TYPE = {
:Network => [REFERENCE_TYPE]
}
VCLOUD_TYPE = ENTITY_TYPE.merge({
:OrganizationReferences => ORGANIZATION_REFERENCES_TYPE,
:ProviderVdcReferences => PROVIDER_VDC_REFERENCES_TYPE,
:RightReferences => RIGHT_REFERENCES_TYPE,
:RoleReferences => ROLE_REFERENCES_TYPE,
:Networks => NETWORKS_TYPE
})
end
end
end