class Fog::Compute::ProfitBricks::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/profitbricks/compute.rb, line 71
def initialize(options={})
  @profitbricks_username = options[:profitbricks_username]
  @profitbricks_password = options[:profitbricks_password]
  @profitbricks_url      = options[:profitbricks_url] ||
                           "https://api.profitbricks.com/#{API_VERSION}"

  @connection = Fog::XML::Connection.new(@profitbricks_url, false)
end

Public Instance Methods

clear_data_center(data_center_id) click to toggle source

Clear all objects within a virtual data center

Parameters

  • dataCenterId<~String> - Required, UUID of virtual data center

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • clearDataCenterResponse<~Hash>:

      • requestId<~String> - ID of request

      • dataCenterId<~String> - UUID of virtual data center

      • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/clear_data_center.rb, line 21
def clear_data_center(data_center_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope {
    |xml| xml[:ws].clearDataCenter {
      xml.dataCenterId(data_center_id)
    }
  }

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::ClearDataCenter.new
  )
end
connect_storage_to_server(storage_id, server_id, options={}) click to toggle source

Connect virtual storage

Parameters

  • storageId<~String> - Required, UUID of virtual storage

  • serverId<~String> - Required,

  • options<~Hash>:

    • busType<~String> - Optional, VIRTIO, IDE

    • deviceNumber<~Integer> - Optional,

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • connectStorageToServerResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/connect_storage_to_server.rb, line 25
def connect_storage_to_server(storage_id, server_id, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].connectStorageToServer {
        xml.request { 
          xml.storageId(storage_id)
          xml.serverId(server_id)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::ConnectStorageToServer.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
create_data_center(data_center_name='', location='') click to toggle source

Create a new virtual data center

Parameters

dataCenterName<~String> - Name of the new virtual data center
location<~String> - Location to create the new data center ("de/fkb", "de/fra", or "us/las")

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • createDataCenterResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

        • location<~String> - Location of virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/create_data_center.rb, line 23
def create_data_center(data_center_name='', location='')
    soap_envelope = Fog::ProfitBricks.construct_envelope {
        |xml| xml[:ws].createDataCenter {
        xml.request {
            xml.dataCenterName(data_center_name)
            xml.location(location)
        }
    }
}

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
            Fog::Parsers::Compute::ProfitBricks::CreateDataCenter.new
    )
end
create_flavor(flavor_name, cores, ram) click to toggle source

Not a real API method; will only return flavor object.

# File lib/fog/profitbricks/requests/compute/create_flavor.rb, line 6
def create_flavor(flavor_name, cores, ram)
    response        = Excon::Response.new
    response.status = 200
    response.body   = {
      'createFlavorResponse' => {
          'id'    => Fog::UUID.uuid,
          'name'  => flavor_name,
          'cores' => cores,
          'ram'   => ram,
      }
    }
    response
end
create_nic(server_id, lan_id, options={}) click to toggle source

Create new virtual network interface

Parameters

  • serverId<~String> - Required,

  • lanId - Required,

  • options<~Hash>:

    • nicName<~String> - Optional, name of the new virtual network interface

    • ip<~String> - Optional,

    • dhcpActive<~String> - Optional,

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • createNicResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

        • nicId<~String> - UUID of the new virtual network interface

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/create_nic.rb, line 27
def create_nic(server_id, lan_id, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].createNic {
        xml.request {
          xml.serverId(server_id)
          xml.lanId(lan_id)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::CreateNic.new
    )
end
create_server(data_center_id, cores, ram, options={}) click to toggle source

Create new virtual server

Parameters

  • dataCenterId<~String> - Required, UUID of virtual data center

  • cores<~Integer> - Required, number of CPU cores allocated to virtual server

  • ram<~Integer> - Required, amount of memory in GB allocated to virtual server

  • options<~Hash>:

    • serverName<~String> - Optional, name of the new virtual network interface

    • bootFromStorageId<~String> - Optional, defines an existing storage device ID to be set as boot device of the server

    • bootFromImageId<~<String> - Optional, defines an existing CD-ROM/DVD image ID to be set as boot device of the server

    • internetAccess<~Boolean> - Optional, set to TRUE to connect the server to the Internet via the specified LAN ID

    • lanId<~String> - Optional, connects the server to the specified LAN ID

    • osType<~String> - Optional, UNKNOWN, WINDOWS, LINUX, OTHER

    • availabilityZone<~String> - Optional, AUTO, ZONE_1, ZONE_2

    • cpuHotPlug<~Boolean> - Optional, set the server CPU Hot-Plug capability

    • ramHotPlug<~Boolean> - Optional, set the server RAM Hot-Plug capability

    • nicHotPlug<~Boolean> - Optional, set the server NIC Hot-Plug capability

    • nicHotUnPlug<~Boolean> - Optional, set the server NIC Hot-UnPlug capability

    • discVirtioHotPlug<~Boolean> - Optional, set the server capabilities to hotplug storages which are connected through VirtIO bustypeSet

    • discVirtioHotUnPlug<~Boolean> - Optional, set the server capabilities to hotUnplug storages which are connected through VirtIO bustypeSet

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • createServerResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

        • serverId<~String> - UUID of the new virtual server

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/create_server.rb, line 38
def create_server(data_center_id, cores, ram, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].createServer {
        xml.request {
          xml.dataCenterId(data_center_id)
          xml.cores(cores)
          xml.ram(ram)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::CreateServer.new
    )
end
create_storage(data_center_id, size, options={}) click to toggle source

Create new virtual storage

Parameters

  • dataCenterId<~String> - Required, UUID of virtual data center

  • size<~Integer> - Required, size of virtual storage

  • options<~Hash>:

    • storageName<~String> - Optional, name of the new virtual storage

    • mountImageId<~String> - Optional, UUID of image

    • profitBricksImagePassword<~String> - Optional,

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • createStorageResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

        • storageId<~String> - UUID of the new virtual storage

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/create_storage.rb, line 27
def create_storage(data_center_id, size, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].createStorage {
        xml.request {
          xml.dataCenterId(data_center_id)
          xml.size(size)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::CreateStorage.new
    )
end
delete_data_center(data_center_id) click to toggle source

Delete virtual data center

Parameters

  • dataCenterId<~String> - UUID of the virtual data center

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • deleteDataCenterResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/delete_data_center.rb, line 21
def delete_data_center(data_center_id)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].deleteDataCenter {
        xml.dataCenterId(data_center_id)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::DeleteDataCenter.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
delete_nic(nic_id) click to toggle source

Delete virtual network interface

Parameters

  • nicId<~String> - UUID of the virtual network interface

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • deleteNicResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/delete_nic.rb, line 21
def delete_nic(nic_id)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].deleteNic {
        xml.nicId(nic_id)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::DeleteNic.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
delete_server(server_id) click to toggle source

Delete virtual server

Parameters

  • serverId<~String> - UUID of the virtual server

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • deleteServerResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/delete_server.rb, line 21
def delete_server(server_id)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].deleteServer {
        xml.serverId(server_id)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::DeleteServer.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
delete_storage(storage_id) click to toggle source

Delete a virtual storage

Parameters

  • storageId<~String> -

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • deleteStorageResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/delete_storage.rb, line 21
def delete_storage(storage_id)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].deleteStorage {
        xml.storageId(storage_id)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::DeleteStorage.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
disconnect_storage_from_server(storage_id, server_id) click to toggle source

Disconnect virtual storage

Parameters

  • serverId<~String> - UUID of virtual server

  • storageId<~String> - UUID of virtual storage

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • disconnectStorageToServerResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/disconnect_storage_from_server.rb, line 22
def disconnect_storage_from_server(storage_id, server_id)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].disconnectStorageFromServer {
          xml.serverId(server_id)
          xml.storageId(storage_id)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::DisconnectStorageFromServer.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
get_all_data_centers() click to toggle source
# File lib/fog/profitbricks/requests/compute/get_all_data_centers.rb, line 6
def get_all_data_centers
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].getAllDataCenters
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetAllDataCenters.new
  )
end
get_all_flavors() click to toggle source
# File lib/fog/profitbricks/requests/compute/get_all_flavors.rb, line 5
def get_all_flavors()
    response        = Excon::Response.new
    response.status = 200
    response.body   = {
        'getAllFlavorsResponse' => [
            {
                'flavorId'   => '00db4c8f-5e83-49b0-a70b-ac4aad786163',
                'flavorName' => 'Micro',
                'ram'        => 1024,
                'cores'      => 1
            },
            {
                'flavorId'   => 'dc64957b-be9d-431e-91cd-9e217f94d3de',
                'flavorName' => 'Small',
                'ram'        => 2048,
                'cores'      => 1
            },
            {
                'flavorId'   => 'b37d000e-b347-4592-b572-df13ef8f68e1',
                'flavorName' => 'Medium',
                'ram'        => 4096,
                'cores'      => 2
            },
            {
                'flavorId'   => 'a5a4389f-54b6-4f47-b6e8-1c5c55976b94',
                'flavorName' => 'Large',
                'ram'        => 7168,
                'cores'      => 4
            },
            {
                'flavorId'   => '0052db40-f1dd-4ecf-a711-5980081b7059',
                'flavorName' => 'Extra Large',
                'ram'        => 14336,
                'cores'      => 8
            },
            {
                'flavorId'   => '8b2b835d-be09-48cf-aae2-7e35aafe92d6',
                'flavorName' => 'Memory Intensive Small',
                'ram'        => 16384,
                'cores'      => 2
            },
            {
                'flavorId'   => '45c28f8b-6a67-4f69-8c94-231d371da2b6',
                'flavorName' => 'Memory Intensive Medium',
                'ram'        => 28672,
                'cores'      => 4
            },
            {
                'flavorId'    => '1d22436d-d958-4151-b144-43a8e180c4c4',
                'flavorName'  => 'Memory Intensive Large',
                'ram'         => 57344,
                'cores'       => 8
            },
        ]
    }
    response
end
get_all_images() click to toggle source

Displays a list of all available images.

Parameters

  • N/A

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • getAllImagesResponse<~Hash>:

        • imageId<~String> - Identifer of the image

        • imageName<~String> - Name of the image

        • imageSize<~Integer> - Size of the image

        • imageType<~String> - Image type HDD or CD-ROM/DVD (ISO) image

        • writeable<~String> - Image is writable (TRUE/FALSE)

        • bootable<~String> - Image is bootable

        • cpuHotplug<~String> -Image supports CPU Hot-Plugging

        • cpuHotUnplug<~String> -

        • ramHotPlug<~String> - Image supports memory Hot-Plugging

        • ramHotUnPlug<~String> -

        • discVirtioHotPlug<~String> -

        • discVirtioHotUnplug<~String> -

        • nicHotPlug<~String> -

        • nicHotUnplug<~String> -

        • serverIds<~String> - List all servers by ID on which the image is used

        • location<~String> - Location where the image has been uploaded

        • osType<~String> - OS type of an image (WINDOWS, LINUX, OTHER, UNKNOWN)

        • public<~String> - Shows if image is publicly available or private

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_all_images.rb, line 36
def get_all_images()
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].getAllImages
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  =>
            Fog::Parsers::Compute::ProfitBricks::GetAllImages.new
    )
end
get_all_locations(options={}) click to toggle source
# File lib/fog/profitbricks/requests/compute/get_all_locations.rb, line 5
def get_all_locations(options={})
    response        = Excon::Response.new
    response.status = 200
    response.body   = {
        'getAllLocationsResponse' => [
            {
                'locationId'   => 'c0420cc0-90e8-4f4b-8860-df0a07d18047',
                'locationName' => 'de/fkb',
                'country'      => 'DEU'
            },
            {
                'locationId'   => '68c4099a-d9d8-4683-bdc2-12789aacfa2a',
                'locationName' => 'de/fra',
                'country'      => 'DEU'
            },
            {
                'locationId'   => 'e102ba74-6764-47f3-8896-246141da8ada',
                'locationName' => 'us/las',
                'country'      => 'USA'
            }
        ]
    }
    response
end
get_all_nic() click to toggle source

Returns all virtual NICs

Parameters

  • N/A

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • getAllNicResponse<~Hash>:

        • nicId<~String> - UUID of the network interface

        • nicName<~String> - Name of the network interface

        • lanId<~Integer> -

        • internetAccess<~Boolean> -

        • serverId<~String> -

        • ips<~String> -

        • macAddress<~String> -

        • firewall<~Hash>:

        • dhcpActive<~Boolean> -

        • gatewayIp<~String> -

        • provisioningState<~String> - INACTIVE, INPROCESS, AVAILABLE, DELETED, ERROR

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_all_nic.rb, line 30
def get_all_nic
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].getAllNic
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::GetAllNic.new
    )
end
get_all_servers() click to toggle source

Retrieve list of virtual servers

Parameters

  • N/A

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • getServerResponse<~Array>:

      • <~Hash>:

      • dataCenterId<~String> - UUID of virtual data center

      • dataCenterVersion<~Integer> - Version of the virtual data center

      • serverId<~String> - UUID of the new virtual server

      • serverName<~String> -

      • cores<~Integer> -

      • ram<~Integer> -

      • connectedStorages<~Array> -

      • nics<~Array> -

      • ips<~String> -

      • internetAccess<~Boolean> -

      • provisioningState<~String> -

      • virtualMachineState<~String> -

      • creationTime<~Time> -

      • lastModificationTime<~Time> -

      • osType<~String> - UNKNOWN, WINDOWS, LINUX, OTHER

      • availabilityZone<~String> - AUTO, ZONE_1, ZONE_2

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_all_servers.rb, line 34
def get_all_servers
  soap_envelope = Fog::ProfitBricks.construct_envelope {
    |xml| xml[:ws].getAllServers
  }

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetAllServers.new
  )
end
get_all_storages() click to toggle source

Returns all virtual storage information

Parameters

  • N/A

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • getAllStorages<~Hash>:

        • dataCenterId<~String> - UUID of the virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

        • storageId<~String> - UUID of the virtual storage

        • size<~Integer> - Size of the virtual storage in GB

        • storageName<~String> - Name of the virtual storage

        • mountImage<~Hash>:

          • imageId<~String> -

          • imageName<~String> -

        • serverIds<~String> - List of servers connected to the virtual storage by UUID

        • provisioningState<~String> - Current provisioning state of virtual storage

        • creationTime<~Time> - Time when virtual storage was created

        • lastModificationTime<~Time> - Time when the virtual storage was last modified

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_all_storages.rb, line 30
def get_all_storages
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].getAllStorages
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::GetAllStorages.new
    )
end
get_data_center(data_center_id) click to toggle source
# File lib/fog/profitbricks/requests/compute/get_data_center.rb, line 7
def get_data_center(data_center_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].getDataCenter { xml.dataCenterId(data_center_id) }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetDataCenter.new
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
get_data_center_state(data_center_id) click to toggle source
# File lib/fog/profitbricks/requests/compute/get_data_center_state.rb, line 6
def get_data_center_state(data_center_id)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].getDataCenterState {
        xml.dataCenterId(data_center_id)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::GetDataCenterState.new
    )
end
get_flavor(flavor_id) click to toggle source
# File lib/fog/profitbricks/requests/compute/get_flavor.rb, line 5
def get_flavor(flavor_id)
  response        = Excon::Response.new
  response.status = 200
  response.body   = {
    "getFlavorResponse" => [
      {
        "flavorId"   => "00db4c8f-5e83-49b0-a70b-ac4aad786163",
        "flavorName" => "Micro",
        "ram"        => 1024,
        "cores"      => 1
      },
      {
        "flavorId"   => "dc64957b-be9d-431e-91cd-9e217f94d3de",
        "flavorName" => "Small",
        "ram"        => 2048,
        "cores"      => 1
      },
      {
        "flavorId"   => "b37d000e-b347-4592-b572-df13ef8f68e1",
        "flavorName" => "Medium",
        "ram"        => 4096,
        "cores"      => 2
      },
      {
        "flavorId"   => "a5a4389f-54b6-4f47-b6e8-1c5c55976b94",
        "flavorName" => "Large",
        "ram"        => 7168,
        "cores"      => 4
      },
      {
        "flavorId"   => "0052db40-f1dd-4ecf-a711-5980081b7059",
        "flavorName" => "Extra Large",
        "ram"        => 14336,
        "cores"      => 8
      },
      {
        "flavorId"   => "8b2b835d-be09-48cf-aae2-7e35aafe92d6",
        "flavorName" => "Memory Intensive Small",
        "ram"        => 16384,
        "cores"      => 2
      },
      {
        "flavorId"   => "45c28f8b-6a67-4f69-8c94-231d371da2b6",
        "flavorName" => "Memory Intensive Medium",
        "ram"        => 28672,
        "cores"      => 4
      },
      {
        "flavorId"   => "1d22436d-d958-4151-b144-43a8e180c4c4",
        "flavorName" => "Memory Intensive Large",
        "ram"        => 57344,
        "cores"      => 8
      },
    ].find { |flavor| flavor["flavorId"] == flavor_id } || raise(Fog::Errors::NotFound)
  }
  response
end
get_image(image_id) click to toggle source

Displays a list of all available images.

Parameters

  • imageId<~String> - Name of the new virtual data center

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • getAllImagesResponse<~Hash>:

      • imageId<~String> - Identifer of the image

      • imageName<~String> - Name of the image

      • imageSize<~Integer> - Size of the image (in MB?)

      • imageType<~String> - Image type HDD or CD-ROM/DVD (ISO) image

      • writeable<~String> - Image is writable (TRUE/FALSE)

      • bootable<~String> - Image is bootable

      • cpuHotplug<~String> -Image supports CPU Hot-Plugging

      • cpuHotUnplug<~String> -

      • ramHotPlug<~String> - Image supports memory Hot-Plugging

      • ramHotUnPlug<~String> -

      • discVirtioHotPlug<~String> -

      • discVirtioHotUnplug<~String> -

      • nicHotPlug<~String> -

      • nicHotUnplug<~String> -

      • serverIds<~String> - List all servers by ID on which the image is used

      • location<~String> - Location where the image has been uploaded

      • osType<~String> - OS type of an image (WINDOWS, LINUX, OTHER, UNKNOWN)

      • public<~String> - Shows if image is publicly available or private

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_image.rb, line 36
def get_image(image_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].getImage {
      xml.imageId(image_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetImage.new
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
get_location(location_id) click to toggle source
# File lib/fog/profitbricks/requests/compute/get_location.rb, line 5
def get_location(location_id)
  response        = Excon::Response.new
  response.status = 200
  response.body   = {
    "getLocationResponse" => [
      {
        "locationId"   => "c0420cc0-90e8-4f4b-8860-df0a07d18047",
        "locationName" => "de/fkb",
        "country"      => "DEU"
      },
      {
        "locationId"   => "68c4099a-d9d8-4683-bdc2-12789aacfa2a",
        "locationName" => "de/fra",
        "country"      => "DEU"
      },
      {
        "locationId"   => "e102ba74-6764-47f3-8896-246141da8ada",
        "locationName" => "us/las",
        "country"      => "USA"
      }
    ].find { |location| location["locationId"] == location_id } || raise(Fog::Errors::NotFound)
  }
  response
end
get_nic(nic_id) click to toggle source

Return virtual NIC information

Parameters

  • N/A

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • getNicResponse<~Hash>:

      • nicId<~String> - UUID of the network interface

      • nicName<~String> - Name of the network interface

      • lanId<~Integer> -

      • internetAccess<~Boolean> -

      • serverId<~String> -

      • ips<~String> -

      • macAddress<~String> -

      • firewall<~Hash>:

      • dhcpActive<~Boolean> -

      • gatewayIp<~String> -

      • provisioningState<~String> - INACTIVE, INPROCESS, AVAILABLE, DELETED, ERROR

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_nic.rb, line 30
def get_nic(nic_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].getNic {
      xml.nicId(nic_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetNic.new
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
get_server(server_id) click to toggle source

Create new virtual server

Parameters

  • serverId<~String> - UUID of a virtual server

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • getServerResponse<~Hash>:

      • requestId<~String> - ID of request

      • dataCenterId<~String> - UUID of virtual data center

      • dataCenterVersion<~Integer> - Version of the virtual data center

      • serverId<~String> - UUID of the new virtual server

      • serverName<~String> -

      • cores<~Integer> -

      • ram<~Integer> -

      • internetAccess<~String> -

      • ips<~String> -

      • connectedStorages<~Array>:

      • bootDevice<~Integer> -

      • busType<~String> - VIRTIO|IDE

      • deviceNumber<~Integer> -

      • size<~Integer> -

      • storageId<~String> -

      • storageName<~String> -

      • nics<~Array>:

      • dataCenterId<~String> -

      • dataCenterVersion<~Integer> -

      • nicId<~String> -

      • lanId<~Integer> -

      • internetAccess<~String> -

      • serverId<~String> -

      • ips<~String> -

      • macAddress<~String> -

      • firewall<~Hash>:

        • active<~String> -

        • firewallId<~String> -

        • nicId<~String> -

        • provisioningState<~String> -

      • dhcpActive<~String> -

      • provisioningState<~String> -

      • provisioningState<~String> -

      • virtualMachineState<~String> -

      • creationTime<~Time> -

      • lastModificationTime<~Time> -

      • osType<~String> -

      • availabilityZone<~String> -

      • cpuHotPlug<~String> -

      • ramHotPlug<~String> -

      • nicHotPlug<~String> -

      • nicHotUnPlug<~String> -

      • discVirtioHotPlug<~String> -

      • discVirtioHotUnPlug<~String> -

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_server.rb, line 62
def get_server(server_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].getServer {
      xml.serverId(server_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetServer.new
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
get_storage(storage_id) click to toggle source

Returns all virtual storage information

Parameters

  • N/A

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • getStorage<~Hash>:

      • dataCenterId<~String> - UUID of the virtual data center

      • dataCenterVersion<~Integer> - Version of the virtual data center

      • storageId<~String> - UUID of the virtual storage

      • size<~Integer> - Size of the virtual storage in GB

      • storageName<~String> - Name of the virtual storage

      • mountImage<~Hash>:

      • imageId<~String> -

      • imageName<~String> -

      • serverIds<~String> - List of servers connected to the virtual storage by UUID

      • provisioningState<~String> - Current provisioning state of virtual storage

      • creationTime<~Time> - Time when virtual storage was created

      • lastModificationTime<~Time> - Time when the virtual storage was last modified

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/get_storage.rb, line 30
def get_storage(storage_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].getStorage {
      xml.storageId(storage_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::GetStorage.new
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
request(params) click to toggle source
# File lib/fog/profitbricks/compute.rb, line 80
def request(params)
  begin
    response = @connection.request(params.merge({
      :headers => {
        'Authorization' => "Basic #{auth_header}"
      }.merge!(params[:headers] || {})
    }))
  rescue Excon::Errors::Unauthorized => error
    raise error
  rescue Excon::Errors::HTTPStatusError => error
    raise error
  rescue Excon::Errors::InternalServerError => error
    raise error
  end
  response
end
reset_server(server_id) click to toggle source

Reset specified virtual server

Parameters

  • serverId<~String> - UUID of a virtual server

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • resetServerResponse<~Hash>:

      • requestId<~String> - ID of request

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/reset_server.rb, line 19
def reset_server(server_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].resetServer {
      xml.serverId(server_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml,
    :parser  => Fog::Parsers::Compute::ProfitBricks::ResetServer.new
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
set_internet_access(data_center_id, lan_id, internet_access) click to toggle source

Connect an existing NIC to a public LAN to get internet access

Parameters

  • dataCenterId<~String> -

  • lanId<~Integer> -

  • internetAccess<~Boolean> -

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • setInternetAccessResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/set_internet_access.rb, line 23
def set_internet_access(data_center_id, lan_id, internet_access)
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].setInternetAccess {
        xml.dataCenterId(data_center_id)
        xml.lanId(lan_id)
        xml.internetAccess(internet_access)
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  =>
          Fog::Parsers::Compute::ProfitBricks::SetInternetAccess.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
start_server(server_id) click to toggle source

Start specified virtual server

Parameters

  • serverId<~String> - UUID of a virtual server

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • startServerResponse<~Hash>:

      • requestId<~String> - ID of request

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/start_server.rb, line 18
def start_server(server_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].startServer {
      xml.serverId(server_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
stop_server(server_id) click to toggle source

Stop specified virtual server

Parameters

  • serverId<~String> - UUID of a virtual server

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

    • stopServerResponse<~Hash>:

      • requestId<~String> - ID of request

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/stop_server.rb, line 18
def stop_server(server_id)
  soap_envelope = Fog::ProfitBricks.construct_envelope do |xml|
    xml[:ws].stopServer {
      xml.serverId(server_id)
    }
  end

  request(
    :expects => [200],
    :method  => "POST",
    :body    => soap_envelope.to_xml
  )
rescue Excon::Errors::InternalServerError => error
  Fog::Errors::NotFound.new(error)
end
update_data_center(data_center_id, options={}) click to toggle source
# File lib/fog/profitbricks/requests/compute/update_data_center.rb, line 6
def update_data_center(data_center_id, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].updateDataCenter {
        xml.request { 
          xml.dataCenterId(data_center_id)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  => 
          Fog::Parsers::Compute::ProfitBricks::UpdateDataCenter.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
update_nic(nic_id, options={}) click to toggle source

Update a virtual NIC

Parameters

  • nicId<~String> - Required,

  • options<~Hash>:

    • lanId<~Integer> - Optional,

    • nicName<~String> - Optional, name of the new virtual network interface

    • ip<~String> - Optional,

    • dhcpActive<~Boolean> - Optional,

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • updateNicResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/update_nic.rb, line 26
def update_nic(nic_id, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].updateNic {
        xml.request { 
          xml.nicId(nic_id)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  =>
          Fog::Parsers::Compute::ProfitBricks::UpdateNic.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
update_server(server_id, options={}) click to toggle source

Update a virtual server

Parameters

  • serverId<~String> - Required, UUID of virtual server

  • options<~Hash>:

    • serverName<~String> - Optional,

    • cores<~Integer> - Optional,

    • ram<~Integer> Optional, Memory in MB

    • bootFromStorageId<~String> - Optional, UUID of boot storage

    • bootFromImageId<~String> -

    • osType<~String> - Optional, UNKNOWN, WINDOWS, LINUX, OTHER

    • availabilityZone<~String> - Optional, AUTO, ZONE_1, ZONE_2

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • updateServerResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/update_server.rb, line 29
def update_server(server_id, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].updateServer {
        xml.request { 
          xml.serverId(server_id)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  =>
          Fog::Parsers::Compute::ProfitBricks::UpdateServer.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end
update_storage(storage_id, options={}) click to toggle source

Update a virtual storage

Parameters

  • storageId<~String> - Required, UUID of the virtual storage

  • options<~Hash>:

    • size<~Integer> - Optional, size of virtual storage in GB

    • storageName<~String> - Optional,

    • mountImageId<~String> - Optional,

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • updateStorageResponse<~Hash>:

        • requestId<~String> - ID of request

        • dataCenterId<~String> - UUID of virtual data center

        • dataCenterVersion<~Integer> - Version of the virtual data center

ProfitBricks API Documentation

# File lib/fog/profitbricks/requests/compute/update_storage.rb, line 25
def update_storage(storage_id, options={})
    soap_envelope = Fog::ProfitBricks.construct_envelope {
      |xml| xml[:ws].updateStorage {
        xml.request { 
          xml.storageId(storage_id)
          options.each { |key, value| xml.send(key, value) }
        }
      }
    }

    request(
        :expects => [200],
        :method  => 'POST',
        :body    => soap_envelope.to_xml,
        :parser  =>
          Fog::Parsers::Compute::ProfitBricks::UpdateStorage.new
    )
rescue Excon::Errors::InternalServerError => error
    Fog::Errors::NotFound.new(error)
end

Private Instance Methods

auth_header() click to toggle source
# File lib/fog/profitbricks/compute.rb, line 99
def auth_header
  return Base64.encode64(
    "#{@profitbricks_username}:#{@profitbricks_password}"
  ).delete("\r\n")
end