Class: Bosh::Cloud

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud.rb

Overview

CPI - Cloud Provider Interface, used for interfacing with various IaaS APIs.

Key terms: Stemcell: template used for creating VMs (shouldn’t be powered on) VM: VM created from a stemcell with custom settings (networking and resources) Disk: volume that can be attached and detached from the VMs,

never attached to more than a single VM at one time

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Cloud

Cloud initialization

Parameters:

  • options (Hash)

    cloud options



26
27
# File 'lib/cloud.rb', line 26

def initialize(options)
end

Instance Method Details

#attach_disk(vm_id, disk_id) ⇒ void

This method returns an undefined value.

Attaches a disk

Parameters:

  • vm (String)

    vm id that was once returned by #create_vm

  • disk (String)

    disk id that was once returned by #create_disk



198
199
200
# File 'lib/cloud.rb', line 198

def attach_disk(vm_id, disk_id)
  not_implemented(:attach_disk)
end

#calculate_vm_cloud_properties(vm_properties) ⇒ Hash

Specify VM’s hardware resources can be used with #create_vm

Parameters:

  • vm_properties (Hash)

    (typically cpu, ram, ephemeral_disk_size)

Returns:

  • (Hash)

    opaque description of the VM’s configuration that



247
248
249
# File 'lib/cloud.rb', line 247

def calculate_vm_cloud_properties(vm_properties)
  not_implemented(:calculate_vm_cloud_properties)
end

#create_disk(size, cloud_properties, vm_locality) ⇒ String

Creates a disk (possibly lazily) that will be attached later to a VM. When VM locality is specified the disk will be placed near the VM so it won’t have to move when it’s attached later.

Parameters:

  • size (Integer)

    disk size in MB

  • cloud_properties (Hash)

    properties required for creating this disk specific to a CPI

  • vm_locality (String)

    vm id if known of the VM that this disk will be attached to

Returns:



180
181
182
# File 'lib/cloud.rb', line 180

def create_disk(size, cloud_properties, vm_locality)
  not_implemented(:create_disk)
end

#create_stemcell(image_path, cloud_properties) ⇒ String

Creates a stemcell

Parameters:

  • image_path (String)

    path to an opaque blob containing the stemcell image

  • cloud_properties (Hash)

    properties required for creating this template specific to a CPI

Returns:



55
56
57
# File 'lib/cloud.rb', line 55

def create_stemcell(image_path, cloud_properties)
  not_implemented(:create_stemcell)
end

#create_vm(agent_id, stemcell_id, resource_pool, networks, disk_locality, env) ⇒ String

Creates a VM - creates (and powers on) a VM from a stemcell with the proper resources and on the specified network. When disk locality is present the VM will be placed near the provided disk so it won’t have to move when the disk is attached later.

Sample networking config:

{"network_a" =>
  {
    "netmask"          => "255.255.248.0",
    "ip"               => "172.30.41.40",
    "gateway"          => "172.30.40.1",
    "dns"              => ["172.30.22.153", "172.30.22.154"],
    "cloud_properties" => {"name" => "VLAN444"}
  }
}

Sample resource pool config (CPI specific):

{
  "ram"  => 512,
  "disk" => 512,
  "cpu"  => 1
}

or similar for EC2:

{"name" => "m1.small"}

Parameters:

  • agent_id (String)

    UUID for the agent that will be used later on by the director to locate and talk to the agent

  • stemcell (String)

    stemcell id that was once returned by #create_stemcell

  • resource_pool (Hash)

    cloud specific properties describing the resources needed for this VM

  • networks (Hash)

    list of networks and their settings needed for this VM

  • disk_locality (String, Array)

    disk id(s) if known of the disk(s) that will be attached to this vm

  • env (Hash)

    environment that will be passed to this vm

Returns:



103
104
105
106
# File 'lib/cloud.rb', line 103

def create_vm(agent_id, stemcell_id, resource_pool,
              networks, disk_locality, env)
  not_implemented(:create_vm)
end

#current_vm_idString

Get the vm_id of this host

Returns:

  • (String)

    opaque id later used by other methods of the CPI



44
45
46
# File 'lib/cloud.rb', line 44

def current_vm_id
  not_implemented(:current_vm_id)
end

#delete_disk(disk_id) ⇒ void

This method returns an undefined value.

Deletes a disk Will raise an exception if the disk is attached to a VM

Parameters:

  • disk (String)

    disk id that was once returned by #create_disk



190
191
192
# File 'lib/cloud.rb', line 190

def delete_disk(disk_id)
  not_implemented(:delete_disk)
end

#delete_snapshot(snapshot_id) ⇒ void

This method returns an undefined value.

Delete a disk snapshot

Parameters:

  • snapshot_id (String)

    snapshot id to delete



213
214
215
# File 'lib/cloud.rb', line 213

def delete_snapshot(snapshot_id)
  not_implemented(:delete_snapshot)
end

#delete_stemcell(stemcell_id) ⇒ void

This method returns an undefined value.

Deletes a stemcell

Parameters:



64
65
66
# File 'lib/cloud.rb', line 64

def delete_stemcell(stemcell_id)
  not_implemented(:delete_stemcell)
end

#delete_vm(vm_id) ⇒ void

This method returns an undefined value.

Deletes a VM. If the VM has already been deleted, this call returns normally and has no effect.

Parameters:

  • vm (String)

    vm id that was once returned by #create_vm



113
114
115
# File 'lib/cloud.rb', line 113

def delete_vm(vm_id)
  not_implemented(:delete_vm)
end

#detach_disk(vm_id, disk_id) ⇒ void

This method returns an undefined value.

Detaches a disk

Parameters:

  • vm (String)

    vm id that was once returned by #create_vm

  • disk (String)

    disk id that was once returned by #create_disk



221
222
223
# File 'lib/cloud.rb', line 221

def detach_disk(vm_id, disk_id)
  not_implemented(:detach_disk)
end

#get_disks(vm_id) ⇒ array[String]

List the attached disks of the VM. other disk-related methods on the CPI

Parameters:

  • vm_id (String)

    is the CPI-standard vm_id (eg, returned from current_vm_id)

Returns:

  • (array[String])

    list of opaque disk_ids that can be used with the



229
230
231
# File 'lib/cloud.rb', line 229

def get_disks(vm_id)
  not_implemented(:get_disks)
end

#has_disk?(disk_id) ⇒ Boolean

Checks if a disk exists

Parameters:

  • disk (String)

    disk_id that was once returned by #create_disk

Returns:

  • (Boolean)

    True if the disk exists



131
132
133
# File 'lib/cloud.rb', line 131

def has_disk?(disk_id)
  not_implemented(:has_disk?)
end

#has_vm?(vm_id) ⇒ Boolean

Checks if a VM exists

Parameters:

  • vm (String)

    vm id that was once returned by #create_vm

Returns:

  • (Boolean)

    True if the vm exists



122
123
124
# File 'lib/cloud.rb', line 122

def has_vm?(vm_id)
  not_implemented(:has_vm?)
end

#infoObject

Information about cpi

Sample info response:

{"stemcell_formats" =>
  ["aws-raw", "aws-light"]
}
@return [Hash] information about cpi, currently stemcell formats, which are supported


36
37
38
# File 'lib/cloud.rb', line 36

def info
  not_implemented(:info)
end

#reboot_vm(vm_id) ⇒ void

This method returns an undefined value.

Reboots a VM

Parameters:

  • vm (String)

    vm id that was once returned by #create_vm

  • CPI (Optional, Hash)

    specific options (e.g hard/soft reboot)



141
142
143
# File 'lib/cloud.rb', line 141

def reboot_vm(vm_id)
  not_implemented(:reboot_vm)
end

#resize_disk(disk_id, new_size) ⇒ void

This method returns an undefined value.

Resizes an existing disk

Parameters:

  • disk_id (String)

    disk id

  • new_size (Integer)

    disk size in MiB



239
240
241
# File 'lib/cloud.rb', line 239

def resize_disk(disk_id, new_size)
  not_implemented(:resize_disk)
end

#set_disk_metadata(disk_id, metadata) ⇒ void

This method returns an undefined value.

Set metadata for a disk

Optional. Implement to provide more information for the IaaS.

Parameters:

  • disk_id (String)

    disk id that was once returned by #create_disk

  • metadata (Hash)

    metadata key/value pairs



165
166
167
# File 'lib/cloud.rb', line 165

def (disk_id, )
  not_implemented(:set_disk_metadata)
end

#set_vm_metadata(vm, metadata) ⇒ void

This method returns an undefined value.

Set metadata for a VM

Optional. Implement to provide more information for the IaaS.

Parameters:

  • vm (String)

    vm id that was once returned by #create_vm

  • metadata (Hash)

    metadata key/value pairs



153
154
155
# File 'lib/cloud.rb', line 153

def (vm, )
  not_implemented(:set_vm_metadata)
end

#snapshot_disk(disk_id, metadata) ⇒ String

Take snapshot of disk

Parameters:

  • disk_id (String)

    disk id of the disk to take the snapshot of

  • metadata (Hash)

    metadata key/value pairs

Returns:

  • (String)

    snapshot id



206
207
208
# File 'lib/cloud.rb', line 206

def snapshot_disk(disk_id, )
  not_implemented(:snapshot_disk)
end