Skip to content
Newer
Older
100644 180 lines (159 sloc) 5.66 KB
0ff74d1 Director copyright notice
Vadim Spivak authored
1 # Copyright (c) 2009-2012 VMware, Inc.
2
8a5599f @dougm Refactor director/cloud to vsphere_cpi gem
dougm authored
3 module Bosh; module Clouds; end; end
4
a597226 @drnic Ensure Forwardable class is loaded
drnic authored
5 require "forwardable"
6
8a5599f @dougm Refactor director/cloud to vsphere_cpi gem
dougm authored
7 require "cloud/config"
8 require "cloud/errors"
9 require "cloud/provider"
10
11 module Bosh
ecb56c3 docs
Vadim Spivak authored
12
13 ##
14 # CPI - Cloud Provider Interface, used for interfacing with various IaaS APIs.
15 #
16 # Key terms:
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
17 # Stemcell: template used for creating VMs (shouldn't be powered on)
18 # VM: VM created from a stemcell with custom settings (networking and resources)
19 # Disk: volume that can be attached and detached from the VMs,
20 # never attached to more than a single VM at one time
37822ce initial director commit (tests work)
Vadim Spivak authored
21 class Cloud
22
ecb56c3 docs
Vadim Spivak authored
23 ##
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
24 # Cloud initialization
25 #
26 # @param [Hash] options cloud options
27 def initialize(options)
28 end
29
30 ##
ecb56c3 docs
Vadim Spivak authored
31 # Creates a stemcell
32 #
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
33 # @param [String] image_path path to an opaque blob containing the stemcell image
ecb56c3 docs
Vadim Spivak authored
34 # @param [Hash] cloud_properties properties required for creating this template
35 # specific to a CPI
36 # @return [String] opaque id later used by {#create_vm} and {#delete_stemcell}
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
37 def create_stemcell(image_path, cloud_properties)
38 not_implemented(:create_stemcell)
37822ce initial director commit (tests work)
Vadim Spivak authored
39 end
40
ecb56c3 docs
Vadim Spivak authored
41 ##
42 # Deletes a stemcell
43 #
44 # @param [String] stemcell stemcell id that was once returned by {#create_stemcell}
45 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
46 def delete_stemcell(stemcell_id)
47 not_implemented(:delete_stemcell)
37822ce initial director commit (tests work)
Vadim Spivak authored
48 end
49
ecb56c3 docs
Vadim Spivak authored
50 ##
51 # Creates a VM - creates (and powers on) a VM from a stemcell with the proper resources
52 # and on the specified network. When disk locality is present the VM will be placed near
53 # the provided disk so it won't have to move when the disk is attached later.
54 #
55 # Sample networking config:
83964d4 style cleanup
Vadim Spivak authored
56 # {"network_a" =>
ecb56c3 docs
Vadim Spivak authored
57 # {
58 # "netmask" => "255.255.248.0",
59 # "ip" => "172.30.41.40",
60 # "gateway" => "172.30.40.1",
83964d4 style cleanup
Vadim Spivak authored
61 # "dns" => ["172.30.22.153", "172.30.22.154"],
62 # "cloud_properties" => {"name" => "VLAN444"}
ecb56c3 docs
Vadim Spivak authored
63 # }
64 # }
65 #
66 # Sample resource pool config (CPI specific):
67 # {
68 # "ram" => 512,
69 # "disk" => 512,
70 # "cpu" => 1
71 # }
72 # or similar for EC2:
83964d4 style cleanup
Vadim Spivak authored
73 # {"name" => "m1.small"}
ecb56c3 docs
Vadim Spivak authored
74 #
75 # @param [String] agent_id UUID for the agent that will be used later on by the director
76 # to locate and talk to the agent
77 # @param [String] stemcell stemcell id that was once returned by {#create_stemcell}
78 # @param [Hash] resource_pool cloud specific properties describing the resources needed
79 # for this VM
80 # @param [Hash] networks list of networks and their settings needed for this VM
711e75c @mahpat Problem: When selecting a cluster for a create a VM operation, we do …
mahpat authored
81 # @param [optional, String, Array] disk_locality disk id(s) if known of the disk(s) that will be
82 # attached to this vm
69a1070 and an "env" hash to resource pool
Vadim Spivak authored
83 # @param [optional, Hash] env environment that will be passed to this vm
ecb56c3 docs
Vadim Spivak authored
84 # @return [String] opaque id later used by {#configure_networks}, {#attach_disk},
85 # {#detach_disk}, and {#delete_vm}
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
86 def create_vm(agent_id, stemcell_id, resource_pool,
87 networks, disk_locality = nil, env = nil)
88 not_implemented(:create_vm)
37822ce initial director commit (tests work)
Vadim Spivak authored
89 end
90
ecb56c3 docs
Vadim Spivak authored
91 ##
92 # Deletes a VM
93 #
94 # @param [String] vm vm id that was once returned by {#create_vm}
95 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
96 def delete_vm(vm_id)
97 not_implemented(:delete_vm)
37822ce initial director commit (tests work)
Vadim Spivak authored
98 end
99
ecb56c3 docs
Vadim Spivak authored
100 ##
674ea7a BCCK can now handle un-responsive agents and unbounded instance VMs.
Woon Jung authored
101 # Reboots a VM
102 #
103 # @param [String] vm vm id that was once returned by {#create_vm}
104 # @param [Optional, Hash] CPI specific options (e.g hard/soft reboot)
105 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
106 def reboot_vm(vm_id)
107 not_implemented(:reboot_vm)
674ea7a BCCK can now handle un-responsive agents and unbounded instance VMs.
Woon Jung authored
108 end
109
110 ##
ecb56c3 docs
Vadim Spivak authored
111 # Configures networking an existing VM.
112 #
113 # @param [String] vm vm id that was once returned by {#create_vm}
114 # @param [Hash] networks list of networks and their settings needed for this VM,
115 # same as the networks argument in {#create_vm}
116 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
117 def configure_networks(vm_id, networks)
118 not_implemented(:configure_networks)
37822ce initial director commit (tests work)
Vadim Spivak authored
119 end
120
ecb56c3 docs
Vadim Spivak authored
121 ##
122 # Creates a disk (possibly lazily) that will be attached later to a VM. When
123 # VM locality is specified the disk will be placed near the VM so it won't have to move
124 # when it's attached later.
125 #
126 # @param [Integer] size disk size in MB
127 # @param [optional, String] vm_locality vm id if known of the VM that this disk will
128 # be attached to
129 # @return [String] opaque id later used by {#attach_disk}, {#detach_disk}, and {#delete_disk}
130 def create_disk(size, vm_locality = nil)
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
131 not_implemented(:create_disk)
37822ce initial director commit (tests work)
Vadim Spivak authored
132 end
133
ecb56c3 docs
Vadim Spivak authored
134 ##
135 # Deletes a disk
136 # Will raise an exception if the disk is attached to a VM
137 #
138 # @param [String] disk disk id that was once returned by {#create_disk}
139 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
140 def delete_disk(disk_id)
141 not_implemented(:delete_disk)
37822ce initial director commit (tests work)
Vadim Spivak authored
142 end
143
ecb56c3 docs
Vadim Spivak authored
144 ##
145 # Attaches a disk
146 #
147 # @param [String] vm vm id that was once returned by {#create_vm}
148 # @param [String] disk disk id that was once returned by {#create_disk}
149 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
150 def attach_disk(vm_id, disk_id)
151 not_implemented(:attach_disk)
37822ce initial director commit (tests work)
Vadim Spivak authored
152 end
153
ecb56c3 docs
Vadim Spivak authored
154 ##
155 # Detaches a disk
156 #
157 # @param [String] vm vm id that was once returned by {#create_vm}
158 # @param [String] disk disk id that was once returned by {#create_disk}
159 # @return nil
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
160 def detach_disk(vm_id, disk_id)
161 not_implemented(:detach_disk)
37822ce initial director commit (tests work)
Vadim Spivak authored
162 end
163
ecb56c3 docs
Vadim Spivak authored
164 ##
165 # Validates the deployment
166 # @api not_yet_used
37822ce initial director commit (tests work)
Vadim Spivak authored
167 def validate_deployment(old_manifest, new_manifest)
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
168 not_implemented(:validate_deployment)
169 end
170
171 private
37822ce initial director commit (tests work)
Vadim Spivak authored
172
a010ff6 @olegshaldybin First pass at AWS CPI
olegshaldybin authored
173 def not_implemented(method)
174 raise Bosh::Clouds::NotImplemented,
175 "`#{method}' is not implemented by #{self.class}"
37822ce initial director commit (tests work)
Vadim Spivak authored
176 end
177
178 end
711e75c @mahpat Problem: When selecting a cluster for a create a VM operation, we do …
mahpat authored
179 end
Something went wrong with that request. Please try again.