mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
redo marios fixes that accidently got lost in rebase
This commit is contained in:
parent
7514c996cb
commit
24adf4b7ff
1 changed files with 49 additions and 89 deletions
|
@ -1,73 +1,37 @@
|
||||||
module Fog
|
module Fog
|
||||||
module Terremark
|
module Terremark
|
||||||
module Shared
|
module Shared
|
||||||
module Real
|
class Real
|
||||||
|
|
||||||
# Instatiate a vapp template
|
# Instatiate a vapp template
|
||||||
#
|
#
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
# * vdc_id<~Integer> - Id of vdc to instantiate template in
|
# * name<~String>: Name of the resulting vapp .. must start with letter, up to 15 chars alphanumeric.
|
||||||
# * options<~Hash>:
|
# * options<~Hash>:
|
||||||
# * cpus<~Integer>: Number of cpus in [1, 2, 4, 8], defaults to 1
|
# * cpus<~Integer>: Number of cpus in [1, 2, 4, 8], defaults to 1
|
||||||
# * memory<~Integer>: Amount of memory either 512 or a multiple of 1024, defaults to 512
|
# * memory<~Integer>: Amount of memory either 512 or a multiple of 1024, defaults to 512
|
||||||
|
# * vapp_template<~String>: id of the vapp template to be instantiated
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
# * body<~Hash>:
|
# * body<~Hash>:
|
||||||
|
# * 'Links;<~Array> (e.g. up to vdc)
|
||||||
# FIXME
|
# * 'href'<~String> Link to the resulting vapp
|
||||||
|
|
||||||
# * 'CatalogItems'<~Array>
|
|
||||||
# * 'href'<~String> - linke to item
|
|
||||||
# * 'name'<~String> - name of item
|
# * 'name'<~String> - name of item
|
||||||
# * 'type'<~String> - type of item
|
# * 'type'<~String> - type of item
|
||||||
# * 'description'<~String> - Description of catalog
|
# * 'status'<~String> - 0(pending) --> 2(off) -->4(on)
|
||||||
# * 'name'<~String> - Name of catalog
|
def instantiate_vapp_template(name, vapp_template, options = {})
|
||||||
def instantiate_vapp_template(name, options = {})
|
unless name.length < 15
|
||||||
|
raise ArgumentError.new('Name must be fewer than 15 characters')
|
||||||
|
end
|
||||||
options['cpus'] ||= 1
|
options['cpus'] ||= 1
|
||||||
options['memory'] ||= 512
|
options['memory'] ||= 512
|
||||||
|
options['network_id'] ||= default_network_id
|
||||||
# FIXME: much cheating to commence
|
options['vdc_id'] ||= default_vdc_id
|
||||||
vdc_id = default_vdc_id
|
|
||||||
network_id = default_network_id
|
|
||||||
catalog_item = 12 # Ubuntu JeOS 9.10 (64-bit)
|
|
||||||
|
|
||||||
# case UNRESOLVED:
|
|
||||||
# return "0";
|
|
||||||
# case RESOLVED:
|
|
||||||
# return "1";
|
|
||||||
# case OFF:
|
|
||||||
# return "2";
|
|
||||||
# case SUSPENDED:
|
|
||||||
# return "3";
|
|
||||||
# case ON:
|
|
||||||
# return "4";
|
|
||||||
# default:
|
|
||||||
#
|
|
||||||
# /**
|
|
||||||
# * The vApp is unresolved (one or more file references are unavailable in the cloud)
|
|
||||||
# */
|
|
||||||
# UNRESOLVED,
|
|
||||||
# /**
|
|
||||||
# * The vApp is resolved (all file references are available in the cloud) but not deployed
|
|
||||||
# */
|
|
||||||
# RESOLVED,
|
|
||||||
# /**
|
|
||||||
# * The vApp is deployed and powered off
|
|
||||||
# */
|
|
||||||
# OFF,
|
|
||||||
# /**
|
|
||||||
# * The vApp is deployed and suspended
|
|
||||||
# */
|
|
||||||
# SUSPENDED,
|
|
||||||
# /**
|
|
||||||
# * The vApp is deployed and powered on
|
|
||||||
# */
|
|
||||||
# ON;
|
|
||||||
|
|
||||||
data = <<-DATA
|
data = <<-DATA
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<InstantiateVAppTemplateParams name="#{name}" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://services.vcloudexpress.terremark.com/api/v0.8/ns/vcloud.xsd">
|
<InstantiateVAppTemplateParams name="#{name}" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 http://services.vcloudexpress.terremark.com/api/v0.8/ns/vcloud.xsd">
|
||||||
<VAppTemplate href="https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/#{catalog_item}" />
|
<VAppTemplate href="#{@scheme}://#{@host}/#{@path}/vAppTemplate/#{vapp_template}" />
|
||||||
<InstantiationParams xmlns:vmw="http://www.vmware.com/schema/ovf">
|
<InstantiationParams xmlns:vmw="http://www.vmware.com/schema/ovf">
|
||||||
<ProductSection xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:q1="http://www.vmware.com/vcloud/v0.8"/>
|
<ProductSection xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:q1="http://www.vmware.com/vcloud/v0.8"/>
|
||||||
<VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8">
|
<VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8">
|
||||||
|
@ -83,12 +47,8 @@ module Fog
|
||||||
</Item>
|
</Item>
|
||||||
</VirtualHardwareSection>
|
</VirtualHardwareSection>
|
||||||
<NetworkConfigSection>
|
<NetworkConfigSection>
|
||||||
<NetworkConfig name="Network 1">
|
<NetworkConfig>
|
||||||
<Features>
|
<NetworkAssociation href="#{@scheme}://#{@host}/#{@path}/network/#{options['network_id']}"/>
|
||||||
<vmw:FenceMode>allowInOut</vmw:FenceMode>
|
|
||||||
<vmw:Dhcp>true</vmw:Dhcp>
|
|
||||||
</Features>
|
|
||||||
<NetworkAssociation href="https://services.vcloudexpress.terremark.com/api/v8/network/#{network_id}" />
|
|
||||||
</NetworkConfig>
|
</NetworkConfig>
|
||||||
</NetworkConfigSection>
|
</NetworkConfigSection>
|
||||||
</InstantiationParams>
|
</InstantiationParams>
|
||||||
|
@ -100,14 +60,14 @@ module Fog
|
||||||
:expects => 200,
|
:expects => 200,
|
||||||
:headers => { 'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml' },
|
:headers => { 'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml' },
|
||||||
:method => 'POST',
|
:method => 'POST',
|
||||||
:parser => Fog::Parsers::Terremark::Shared::InstantiateVappTemplate.new,
|
:parser => Fog::Parsers::Terremark::InstantiateVappTemplate.new,
|
||||||
:path => "vdc/#{vdc_id}/action/instantiatevAppTemplate"
|
:path => "vdc/#{options['vdc_id']}/action/instantiatevAppTemplate"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Mock
|
class Mock
|
||||||
|
|
||||||
def instatiate_vapp_template(vapp_template_id)
|
def instatiate_vapp_template(vapp_template_id)
|
||||||
raise MockNotImplemented.new("Contributions welcome!")
|
raise MockNotImplemented.new("Contributions welcome!")
|
||||||
|
|
Loading…
Add table
Reference in a new issue