Andreas Jaeger f58477ef61 FirstApp: Move source directory up, rename top-level dir
For the RST guides, we do not need doc/source, since doc is always
empty. Use source directly.

This syncs the setup used here with openstack-manuals.

Rename top-level from openstack-firstapp to firstapp, there's no need
for the long name in this repo.

Change-Id: If4e11a4f90d580876865348e0d88b92cec4b6659
2015-05-01 17:22:46 +02:00

56 lines
1.2 KiB
Ruby

# step-1
require 'fog'
auth_username = 'your_auth_username'
auth_password = 'your_auth_password'
auth_url = 'http://controller:5000'
project_name = 'your_project_name_or_id'
region_name = 'your_region_name'
conn = Fog::Compute.new({
:provider => 'openstack',
:openstack_auth_url => auth_url + '/v2.0/tokens',
:openstack_username => auth_username
:openstack_tenant => project_name
:openstack_api_key => auth_password
})
# step-2
images = conn.list_images
print images.body
# step-3
flavors = conn.list_flavors
print flavors.body
# step-4
image_id = '2cccbea0-cea9-4f86-a3ed-065c652adda5'
image = conn.images.get image_id
print image
# step-5
flavor_id = '3'
image = conn.flavor.get flavor_id
print flavor
# step-6
instance_name = 'testing'
testing_instance = conn.servers.create(:name => instance_name, :flavor_ref => flavor.id, :image_ref => image.id)
# step-7
conn.servers
# step-8
testing_instance.destroy
# step-9
# step-10
all_in_one_security_group = conn.create_security_group 'all-in-one' 'network access for all-in-one application.'
conn.create_security_group_rule all_in_one_security_group 'TCP' 80 80
conn.create_security_group_rule all_in_one_security_group 'TCP' 22 22
# step-11
# step-12
# step-13