Module: Fog::Terremark::Shared::Real

Includes:
Common
Included in:
Vcloud::Real
Defined in:
lib/fog/terremark/shared.rb,
lib/fog/terremark/models/shared/vdcs.rb,
lib/fog/terremark/models/shared/tasks.rb,
lib/fog/terremark/models/shared/images.rb,
lib/fog/terremark/models/shared/servers.rb,
lib/fog/terremark/models/shared/networks.rb,
lib/fog/terremark/models/shared/addresses.rb,
lib/fog/terremark/requests/shared/get_vdc.rb,
lib/fog/terremark/requests/shared/get_task.rb,
lib/fog/terremark/requests/shared/get_vapp.rb,
lib/fog/terremark/requests/shared/power_on.rb,
lib/fog/terremark/requests/shared/power_off.rb,
lib/fog/terremark/models/shared/nodeservices.rb,
lib/fog/terremark/requests/shared/delete_vapp.rb,
lib/fog/terremark/requests/shared/deploy_vapp.rb,
lib/fog/terremark/requests/shared/get_catalog.rb,
lib/fog/terremark/requests/shared/get_network.rb,
lib/fog/terremark/requests/shared/power_reset.rb,
lib/fog/terremark/requests/shared/get_keys_list.rb,
lib/fog/terremark/requests/shared/get_public_ip.rb,
lib/fog/terremark/models/shared/internetservices.rb,
lib/fog/terremark/requests/shared/configure_vapp.rb,
lib/fog/terremark/requests/shared/get_public_ips.rb,
lib/fog/terremark/requests/shared/get_tasks_list.rb,
lib/fog/terremark/requests/shared/power_shutdown.rb,
lib/fog/terremark/requests/shared/get_network_ips.rb,
lib/fog/terremark/requests/shared/add_node_service.rb,
lib/fog/terremark/requests/shared/delete_public_ip.rb,
lib/fog/terremark/requests/shared/get_catalog_item.rb,
lib/fog/terremark/requests/shared/get_organization.rb,
lib/fog/terremark/requests/shared/get_node_services.rb,
lib/fog/terremark/requests/shared/get_organizations.rb,
lib/fog/terremark/requests/shared/get_vapp_template.rb,
lib/fog/terremark/requests/shared/delete_node_service.rb,
lib/fog/terremark/requests/shared/add_internet_service.rb,
lib/fog/terremark/requests/shared/get_internet_services.rb,
lib/fog/terremark/requests/shared/create_internet_service.rb,
lib/fog/terremark/requests/shared/delete_internet_service.rb,
lib/fog/terremark/requests/shared/instantiate_vapp_template.rb

Instance Method Summary collapse

Methods included from Common

#default_organization_id

Instance Method Details

#add_internet_service(ip_id, name, protocol, port, options = {}) ⇒ Object

Reserve requested resources and deploy vApp

Parameters

  • ip_id<~Integer> - Id of ip to add service to

  • name<~String> - Name of service

  • protocol<~String> - Protocol of service

  • port<~Integer> - Port of service

  • options<~Hash>:

    • Enabled<~Boolean>: defaults to true

    • Description<~String>: optional description

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/terremark/requests/shared/add_internet_service.rb', line 28

def add_internet_service(ip_id, name, protocol, port, options = {})
  unless options.key?('Enabled')
    options['Enabled'] = true
  end
  data = <<-DATA
  <CreateInternetServiceRequest xml:lang="en" xmlns="urn:tmrk:vCloudExpressExtensions-1.6" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Name>#{name}</Name>
    <Protocol>#{protocol.upcase}</Protocol>
    <Port>#{port}</Port>
    <Enabled>#{options['Enabled']}</Enabled>
    <Description>#{options['Description']}</Description>
    </CreateInternetServiceRequest>
    DATA
  request(
    :body     => data,
    :expects  => 200,
    :headers  => {'Content-Type' => 'application/xml'},
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::InternetService.new,
    :path     => "api/extensions/v1.6/publicIp/#{ip_id}/internetServices",
    :override_path => true
  )
end

#add_node_service(service_id, ip, name, port, options = {}) ⇒ Object

Reserve requested resources and deploy vApp

Parameters

  • service_id<~String> - Id of service to add node to

  • ip<~String> - Private ip of server to add to node

  • name<~String> - Name of service

  • port<~Integer> - Port of service

  • options<~Hash>:

    • Enabled<~Boolean>: defaults to true

    • Description<~String>: optional description

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/terremark/requests/shared/add_node_service.rb', line 28

def add_node_service(service_id, ip, name, port, options = {})
  unless options.key?('Enabled')
    options['Enabled'] = true
  end

  data = <<-DATA
        <CreateNodeServiceRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:tmrk:vCloudExpressExtensions-1.6"><IpAddress>#{ip}</IpAddress><Name>#{name}</Name><Port>#{port}</Port><Enabled>#{options['Enabled']}</Enabled><Description>#{options['Description']}</Description></CreateNodeServiceRequest>
  DATA
  response = request(
    :body     => data,
    :expects  => 200,
    :headers  => {'Content-Type' => 'application/vnd.tmrk.vCloud.nodeService+xml'},
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::NodeService.new,
    :path     => "api/extensions/v1.6/internetService/#{service_id}/nodeServices",
    :override_path => true
  )

  response
end

#addresses(options = {}) ⇒ Object



11
12
13
# File 'lib/fog/terremark/models/shared/addresses.rb', line 11

def addresses(options = {})
  Fog::Terremark::Shared::Addresses.new(options.merge(:service => self))
end

#configure_vapp(vapp_id, vapp_name, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/terremark/requests/shared/configure_vapp.rb', line 6

def configure_vapp(vapp_id, vapp_name, options = {})
items = ""
vapp_uri = [@host, @path, "vApp", vapp_id.to_s].join("/")

if options['vcpus']
  vcpu_item = <<-DATA
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"> <InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{options['vcpus']}</VirtualQuantity></Item>
DATA
  items << vcpu_item
end

if options['memory']
  memory_item = <<-DATA
<Item xmlns="http://schemas.dmtf.org/ovf/envelope/1"><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType>38<VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{options['memory']}</VirtualQuantity></Item>
DATA
  items << memory_item
end
#Default root disk
virtual_disk_item = <<-DATA
<Item>
<AddressOnParent xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">0</AddressOnParent> <HostResource xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1048576</HostResource><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1048576</VirtualQuantity></Item>
DATA
items << virtual_disk_item
#Additional disks
if options['virtual_disks']
  for disk in options['virtual_disks']
    actual_size = disk.to_i * 1024 * 1024
    virtual_disk_item = <<-DATA
<Item>
<AddressOnParent xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">-1</AddressOnParent><HostResource xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{actual_size}</HostResource><InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">9</InstanceID><ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">17</ResourceType><VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{actual_size}</VirtualQuantity></Item>
DATA
    items << virtual_disk_item
  end
end

data = <<-DATA
<VApp href="#{vapp_uri}" type="application/vnd.vmware.vcloud.vApp+xml" name="#{vapp_name}" status="2" size="10485760" xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<VirtualHardwareSection xmlns="http://schemas.dmtf.org/ovf/envelope/1"><Info>Virtual Hardware</Info>#{items}
</VirtualHardwareSection>
</VApp>
DATA

  request(
    :body => data,
    :expects => 202,
    :headers => { 'Content-Type' => 'application/vnd.vmware.vCloud.vApp+xml' },
    :method => 'PUT',
    :path => "vapp/#{vapp_id}"
  )
end

#create_internet_service(vdc_id, name, protocol, port, options = {}) ⇒ Object

Reserve requested resources and deploy vApp

Parameters

  • vdc_id<~Integer> - Id of vDc to add internet service to

  • name<~String> - Name of service

  • protocol<~String> - Protocol of service

  • port<~Integer> - Port of service

  • options<~Hash>:

    • Enabled<~Boolean>: defaults to true

    • Description<~String>: optional description

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/terremark/requests/shared/create_internet_service.rb', line 30

def create_internet_service(vdc_id, name, protocol, port, options = {})
  unless options.key?('Enabled')
    options['Enabled'] = true
  end
  #Sample: "https://services.vcloudexpress.terremark.com/api/extensions/v1.6/vdc/3142/internetServices"
  path = vdcs.get(vdc_id).links.find { |item| item['name'] == 'Internet Services'}['href'].split(@host)[1]
  data = <<-DATA
  <CreateInternetServiceRequest xml:lang="en" xmlns="urn:tmrk:vCloudExpressExtensions-1.6" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Name>#{name}</Name>
    <Protocol>#{protocol.upcase}</Protocol>
    <Port>#{port}</Port>
    <Enabled>#{options['Enabled']}</Enabled>
    <Description>#{options['Description']}</Description>
    </CreateInternetServiceRequest>
    DATA
  response = request(
    :body     => data,
    :expects  => 200,
    :headers  => {'Content-Type' => 'application/vnd.tmrk.vCloud.internetService+xml'},
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::InternetService.new,
	    :path     => path,
    :override_path => true
  )
  response
end

#delete_internet_service(internet_service_id) ⇒ Object

Destroy an internet service

Parameters

  • internet_service_id<~Integer> - Id of service to destroy



10
11
12
13
14
15
16
17
# File 'lib/fog/terremark/requests/shared/delete_internet_service.rb', line 10

def delete_internet_service(internet_service_id)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "api/extensions/v1.6/internetService/#{internet_service_id}",
    :override_path => true
  )
end

#delete_node_service(node_service_id) ⇒ Object

Destroy a node

Parameters

  • node_service_id<~Integer> - Id of node to destroy



10
11
12
13
14
15
16
17
# File 'lib/fog/terremark/requests/shared/delete_node_service.rb', line 10

def delete_node_service(node_service_id)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "api/extensions/v1.6/nodeService/#{node_service_id}",
    :override_path => true
  )
end

#delete_public_ip(public_ip_id) ⇒ Object

Destroy a public ip

Parameters

  • public_ip_id<~Integer> - Id of public ip to destroy



10
11
12
13
14
15
16
17
# File 'lib/fog/terremark/requests/shared/delete_public_ip.rb', line 10

def delete_public_ip(public_ip_id)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "api/extensions/v1.6/publicIp/#{public_ip_id}",
    :override_path => true
  )
end

#delete_vapp(vapp_id) ⇒ Object

Destroy a vapp

Parameters

  • vapp_id<~Integer> - Id of vapp to destroy



10
11
12
13
14
15
16
# File 'lib/fog/terremark/requests/shared/delete_vapp.rb', line 10

def delete_vapp(vapp_id)
  request(
    :expects  => 202,
    :method   => 'DELETE',
    :path     => "vApp/#{vapp_id}"
  )
end

#deploy_vapp(vapp_id) ⇒ Object

Reserve requested resources and deploy vApp

Parameters

  • vapp_id<~Integer> - Id of vApp to deploy

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/deploy_vapp.rb', line 22

def deploy_vapp(vapp_id)
  request(
    :expects  => 202,
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::Task.new,
    :path     => "vApp/#{vapp_id}/action/deploy"
  )
end

#get_catalog(vdc_id) ⇒ Object

Get details of a catalog

Parameters

  • vdc_id<~Integer> - Id of vdc to view catalog for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘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



19
20
21
22
23
24
25
26
# File 'lib/fog/terremark/requests/shared/get_catalog.rb', line 19

def get_catalog(vdc_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetCatalog.new,
    :path     => "vdc/#{vdc_id}/catalog"
  )
end

#get_catalog_item(catalog_item_id) ⇒ Object

  • ‘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
    


22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/get_catalog_item.rb', line 22

def get_catalog_item(catalog_item_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetCatalogItem.new,
    :path     => "catalogItem/#{catalog_item_id}"
  )
end

#get_internet_services(vdc_id) ⇒ Object

Get a list of all internet services for a vdc

Parameters

  • vdc_id<~Integer> - Id of vDc to get list of internet services for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘InternetServices’<~Array>

        • ‘id’<~String> => id of the internet service

        • ‘name’<~String> => name of service

        • ‘PublicIPAddress’<~Hash>

        • ‘Id’<~String> => id of the public IP

        • ‘name’<~String> => actual ip address



22
23
24
25
26
27
28
29
30
# File 'lib/fog/terremark/requests/shared/get_internet_services.rb', line 22

def get_internet_services(vdc_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetInternetServices.new,
    :path     => "api/extensions/v1.6/vdc/#{vdc_id}/internetServices",
    :override_path => true
  )
end

#get_keys_list(organization_id) ⇒ Object

Get list of SSH keys for an organization

Parameters

  • organization_id<~Integer> - Id of organization to lookup

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘description’<~String> - Description of organization

      • ‘links’<~Array> - An array of links to entities in the organization

        • ‘href’<~String> - location of link

        • ‘name’<~String> - name of link

        • ‘rel’<~String> - action to perform

        • ‘type’<~String> - type of link



21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/terremark/requests/shared/get_keys_list.rb', line 21

def get_keys_list(organization_id)
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetKeysList.new,
    :path     => "api/extensions/v1.6/org/#{organization_id}/keys",
    :override_path => true
  )
  response
end

#get_network(network_id) ⇒ Object

Get details for a Network

Parameters

  • network_id<~Integer> - Id of the network to look up

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    FIXME



14
15
16
17
18
19
20
21
# File 'lib/fog/terremark/requests/shared/get_network.rb', line 14

def get_network(network_id)
 request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::Network.new,
    :path     => "network/#{network_id}"
  )
end

#get_network_ips(network_id) ⇒ Object

Get details for a Network

Parameters

  • network_id<~Integer> - Id of the network to look up

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    FIXME



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/terremark/requests/shared/get_network_ips.rb', line 14

def get_network_ips(network_id)
  opts =  {
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetNetworkIps.new,
    :path     => "network/#{network_id}/ipAddresses"
  }
  if self.is_a?(Fog::Terremark::Ecloud::Real)
    opts[:path] = "/extensions/network/#{network_id}/ips"
  end
  request(opts)
end

#get_node_services(service_id) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/fog/terremark/requests/shared/get_node_services.rb', line 17

def get_node_services(service_id)
   request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetNodeServices.new,
    :path     => "api/extensions/v1.6/internetService/#{service_id}/nodeServices",
    :override_path => true
  )
end

#get_organization(organization_id) ⇒ Object

Get details of an organization

Parameters

  • organization_id<~Integer> - Id of organization to lookup

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘description’<~String> - Description of organization

      • ‘links’<~Array> - An array of links to entities in the organization

        • ‘href’<~String> - location of link

        • ‘name’<~String> - name of link

        • ‘rel’<~String> - action to perform

        • ‘type’<~String> - type of link

      • ‘name’<~String> - Name of organization



20
21
22
23
24
25
26
27
28
# File 'lib/fog/terremark/requests/shared/get_organization.rb', line 20

def get_organization(organization_id)
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetOrganization.new,
    :path     => "org/#{organization_id}"
  )
  response
end

#get_organizationsObject

Get list of organizations

Returns

  • response<~Excon::Response>:

    • body<~Array>:

      • ‘description’<~String> - Description of organization

      • ‘links’<~Array> - An array of links to entities in the organization

      • ‘name’<~String> - Name of organization



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/terremark/requests/shared/get_organizations.rb', line 13

def get_organizations
  request({
    :expects  => 200,
    :headers  => {
      'Authorization' => "Basic #{Base64.encode64("#{@terremark_username}:#{@terremark_password}").chomp!}",
      # Terremark said they're going to remove passing in the Content-Type to login in a future release
      'Content-Type'  => "application/vnd.vmware.vcloud.orgList+xml"
    },
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::GetOrganizations.new,
    :path     => 'login'
  })
end

#get_public_ip(public_ip_id) ⇒ Object

Get details for a public ip

Parameters

  • public_ip_id<~Integer> - Id of public ip to look up

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘PublicIpAddresses’<~Array>

        • ‘href’<~String> - linke to item

        • ‘name’<~String> - name of item



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/terremark/requests/shared/get_public_ip.rb', line 16

def get_public_ip(public_ip_id)
  opts = {
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::PublicIp.new,
    :path     => "publicIps/#{public_ip_id}"
  }
  if self.class == Fog::Terremark::Ecloud::Real
    opts[:path] = "extensions/publicIp/#{public_ip_id}"
  end
  request(opts)
end

#get_public_ips(vdc_id) ⇒ Object

Get list of public ips

Parameters

  • vdc_id<~Integer> - Id of vdc to find public ips for

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘PublicIpAddresses’<~Array>

        • ‘href’<~String> - link to item

        • ‘name’<~String> - name of item



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/terremark/requests/shared/get_public_ips.rb', line 16

def get_public_ips(vdc_id)
  opts = {
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetPublicIps.new,
    :path     => "vdc/#{vdc_id}/publicIps"
  }
  if self.class == Fog::Terremark::Ecloud::Real
    opts[:path] = "extensions/vdc/#{vdc_id}/publicIps"
  end
  request(opts)
end

#get_task(task_id) ⇒ Object

Get details of a task

Parameters

  • task_id<~Integer> - Id of task to lookup

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner

      • ‘Result’<~String> -

        • ‘href’<~String> - href of result

        • ‘name’<~String> - name of result

        • ‘type’<~String> - type of result



26
27
28
29
30
31
32
33
# File 'lib/fog/terremark/requests/shared/get_task.rb', line 26

def get_task(task_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::Task.new,
    :path     => "task/#{task_id}"
  )
end

#get_tasks_list(tasks_list_id) ⇒ Object

Get list of tasks

Parameters

  • tasks_list_id<~Integer> - Id of tasks lists to view

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘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



19
20
21
22
23
24
25
26
# File 'lib/fog/terremark/requests/shared/get_tasks_list.rb', line 19

def get_tasks_list(tasks_list_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetTasksList.new,
    :path     => "tasksList/#{tasks_list_id}"
  )
end

#get_vapp(vapp_id) ⇒ Object

  • ‘endTime’<~String> - endTime of task

    * 'href'<~String> - link to task
    * 'startTime'<~String> - startTime of task
    * 'status'<~String> - status of task
    * 'type'<~String> - type of task
    * 'Owner'<~String> -
      * 'href'<~String> - href of owner
      * 'name'<~String> - name of owner
      * 'type'<~String> - type of owner
    * 'Result'<~String> -
      * 'href'<~String> - href of result
      * 'name'<~String> - name of result
      * 'type'<~String> - type of result
    


29
30
31
32
33
34
35
36
# File 'lib/fog/terremark/requests/shared/get_vapp.rb', line 29

def get_vapp(vapp_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::Vapp.new,
    :path     => "vapp/#{vapp_id}"
  )
end

#get_vapp_template(vapp_template_id) ⇒ Object

  • ‘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
    


22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/get_vapp_template.rb', line 22

def get_vapp_template(vapp_template_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetVappTemplate.new,
    :path     => "vAppTemplate/#{vapp_template_id}"
  )
end

#get_vdc(vdc_id) ⇒ Object

  • ‘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
    


22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/get_vdc.rb', line 22

def get_vdc(vdc_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :parser   => Fog::Parsers::Terremark::Shared::GetVdc.new,
    :path     => "vdc/#{vdc_id}"
  )
end

#images(options = {}) ⇒ Object



14
15
16
# File 'lib/fog/terremark/models/shared/images.rb', line 14

def images(options = {})
  Fog::Terremark::Shared::Images.new(options.merge(:service => self))
end

#instantiate_vapp_template(name, vapp_template, options = {}) ⇒ Object

Instatiate a vapp template

Parameters

  • name<~String>: Name of the resulting vapp .. must start with letter, up to 15 chars alphanumeric.

  • options<~Hash>:

  • 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

  • vapp_template<~String>: id of the vapp template to be instantiated

Returns

  • response<~Excon::Response>:

  • body<~Hash>:

  • ‘Links;<~Array> (e.g. up to vdc)

  • ‘href’<~String> Link to the resulting vapp

  • ‘name’<~String> - name of item

  • ‘type’<~String> - type of item

  • ‘status’<~String> - 0(pending) –> 2(off) –>4(on)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/fog/terremark/requests/shared/instantiate_vapp_template.rb', line 21

def instantiate_vapp_template(name, vapp_template, options = {})
  unless name.length < 15
    raise ArgumentError.new('Name must be fewer than 15 characters')
  end
  unless vapp_template
    raise ArgumentError.new("vApp Image Template is a compulsary parameter")
  end
  options['ssh_key_fingerprint'] ||= default_ssh_key["FingerPrint"]
  options['cpus'] ||= 1
  options['memory'] ||= 512
  options['network_id'] ||= default_network_id
  options['vdc_id'] ||= default_vdc_id
  options['primary_dns'] ||= '208.67.222.222'
  options['secondary_dns'] ||= '208.67.220.220'

  data = <<-DATA
<?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">
  <VAppTemplate href="#{@scheme}://#{@host}/#{@path}/vAppTemplate/#{vapp_template}" />
  <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">
    <Property xmlns="http://schemas.dmtf.org/ovf/envelope/1" ovf:key="primaryDNS" ovf:value="#{options['primary_dns']}" />
    <Property xmlns="http://schemas.dmtf.org/ovf/envelope/1" ovf:key="secondaryDNS" ovf:value="#{options['secondary_dns']}" />
    <Property xmlns="http://schemas.dmtf.org/ovf/envelope/1" ovf:key="sshKeyFingerprint" ovf:value="#{options['ssh_key_fingerprint']}" />
    </ProductSection>
    <VirtualHardwareSection xmlns:q1="http://www.vmware.com/vcloud/v0.8">
      <Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
<InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">1</InstanceID>
<ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">3</ResourceType>
<VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{options['cpus']}</VirtualQuantity>
      </Item>
      <Item xmlns="http://schemas.dmtf.org/ovf/envelope/1">
<InstanceID xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">2</InstanceID>
<ResourceType xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">4</ResourceType>
<VirtualQuantity xmlns="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData">#{options['memory']}</VirtualQuantity>
      </Item>
    </VirtualHardwareSection>
    <NetworkConfigSection>
      <NetworkConfig>
<NetworkAssociation href="#{@scheme}://#{@host}/#{@path}/network/#{options['network_id']}"/>
      </NetworkConfig>
    </NetworkConfigSection>
  </InstantiationParams>
</InstantiateVAppTemplateParams>
DATA

  request(
    :body => data,
    :expects => 200,
    :headers => { 'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml' },
    :method => 'POST',
    :parser => Fog::Parsers::Terremark::Shared::InstantiateVappTemplate.new,
    :path => "vdc/#{options['vdc_id']}/action/instantiatevAppTemplate"
  )
end

#internetservices(options = {}) ⇒ Object



14
15
16
# File 'lib/fog/terremark/models/shared/internetservices.rb', line 14

def internetservices(options = {})
  Fog::Terremark::Shared::InternetServices.new(options.merge(:service => self))
end

#networks(options = {}) ⇒ Object



11
12
13
# File 'lib/fog/terremark/models/shared/networks.rb', line 11

def networks(options = {})
  Fog::Terremark::Shared::Networks.new(options.merge(:service => self))
end

#nodeservices(options = {}) ⇒ Object



14
15
16
# File 'lib/fog/terremark/models/shared/nodeservices.rb', line 14

def nodeservices(options = {})
  Fog::Terremark::Shared::NodeServices.new(options.merge(:service => self))
end

#power_off(vapp_id) ⇒ Object

Power off a vapp

Parameters

  • vapp_id<~Integer> - Id of vapp to power off

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/power_off.rb', line 22

def power_off(vapp_id)
  request(
    :expects  => 202,
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::Task.new,
    :path     => "vApp/#{vapp_id}/power/action/powerOff"
  )
end

#power_on(vapp_id) ⇒ Object

Power on a vapp

Parameters

  • vapp_id<~Integer> - Id of vapp to power on

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/power_on.rb', line 22

def power_on(vapp_id)
  request(
    :expects  => 202,
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::Task.new,
    :path     => "vApp/#{vapp_id}/power/action/powerOn"
  )
end

#power_reset(vapp_id) ⇒ Object

Reset a vapp

Parameters

  • vapp_id<~Integer> - Id of vapp to reset

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • ‘endTime’<~String> - endTime of task

      • ‘href’<~String> - link to task

      • ‘startTime’<~String> - startTime of task

      • ‘status’<~String> - status of task

      • ‘type’<~String> - type of task

      • ‘Owner’<~String> -

        • ‘href’<~String> - href of owner

        • ‘name’<~String> - name of owner

        • ‘type’<~String> - type of owner



22
23
24
25
26
27
28
29
# File 'lib/fog/terremark/requests/shared/power_reset.rb', line 22

def power_reset(vapp_id)
  request(
    :expects  => 202,
    :method   => 'POST',
    :parser   => Fog::Parsers::Terremark::Shared::Task.new,
    :path     => "vApp/#{vapp_id}/power/action/reset"
  )
end

#power_shutdown(vapp_id) ⇒ Object

Shutdown a vapp

Parameters

  • vapp_id<~Integer> - Id of vapp to shutdown

Returns

Nothing



12
13
14
15
16
17
18
# File 'lib/fog/terremark/requests/shared/power_shutdown.rb', line 12

def power_shutdown(vapp_id)
  request(
    :expects  => 204,
    :method   => 'POST',
    :path     => "vApp/#{vapp_id}/power/action/shutdown"
  )
end

#servers(options = {}) ⇒ Object



14
15
16
# File 'lib/fog/terremark/models/shared/servers.rb', line 14

def servers(options = {})
  Fog::Terremark::Shared::Servers.new(options.merge(:service => self))
end

#tasksObject



14
15
16
# File 'lib/fog/terremark/models/shared/tasks.rb', line 14

def tasks
  Fog::Terremark::Shared::Tasks.new(:service => self)
end

#vdcs(options = {}) ⇒ Object



11
12
13
# File 'lib/fog/terremark/models/shared/vdcs.rb', line 11

def vdcs(options = {})
  Fog::Terremark::Shared::Vdcs.new(options.merge(:service => self))
end