diff --git a/firstapp/samples/fog/block_storage.rb b/firstapp/samples/fog/block_storage.rb
index e94ce411d..bce263931 100755
--- a/firstapp/samples/fog/block_storage.rb
+++ b/firstapp/samples/fog/block_storage.rb
@@ -1,64 +1,56 @@
#!/usr/bin/env ruby
-require 'fog'
+require 'fog/openstack'
# step-1
auth_username = "your_auth_username"
auth_password = "your_auth_password"
-auth_url = "http://controller:5000"
-project_name = "your_project_name_or_id"
+auth_url = "http://controller:5000"
+project_name = "your_project_name_or_id"
-conn = Fog::Compute::OpenStack.new({
- openstack_auth_url: auth_url + "/v3/auth/tokens",
- openstack_domain_id: "default",
- openstack_username: auth_username,
- openstack_api_key: auth_password,
- openstack_project_name: project_name
- })
+conn = Fog::Compute::OpenStack.new openstack_auth_url: auth_url + "/v3/auth/tokens",
+ openstack_domain_id: "default",
+ openstack_username: auth_username,
+ openstack_api_key: auth_password,
+ openstack_project_name: project_name
# step-2
-volume = conn.volumes.create({
- name: "test",
- description: "",
- size: 1
- })
+volume = conn.volumes.create name: "test",
+ description: "",
+ size: 1
+
p volume
# step-3
p conn.volumes.summary
# step-4
-db_group = conn.security_groups.create({
- name: "database",
- description: "for database service"
- })
-conn.security_group_rules.create({
- parent_group_id: db_group.id,
- ip_protocol: "tcp",
- from_port: 3306,
- to_port: 3306
- })
-instance = conn.servers.create({
- name: "app-database",
- image_ref: image.id,
- flavor_ref: flavor.id,
- key_name: key_pair.name,
- security_groups: db_group
- })
-Fog.wait_for {instance.ready?}
+db_group = conn.security_groups.create name: "database",
+ description: "for database service"
+
+conn.security_group_rules.create parent_group_id: db_group.id,
+ ip_protocol: "tcp",
+ from_port: 3306,
+ to_port: 3306
+
+instance = conn.servers.create name: "app-database",
+ image_ref: image.id,
+ flavor_ref: flavor.id,
+ key_name: key_pair.name,
+ security_groups: db_group
+
+Fog.wait_for { instance.ready? }
# step-5
-volume = conn.volumes.get("755ab026-b5f2-4f53-b34a-6d082fb36689")
-instance.attach_volume(volume.id, "/dev/vdb")
+volume = conn.volumes.get "755ab026-b5f2-4f53-b34a-6d082fb36689"
+instance.attach_volume volume.id, "/dev/vdb"
# step-6
-instance.detach_volume(volume.id)
+instance.detach_volume volume.id
volume.destroy
# step-7
-conn.snapshots.create({
- volume_id: volume.id,
- name: "test_backup_1",
- description: "test"
- })
+conn.snapshots.create volume_id: volume.id,
+ name: "test_backup_1",
+ description: "test"
# step-8
diff --git a/firstapp/samples/fog/durability.rb b/firstapp/samples/fog/durability.rb
index 687e91c64..f21be2048 100755
--- a/firstapp/samples/fog/durability.rb
+++ b/firstapp/samples/fog/durability.rb
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-require 'fog'
+require 'fog/openstack'
require 'digest/md5'
require 'net/http'
require 'json'
@@ -7,41 +7,36 @@ require 'json'
# step-1
auth_username = "your_auth_username"
auth_password = "your_auth_password"
-auth_url = "http://controller:5000"
-project_name = "your_project_name_or_id"
+auth_url = "http://controller:5000"
+project_name = "your_project_name_or_id"
-swift = Fog::Storage::OpenStack.new({
- openstack_auth_url: auth_url + "/v3/auth/tokens",
- openstack_domain_id: "default",
- openstack_username: auth_username,
- openstack_api_key: auth_password,
- openstack_project_name: project_name
- })
+swift = Fog::Storage::OpenStack.new openstack_auth_url: auth_url + "/v3/auth/tokens",
+ openstack_domain_id: "default",
+ openstack_username: auth_username,
+ openstack_api_key: auth_password,
+ openstack_project_name: project_name
# step-2
container_name = "fractals"
-container = swift.directories.create({
- key: container_name
- })
+container = swift.directories.create key: container_name
+
p container
# step-3
p swift.directories.all
# step-4
-file_path = "goat.jpg"
+file_path = "goat.jpg"
object_name = "an amazing goat"
-container = swift.direcories.get(container_name)
-object = container.files.create({
- body: File.read(File.expand_path(file_path)),
- key: object_name
- })
+container = swift.direcories.get container_name
+object = container.files.create body: File.read(File.expand_path(file_path)),
+ key: object_name
# step-5
p container.files.all
# step-6
-p container.files.get(object_name)
+p container.files.get object_name
# step-7
puts Digest::MD5.hexdigest(File.read(File.expand_path(file_path)))
@@ -55,12 +50,11 @@ p container.files.all
# step-10
# step-11
-endpoint = "http://IP_API_1"
-uri = URI("#{endpoint}/v1/fractal")
-uri.query = URI.encode_www_form({
- results_per_page: -1
- })
-data = JSON.parse(Net::HTTP.get_response(uri).body)
+endpoint = "http://IP_API_1"
+uri = URI("#{endpoint}/v1/fractal")
+uri.query = URI.encode_www_form results_per_page: -1
+data = JSON.parse(Net::HTTP.get_response(uri).body)
+
data["objects"].each do |fractal|
uri = URI("#{endpoint}/fractal/#{fractal["uuid"]}")
#TBC
diff --git a/firstapp/samples/fog/getting_started.rb b/firstapp/samples/fog/getting_started.rb
index e2c1208ed..d4b9b7fd7 100755
--- a/firstapp/samples/fog/getting_started.rb
+++ b/firstapp/samples/fog/getting_started.rb
@@ -1,19 +1,17 @@
#!/usr/bin/env ruby
-require 'fog'
+require 'fog/openstack'
# step-1
auth_username = "your_auth_username"
auth_password = "your_auth_password"
-auth_url = "http://controller:5000"
-project_name = "your_project_name_or_id"
+auth_url = "http://controller:5000"
+project_name = "your_project_name_or_id"
-conn = Fog::Compute::OpenStack.new({
- openstack_auth_url: auth_url + "/v3/auth/tokens",
- openstack_domain_id: "default",
- openstack_username: auth_username,
- openstack_api_key: auth_password,
- openstack_project_name: project_name
- })
+conn = Fog::Compute::OpenStack.new openstack_auth_url: auth_url + "/v3/auth/tokens",
+ openstack_domain_id: "default",
+ openstack_username: auth_username,
+ openstack_api_key: auth_password,
+ openstack_project_name: project_name
# step-2
p conn.images.summary
@@ -22,20 +20,19 @@ p conn.images.summary
p conn.flavors.summary
# step-4
-image = conn.images.get("2cccbea0-cea9-4f86-a3ed-065c652adda5")
+image = conn.images.get "2cccbea0-cea9-4f86-a3ed-065c652adda5"
p image
# step-5
-flavor = conn.flavors.get("2")
+flavor = conn.flavors.get "2"
p flavor
# step-6
-instance_name = "testing"
-testing_instance = conn.servers.create({
- name: instance_name,
- image_ref: image.id,
- flavor_ref: flavor.id
- })
+instance_name = "testing"
+testing_instance = conn.servers.create name: instance_name,
+ image_ref: image.id,
+ flavor_ref: flavor.id
+
Fog.wait_for {testing_instance.ready?}
p testing_instance
@@ -48,17 +45,15 @@ testing_instance.destroy
# step-9
puts "Checking for existing SSH key pair..."
-key_pair_name = "demokey"
+key_pair_name = "demokey"
pub_key_file_path = "~/.ssh/id_rsa.pub"
if key_pair = conn.key_pairs.get(key_pair_name)
puts "Keypair #{key_pair_name} already exists. Skipping import."
else
puts "adding keypair..."
- key_pair = conn.key_pairs.create({
- name: key_pair_name,
- public_key: File.read(File.expand_path(pub_key_file_path))
- })
+ key_pair = conn.key_pairs.create name: key_pair_name,
+ public_key: File.read(File.expand_path(pub_key_file_path))
end
p conn.key_pairs.all
@@ -67,25 +62,26 @@ p conn.key_pairs.all
puts "Checking for existing security group..."
security_group_name = "all-in-one"
-if all_in_one_security_group = conn.security_groups.find {|security_group| security_group.name == security_group_name}
+all_in_one_security_group = conn.security_groups.find do |security_group|
+ security_group.name == security_group_name
+end
+
+if all_in_one_security_group
puts "Security Group #{security_group_name} already exists. Skipping creation."
else
- all_in_one_security_group = conn.security_groups.create({
- name: security_group_name,
- description: "network access for all-in-one application."
- })
- conn.security_group_rules.create({
- parent_group_id: all_in_one_security_group.id,
- ip_protocol: "tcp",
- from_port: 80,
- to_port: 80
- })
- conn.security_group_rules.create({
- parent_group_id: all_in_one_security_group.id,
- ip_protocol: "tcp",
- from_port: 22,
- to_port: 22
- })
+ all_in_one_security_group = conn.security_groups.create name: security_group_name,
+ description: "network access for all-in-one application."
+
+ conn.security_group_rules.create parent_group_id: all_in_one_security_group.id,
+ ip_protocol: "tcp",
+ from_port: 80,
+ to_port: 80
+
+ conn.security_group_rules.create parent_group_id: all_in_one_security_group.id,
+ ip_protocol: "tcp",
+ from_port: 22,
+ to_port: 22
+
end
p conn.security_groups.all
@@ -104,33 +100,30 @@ instance_name = "all-in-one"
if testing_instance = conn.servers.find {|instance| instance.name == instance_name}
puts "Instance #{instance_name} already exists. Skipping creation."
else
- testing_instance = conn.servers.create({
- name: instance_name,
- image_ref: image.id,
- flavor_ref: flavor.id,
- key_name: key_pair.name,
- user_data: user_data,
- security_groups: all_in_one_security_group
- })
+ testing_instance = conn.servers.create name: instance_name,
+ image_ref: image.id,
+ flavor_ref: flavor.id,
+ key_name: key_pair.name,
+ user_data: user_data,
+ security_groups: all_in_one_security_group
+
Fog.wait_for {testing_instance.ready?}
end
p conn.servers.summary
# step-13
-puts "Private IP found: #{private_ip_address}" if private_ip_address ||= testing_instance.private_ip_address
+puts "Private IP found: #{private_ip_address}" if private_ip_address = testing_instance.private_ip_address
# step-14
-puts "Public IP found: #{floating_ip_address}" if floating_ip_address ||= testing_instance.floating_ip_address
+puts "Public IP found: #{floating_ip_address}" if floating_ip_address = testing_instance.floating_ip_address
# step-15
puts "Checking for unused Floating IP..."
unless unused_floating_ip_address = conn.addresses.find {|address| address.instance_id.nil?}
pool_name = conn.addresses.get_address_pools[0]["name"]
puts "Allocating new Floating IP from pool: #{pool_name}"
- unused_floating_ip_address = conn.addresses.create({
- pool: pool_name
- })
+ unused_floating_ip_address = conn.addresses.create pool: pool_name
end
# step-16
diff --git a/firstapp/samples/fog/introduction.rb b/firstapp/samples/fog/introduction.rb
index d73980a41..e365edd52 100644
--- a/firstapp/samples/fog/introduction.rb
+++ b/firstapp/samples/fog/introduction.rb
@@ -5,15 +5,14 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
-i faafo -i messaging -r api -r worker -r demo
END
-instance_name = "all-in-one"
-testing_instance = conn.servers.create({
- name: instance_name,
- image_ref: image.id,
- flavor_ref: flavor.id,
- key_name: key_pair.name,
- user_data: user_data,
- security_groups: all_in_one_security_group
- })
+instance_name = "all-in-one"
+testing_instance = conn.servers.create name: instance_name,
+ image_ref: image.id,
+ flavor_ref: flavor.id,
+ key_name: key_pair.name,
+ user_data: user_data,
+ security_groups: all_in_one_security_group
+
Fog.wait_for {testing_instance.ready?}
# step-2
@@ -24,22 +23,18 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
END
# step-3
-all_in_one_security_group = conn.security_groups.create({
- name: "all-in-one",
- description: "network access for all-in-one application."
- })
-conn.security_group_rules.create({
- parent_group_id: all_in_one_security_group.id,
- ip_protocol: "tcp",
- from_port: 80,
- to_port: 80
- })
-conn.security_group_rules.create({
- parent_group_id: all_in_one_security_group.id,
- ip_protocol: "tcp",
- from_port: 22,
- to_port: 22
- })
+all_in_one_security_group = conn.security_groups.create name: "all-in-one",
+ description: "network access for all-in-one application."
+
+conn.security_group_rules.create parent_group_id: all_in_one_security_group.id,
+ ip_protocol: "tcp",
+ from_port: 80,
+ to_port: 80
+
+conn.security_group_rules.create parent_group_id: all_in_one_security_group.id,
+ ip_protocol: "tcp",
+ from_port: 22,
+ to_port: 22
# step-4
conn.security_groups.all
@@ -58,48 +53,38 @@ puts "Found an unused Floating IP: #{unused_floating_ip_address.ip}" if unused_f
pool_name = conn.addresses.get_address_pools[0]["name"]
# step-9
-unused_floating_ip_address = conn.addresses.create({
- pool: pool_name
- })
+unused_floating_ip_address = conn.addresses.create pool: pool_name
# step-10
unused_floating_ip_address.server = instance
# step-11
-worker_group = conn.security_groups.create({
- name: "worker",
- description: "for services that run on a worker node"
- })
-conn.security_group_rules.create({
- parent_group_id: worker_group.id,
- ip_protocol: "tcp",
- from_port: 22,
- to_port: 22
- })
+worker_group = conn.security_groups.create name: "worker",
+ description: "for services that run on a worker node"
-controller_group = conn.security_groups.create({
- name: "control",
- description: "for services that run on a control node"
- })
-conn.security_group_rules.create({
- parent_group_id: controller_group.id,
- ip_protocol: "tcp",
- from_port: 22,
- to_port: 22
- })
-conn.security_group_rules.create({
- parent_group_id: controller_group.id,
- ip_protocol: "tcp",
- from_port: 80,
- to_port: 80
- })
-conn.security_group_rules.create({
- parent_group_id: controller_group.id,
- ip_protocol: "tcp",
- from_port: 5672,
- to_port: 5672,
- group: worker_group.id
- })
+conn.security_group_rules.create parent_group_id: worker_group.id,
+ ip_protocol: "tcp",
+ from_port: 22,
+ to_port: 22
+
+controller_group = conn.security_groups.create name: "control",
+ description: "for services that run on a control node"
+
+conn.security_group_rules.create parent_group_id: controller_group.id,
+ ip_protocol: "tcp",
+ from_port: 22,
+ to_port: 22
+
+conn.security_group_rules.create parent_group_id: controller_group.id,
+ ip_protocol: "tcp",
+ from_port: 80,
+ to_port: 80
+
+conn.security_group_rules.create parent_group_id: controller_group.id,
+ ip_protocol: "tcp",
+ from_port: 5672,
+ to_port: 5672,
+ group: worker_group.id
user_data = <`_
- A Ruby-based SDK.
Use it to work with multiple clouds.
- - https://github.com/fog/fog/blob/master/lib/fog/openstack/docs/getting_started.md
+ - https://github.com/fog/fog-openstack/blob/master/lib/fog/openstack/docs/getting_started.md
* - node.js
- `pkgcloud `_
- A Node.js-based SDK.
diff --git a/firstapp/source/orchestration.rst b/firstapp/source/orchestration.rst
index 861a60761..0024f246f 100644
--- a/firstapp/source/orchestration.rst
+++ b/firstapp/source/orchestration.rst
@@ -59,7 +59,7 @@ http://docs.openstack.org/cli-reference/common/cli_set_environment_variables_usi
.. only:: fog
.. note:: fog `does support OpenStack Orchestration
- `_.
+ `_.
.. only:: jclouds
diff --git a/www/index.html b/www/index.html
index 39d90d7ea..c9f955387 100644
--- a/www/index.html
+++ b/www/index.html
@@ -316,7 +316,7 @@
Docs and resources
-
+
Getting Started with Fog and OpenStack
@@ -356,7 +356,7 @@
Issues:
-
+
fog/fog Issues