Ruby styling/organization fixes.
Change-Id: I8db03eae74abe72077813a18f8dafec91519eb5f Signed-off-by: Sean Handley <sean.handley@gmail.com>
This commit is contained in:
parent
f7adfac071
commit
c0d164ce19
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = <<END
|
||||
#!/usr/bin/env bash
|
||||
@ -107,23 +92,20 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
|
||||
-i messaging -i faafo -r api
|
||||
END
|
||||
|
||||
instance_controller_1 = conn.servers.create({
|
||||
name: "app-controller",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: controller_group
|
||||
})
|
||||
instance_controller_1 = conn.servers.create name: "app-controller",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: controller_group
|
||||
|
||||
Fog.wait_for {instance_controller_1.ready?}
|
||||
|
||||
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
|
||||
|
||||
unused_floating_ip_address.server = instance_controller_1
|
||||
@ -131,7 +113,7 @@ puts "Application will be deployed to http://#{unused_floating_ip_address.ip}"
|
||||
|
||||
# step-12
|
||||
instance_controller_1 = conn.servers.get(instance_controller_1.id)
|
||||
ip_controller = instance_controller_1.floating_ip_address ? instance_controller_1.private_ip_address : instance_controller_1.floating_ip_address
|
||||
ip_controller = instance_controller_1.private_ip_address || instance_controller_1.floating_ip_address
|
||||
|
||||
user_data = <<END
|
||||
#!/usr/bin/env bash
|
||||
@ -139,23 +121,20 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
|
||||
-i faafo -r worker -e "http://#{ip_controller}" -m "amqp://guest:guest@#{ip_controller}:5672/"
|
||||
END
|
||||
|
||||
instance_worker_1 = conn.servers.create({
|
||||
name: "app-worker-1",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
})
|
||||
instance_worker_1 = conn.servers.create name: "app-worker-1",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
|
||||
Fog.wait_for {instance_worker_1.ready?}
|
||||
|
||||
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
|
||||
|
||||
unused_floating_ip_address.server = instance_worker_1
|
||||
|
@ -1,107 +1,105 @@
|
||||
# step-1
|
||||
conn.servers.select {|instance| ["all-in-one","app-worker-1", "app-worker-2", "app-controller"].include?(instance.name)}.each do |instance|
|
||||
instance_names = ["all-in-one","app-worker-1", "app-worker-2", "app-controller"]
|
||||
|
||||
conn.servers.select {|instance| instance_names.include?(instance.name)}.each do |instance|
|
||||
puts "Destroying Instance: #{instance.name}"
|
||||
instance.destroy
|
||||
end
|
||||
|
||||
conn.security_groups.select {|security_group| ["control", "worker", "api", "services"].include?(security_group.name)}.each do |security_group|
|
||||
security_group_names = ["control", "worker", "api", "services"]
|
||||
|
||||
conn.security_groups.select {|security_group| security_group_names.include?(security_group.name)}.each do |security_group|
|
||||
puts "Deleting security group: #{security_group.name}"
|
||||
security_group.destroy
|
||||
end
|
||||
|
||||
# step-2
|
||||
api_group = conn.security_groups.create({
|
||||
name: "api",
|
||||
description: "for API services only"
|
||||
})
|
||||
conn.security_group_rules.create({
|
||||
parent_group_id: api_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 80,
|
||||
to_port: 80
|
||||
})
|
||||
conn.security_group_rules.create({
|
||||
parent_group_id: api_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 22,
|
||||
to_port: 22
|
||||
})
|
||||
api_group = conn.security_groups.create name: "api",
|
||||
description: "for API services only"
|
||||
|
||||
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
|
||||
})
|
||||
controller_group = conn.security_groups.create name: "control",
|
||||
description: "for services that run on a control node"
|
||||
|
||||
services_group = conn.security_groups.create({
|
||||
name: "services",
|
||||
services_group = conn.security_groups.create name: "services",
|
||||
description: "for DB and AMQP services only"
|
||||
})
|
||||
conn.security_group_rules.create({
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 22,
|
||||
to_port: 22
|
||||
})
|
||||
conn.security_group_rules.create({
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 3306,
|
||||
to_port: 3306,
|
||||
group: api_group.id
|
||||
})
|
||||
conn.security_group_rules.create({
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 5672,
|
||||
to_port: 5672,
|
||||
group: worker_group.id
|
||||
})
|
||||
conn.security_group_rules.create({
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 5672,
|
||||
to_port: 5672,
|
||||
group: api_group.id
|
||||
})
|
||||
|
||||
rules = [
|
||||
{
|
||||
parent_group_id: api_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 80,
|
||||
to_port: 80
|
||||
},
|
||||
{
|
||||
parent_group_id: api_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 22,
|
||||
to_port: 22
|
||||
},
|
||||
{
|
||||
parent_group_id: worker_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 22,
|
||||
to_port: 22
|
||||
},
|
||||
{
|
||||
parent_group_id: controller_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 22,
|
||||
to_port: 22
|
||||
},
|
||||
{
|
||||
parent_group_id: controller_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 80,
|
||||
to_port: 80
|
||||
},
|
||||
{
|
||||
parent_group_id: controller_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 5672,
|
||||
to_port: 5672,
|
||||
group: worker_group.id
|
||||
},
|
||||
{
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 22,
|
||||
to_port: 22
|
||||
},
|
||||
{
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 3306,
|
||||
to_port: 3306,
|
||||
group: api_group.id
|
||||
},
|
||||
{
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 5672,
|
||||
to_port: 5672,
|
||||
group: worker_group.id
|
||||
},
|
||||
{
|
||||
parent_group_id: services_group.id,
|
||||
ip_protocol: "tcp",
|
||||
from_port: 5672,
|
||||
to_port: 5672,
|
||||
group: api_group.id
|
||||
}
|
||||
]
|
||||
rules.each {|rule| conn.security_group_rules.create rule }
|
||||
|
||||
# step-3
|
||||
def get_floating_ip_address(conn)
|
||||
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
|
||||
|
||||
unused_floating_ip_address
|
||||
@ -114,14 +112,13 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
|
||||
-i database -i messaging
|
||||
END
|
||||
|
||||
instance_services = conn.servers.create({
|
||||
name: "app-services",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: services_group
|
||||
})
|
||||
instance_services = conn.servers.create name: "app-services",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: services_group
|
||||
|
||||
Fog.wait_for {instance_services.ready?}
|
||||
services_ip_address = instance_services.private_ip_address
|
||||
|
||||
@ -132,29 +129,27 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
|
||||
-i faafo -r api -m "amqp://guest:guest@#{services_ip_address}:5672/" -d "mysql+pymysql://faafo:password@#{services_ip_address}:3306/faafo"
|
||||
END
|
||||
|
||||
instance_api_1 = conn.servers.create({
|
||||
name: "app-api-1",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: api_group
|
||||
})
|
||||
instance_api_2 = conn.servers.create({
|
||||
name: "app-api-2",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: api_group
|
||||
})
|
||||
instance_api_1 = conn.servers.create name: "app-api-1",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: api_group
|
||||
|
||||
instance_api_2 = conn.servers.create name: "app-api-2",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: api_group
|
||||
|
||||
Fog.wait_for {instance_api_1.ready?}
|
||||
api_1_ip_address = instance_api_1.private_ip_address
|
||||
Fog.wait_for {instance_api_2.ready?}
|
||||
api_2_ip_address = instance_api_2.private_ip_address
|
||||
|
||||
[instance_api_1, instance_api_2].each do |instance|
|
||||
floating_ip_address = get_floating_ip_address(conn)
|
||||
floating_ip_address = get_floating_ip_address(conn)
|
||||
floating_ip_address.server = instance
|
||||
puts "allocated #{floating_ip_address.ip} to #{instance.name}"
|
||||
end
|
||||
@ -166,29 +161,25 @@ curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.s
|
||||
-i faafo -r worker -e "http://#{api_1_ip_address}" -m "amqp://guest:guest@#{services_ip_address}:5672/"
|
||||
END
|
||||
|
||||
instance_worker_1 = conn.servers.create({
|
||||
name: "app-worker-1",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
})
|
||||
instance_worker_2 = conn.servers.create({
|
||||
name: "app-worker-2",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
})
|
||||
instance_worker_3 = conn.servers.create({
|
||||
name: "app-worker-3",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
})
|
||||
instance_worker_1 = conn.servers.create name: "app-worker-1",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
|
||||
instance_worker_2 = conn.servers.create name: "app-worker-2",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
|
||||
instance_worker_3 = conn.servers.create name: "app-worker-3",
|
||||
image_ref: image.id,
|
||||
flavor_ref: flavor.id,
|
||||
key_name: "demokey",
|
||||
user_data: user_data,
|
||||
security_groups: worker_group
|
||||
|
||||
# step-7
|
||||
|
@ -80,7 +80,7 @@ and toolkits with the OpenStack cloud:
|
||||
- `fog <http://fog.io/>`_
|
||||
- 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 <https://github.com/pkgcloud/pkgcloud>`_
|
||||
- A Node.js-based SDK.
|
||||
|
@ -59,7 +59,7 @@ http://docs.openstack.org/cli-reference/common/cli_set_environment_variables_usi
|
||||
.. only:: fog
|
||||
|
||||
.. note:: fog `does support OpenStack Orchestration
|
||||
<https://github.com/fog/fog/tree/master/lib/fog/openstack/models/orchestration>`_.
|
||||
<https://github.com/fog/fog-openstack/tree/master/lib/fog/openstack/models/orchestration>`_.
|
||||
|
||||
.. only:: jclouds
|
||||
|
||||
|
@ -316,7 +316,7 @@
|
||||
Docs and resources
|
||||
</dt>
|
||||
<dd>
|
||||
<a class="link" href="https://github.com/fog/fog/blob/master/lib/fog/openstack/docs/getting_started.md" target="_top">
|
||||
<a class="link" href="https://github.com/fog/fog-openstack/blob/master/lib/fog/openstack/docs/getting_started.md" target="_top">
|
||||
Getting Started with Fog and OpenStack
|
||||
</a>
|
||||
</dd>
|
||||
@ -356,7 +356,7 @@
|
||||
<strong>
|
||||
Issues:
|
||||
</strong>
|
||||
<a href="https://github.com/fog/fog/issues">
|
||||
<a href="https://github.com/fog/fog-openstack/issues">
|
||||
fog/fog Issues
|
||||
</a>
|
||||
</dd>
|
||||
|
Loading…
Reference in New Issue
Block a user