In this presentation, I am going to briefly talk about 'what cloud is' and highlight the various types of cloud (IaaS, PaaS, SaaS). The bulk of the talk will be about using the fog gem using IaaS. I will discuss fog concepts (collections, models, requests, services, providers) and supporting these with actual examples using fog
37. Bootstrap
1. Creates server
2. Waits for server to finish building
3. Create ROOT_USER/.ssh/authorized_keys
4. Lock password for root user
5. Create ROOT_USER/attributes.json file
6. Create ROOT_USER/metadata.json file
44. Collection Methods
all
fetch every object of that type from the
provider.
get
fetch a single object by its identity from the
provider.
create
initialize a new record locally and a remote
resource with the provider.
new
initialize a new record locally, but do not
create a remote resource with the provider.
47. Model Methods
attributes
Returns a hash containing the list of model
attributes and values.
save Saves object. (not all object support update)
reload
Updates object with latest state from
service.
ready?
Returns true if object is in a ready state and
able to perform actions.
wait_for Periodically reloads model yielding to block.
77. module
Fog
module
Compute
class
RackspaceV2
class
Images
<
Fog::Collection
def
get(image_id)
data
=
service.get_image(image_id).body['image']
new(data)
rescue
Fog::Compute::RackspaceV2::NotFound
nil
end
end
end
end
end
78. module
Fog
module
Compute
class
RackspaceV2
class
Images
<
Fog::Collection
def
get(image_id)
data
=
service.get_image(image_id).body['image']
new(data)
rescue
Fog::Compute::RackspaceV2::NotFound
nil
end
end
end
end
end
79. module
Fog
module
Compute
class
RackspaceV2
class
Real
def
get_image(image_id)
request(
:expects
=>
[200,
203],
:method
=>
'GET',
:path
=>
"images/#{image_id}"
)
end
end
end
end
80. module
Fog
module
Compute
class
RackspaceV2
class
Real
def
get_image(image_id)
request(
:expects
=>
[200,
203],
:method
=>
'GET',
:path
=>
"images/#{image_id}"
)
end
end
end
end
81. module
Fog
module
Compute
class
RackspaceV2
class
Real
def
get_image(image_id)
request(
:expects
=>
[200,
203],
:method
=>
'GET',
:path
=>
"images/#{image_id}"
)
end
end
end
end
82. module
Fog
module
Compute
class
RackspaceV2
class
Real
def
get_image(image_id)
request(
:expects
=>
[200,
203],
:method
=>
'GET',
:path
=>
"images/#{image_id}"
)
end
end
end
end
93. Images
tule fog, marya, CC BY-SA 2.0
Clouds, Daniel Boyd, CC BY 2.0
Metroid II: Return of Samus, Michel Ngilen, CC BY-SA 2.0
Lego Mindstorms Kit, Marlon J. Manrique, CC BY 2.0
CD,Visual Pharm, CC BY-SA 2.0
Public Bikes, Richard Masoner / Cyclelicious, CC BY 2.0
PRIVATE, Rupert Ganzer, CC BY 2.0
Hybrid
Sorry We Are Not Open, Alan Levine, CC BY 2.0
We are, e1ther, CC BY 2.0
94. Images (cont)
Yipwm_1b, Greg Goebel, CC BY-SA 2.0
Pause Button, GreenLantern33, CC BY-SA 2.0
3..., Cristiano Betta, CC BY-SA 2.0