MyFirstApp: Introduction section with shade
Improve and complete the code in this section. Change-Id: I6b214c9560a537d4dd8db5b3a15d91deeef00aaa
This commit is contained in:
parent
315431c11c
commit
4e93561777
@ -8,7 +8,9 @@ curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.
|
|||||||
instance_name = 'all-in-one'
|
instance_name = 'all-in-one'
|
||||||
testing_instance = conn.create_server(wait=True, auto_ip=False,
|
testing_instance = conn.create_server(wait=True, auto_ip=False,
|
||||||
name=instance_name,
|
name=instance_name,
|
||||||
image=image_id, flavor=flavor_id, key_name=keypair_name,
|
image=image_id,
|
||||||
|
flavor=flavor_id,
|
||||||
|
key_name=keypair_name,
|
||||||
security_groups=[sec_group_name],
|
security_groups=[sec_group_name],
|
||||||
userdata=userdata)
|
userdata=userdata)
|
||||||
|
|
||||||
@ -25,13 +27,13 @@ conn.create_security_group(sec_group_name, 'network access for all-in-one applic
|
|||||||
conn.create_security_group_rule(sec_group_name, 80, 80, 'TCP')
|
conn.create_security_group_rule(sec_group_name, 80, 80, 'TCP')
|
||||||
conn.create_security_group_rule(sec_group_name, 22, 22, 'TCP')
|
conn.create_security_group_rule(sec_group_name, 22, 22, 'TCP')
|
||||||
|
|
||||||
conn.search_security_groups(sec_group_name)
|
|
||||||
|
|
||||||
# step-4
|
# step-4
|
||||||
conn.list_security_groups()
|
sec_groups = conn.list_security_groups()
|
||||||
|
for sec_group in sec_groups:
|
||||||
|
print(sec_group)
|
||||||
|
|
||||||
# step-5
|
# step-5
|
||||||
conn.delete_security_group_rule(rule['id'])
|
conn.delete_security_group_rule(rule_id)
|
||||||
conn.delete_security_group(sec_group_name)
|
conn.delete_security_group(sec_group_name)
|
||||||
|
|
||||||
# step-6
|
# step-6
|
||||||
@ -47,13 +49,21 @@ unused_floating_ip = conn.available_floating_ip()
|
|||||||
conn.add_ip_list(testing_instance, [unused_floating_ip['floating_ip_address']])
|
conn.add_ip_list(testing_instance, [unused_floating_ip['floating_ip_address']])
|
||||||
|
|
||||||
# step-11
|
# step-11
|
||||||
worker_group = conn.create_security_group('worker', 'for services that run on a worker node')
|
worker_group_name = 'worker'
|
||||||
conn.create_security_group_rule(worker_group['name'], 22, 22, 'TCP')
|
if conn.search_security_groups(worker_group_name):
|
||||||
|
print('Security group \'%s\' already exists. Skipping creation.' % worker_group_name)
|
||||||
|
else:
|
||||||
|
worker_group = conn.create_security_group(worker_group_name, 'for services that run on a worker node')
|
||||||
|
conn.create_security_group_rule(worker_group['name'], 22, 22, 'TCP')
|
||||||
|
|
||||||
controller_group = conn.create_security_group('control', 'for services that run on a control node')
|
controller_group_name = 'control'
|
||||||
conn.create_security_group_rule(controller_group['name'], 22, 22, 'TCP')
|
if conn.search_security_groups(controller_group_name):
|
||||||
conn.create_security_group_rule(controller_group['name'], 80, 80, 'TCP')
|
print('Security group \'%s\' already exists. Skipping creation.' % controller_group_name)
|
||||||
conn.create_security_group_rule(controller_group['name'], 5672, 5672, 'TCP', remote_group_id=worker_group['id'])
|
else:
|
||||||
|
controller_group = conn.create_security_group(controller_group_name, 'for services that run on a control node')
|
||||||
|
conn.create_security_group_rule(controller_group['name'], 22, 22, 'TCP')
|
||||||
|
conn.create_security_group_rule(controller_group['name'], 80, 80, 'TCP')
|
||||||
|
conn.create_security_group_rule(controller_group['name'], 5672, 5672, 'TCP', remote_group_id=worker_group['id'])
|
||||||
|
|
||||||
userdata = '''#!/usr/bin/env bash
|
userdata = '''#!/usr/bin/env bash
|
||||||
curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
|
curl -L -s http://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
|
||||||
@ -65,7 +75,7 @@ instance_controller_1 = conn.create_server(wait=True, auto_ip=False,
|
|||||||
image=image_id,
|
image=image_id,
|
||||||
flavor=flavor_id,
|
flavor=flavor_id,
|
||||||
key_name=keypair_name,
|
key_name=keypair_name,
|
||||||
security_groups=[controller_group['name']],
|
security_groups=[controller_group_name],
|
||||||
userdata=userdata)
|
userdata=userdata)
|
||||||
|
|
||||||
unused_floating_ip = conn.available_floating_ip()
|
unused_floating_ip = conn.available_floating_ip()
|
||||||
@ -91,7 +101,7 @@ instance_worker_1 = conn.create_server(wait=True, auto_ip=False,
|
|||||||
image=image_id,
|
image=image_id,
|
||||||
flavor=flavor_id,
|
flavor=flavor_id,
|
||||||
key_name=keypair_name,
|
key_name=keypair_name,
|
||||||
security_groups=[worker_group['name']],
|
security_groups=[worker_group_name],
|
||||||
userdata=userdata)
|
userdata=userdata)
|
||||||
|
|
||||||
unused_floating_ip = conn.available_floating_ip()
|
unused_floating_ip = conn.available_floating_ip()
|
||||||
@ -104,5 +114,3 @@ print('The worker will be available for SSH at %s' % unused_floating_ip['floatin
|
|||||||
instance_worker_1 = conn.get_server(instance_worker_1['name'])
|
instance_worker_1 = conn.get_server(instance_worker_1['name'])
|
||||||
ip_instance_worker_1 = conn.get_server_public_ip(instance_worker_1)
|
ip_instance_worker_1 = conn.get_server_public_ip(instance_worker_1)
|
||||||
print(ip_instance_worker_1)
|
print(ip_instance_worker_1)
|
||||||
|
|
||||||
# step-14
|
|
||||||
|
@ -403,6 +403,30 @@ To see which security groups apply to an instance, you can:
|
|||||||
:start-after: step-6
|
:start-after: step-6
|
||||||
:end-before: step-7
|
:end-before: step-7
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
name: 'all-in-one',
|
||||||
|
description: 'network access for all-in-one application.',
|
||||||
|
security_group_rules:
|
||||||
|
- direction: 'ingress',
|
||||||
|
protocol': 'tcp',
|
||||||
|
remote_ip_prefix: '0.0.0.0/0',
|
||||||
|
port_range_max: 22,
|
||||||
|
security_group_id: '83aa1bf9-564a-47da-bb46-60cd1c63cc84',
|
||||||
|
port_range_min: 22,
|
||||||
|
ethertype: 'IPv4',
|
||||||
|
id: '5ff0008f-a02d-4b40-9719-f52c77dfdab0',
|
||||||
|
- direction: 'ingress',
|
||||||
|
protocol: 'tcp',
|
||||||
|
remote_ip_prefix: '0.0.0.0/0',
|
||||||
|
port_range_max: 80,
|
||||||
|
security_group_id: '83aa1bf9-564a-47da-bb46-60cd1c63cc84',
|
||||||
|
port_range_min: 80,
|
||||||
|
ethertype: 'IPv4',
|
||||||
|
id: 'c2539e49-b110-4657-bf0a-7a221f5e9e6f',
|
||||||
|
id: '83aa1bf9-564a-47da-bb46-60cd1c63cc84'
|
||||||
|
|
||||||
|
|
||||||
.. only:: fog
|
.. only:: fog
|
||||||
|
|
||||||
.. literalinclude:: ../samples/fog/introduction.rb
|
.. literalinclude:: ../samples/fog/introduction.rb
|
||||||
@ -676,7 +700,6 @@ address of the worker:
|
|||||||
.. literalinclude:: ../samples/shade/introduction.py
|
.. literalinclude:: ../samples/shade/introduction.py
|
||||||
:language: python
|
:language: python
|
||||||
:start-after: step-13
|
:start-after: step-13
|
||||||
:end-before: step-14
|
|
||||||
|
|
||||||
.. only:: fog
|
.. only:: fog
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user