|
@ -13,7 +13,7 @@ from libcloud.compute.types import Provider |
|
|
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username, |
|
|
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username, |
|
|
# project etc., as coordinated in the lab sessions) |
|
|
# project etc., as coordinated in the lab sessions) |
|
|
|
|
|
|
|
|
group_number = 30 |
|
|
|
|
|
|
|
|
group_number = 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# web service endpoint of the private cloud infrastructure |
|
|
# web service endpoint of the private cloud infrastructure |
|
@ -26,15 +26,17 @@ project_name = 'CloudComp' + str(group_number) |
|
|
project_network = 'CloudComp' + str(group_number) + '-net' |
|
|
project_network = 'CloudComp' + str(group_number) + '-net' |
|
|
|
|
|
|
|
|
# The image to look for and use for the started instance |
|
|
# The image to look for and use for the started instance |
|
|
ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image" |
|
|
|
|
|
# TODO: Ubuntu >18.04 would require major updates to faafo example again/better option: complete rewrite of example? |
|
|
|
|
|
|
|
|
#ubuntu_image_name = "Ubuntu 20.04 - Focal Fossa - 64-bit - Cloud Based Image" |
|
|
|
|
|
ubuntu_image_name = "Ubuntu 22.04 - Jammy Jellyfish - 64-bit - Cloud Based Image" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key |
|
|
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key |
|
|
# |
|
|
# |
|
|
# id_rsa.pub should look like this (standard sshd pubkey format): |
|
|
# id_rsa.pub should look like this (standard sshd pubkey format): |
|
|
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAw+J...F3w2mleybgT1w== user@HOSTNAME |
|
|
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAw+J...F3w2mleybgT1w== user@HOSTNAME |
|
|
|
|
|
|
|
|
keypair_name = 'srieger-pub' |
|
|
|
|
|
|
|
|
#keypair_name = 'CloudComp30-keypair' |
|
|
|
|
|
keypair_name = "srieger-pub" |
|
|
pub_key_file = '~/.ssh/id_rsa.pub' |
|
|
pub_key_file = '~/.ssh/id_rsa.pub' |
|
|
|
|
|
|
|
|
flavor_name = 'm1.small' |
|
|
flavor_name = 'm1.small' |
|
@ -113,7 +115,7 @@ def main(): |
|
|
keypair_exists = True |
|
|
keypair_exists = True |
|
|
|
|
|
|
|
|
if keypair_exists: |
|
|
if keypair_exists: |
|
|
print('Keypair ' + keypair_name + ' already exists. Skipping import.') |
|
|
|
|
|
|
|
|
print(('Keypair ' + keypair_name + ' already exists. Skipping import.')) |
|
|
else: |
|
|
else: |
|
|
print('adding keypair...') |
|
|
print('adding keypair...') |
|
|
conn.import_key_pair_from_file(keypair_name, pub_key_file) |
|
|
conn.import_key_pair_from_file(keypair_name, pub_key_file) |
|
@ -131,7 +133,7 @@ def main(): |
|
|
for instance in conn.list_nodes(): |
|
|
for instance in conn.list_nodes(): |
|
|
if instance.name in ['all-in-one', 'app-worker-1', 'app-worker-2', 'app-worker-3', 'app-controller', |
|
|
if instance.name in ['all-in-one', 'app-worker-1', 'app-worker-2', 'app-worker-3', 'app-controller', |
|
|
'app-services', 'app-api-1', 'app-api-2']: |
|
|
'app-services', 'app-api-1', 'app-api-2']: |
|
|
print('Destroying Instance: %s' % instance.name) |
|
|
|
|
|
|
|
|
print(('Destroying Instance: %s' % instance.name)) |
|
|
conn.destroy_node(instance) |
|
|
conn.destroy_node(instance) |
|
|
|
|
|
|
|
|
# wait until all nodes are destroyed to be able to remove depended security groups |
|
|
# wait until all nodes are destroyed to be able to remove depended security groups |
|
@ -149,7 +151,7 @@ def main(): |
|
|
# delete security groups |
|
|
# delete security groups |
|
|
for group in conn.ex_list_security_groups(): |
|
|
for group in conn.ex_list_security_groups(): |
|
|
if group.name in ['control', 'worker', 'api', 'services']: |
|
|
if group.name in ['control', 'worker', 'api', 'services']: |
|
|
print('Deleting security group: %s' % group.name) |
|
|
|
|
|
|
|
|
print(('Deleting security group: %s' % group.name)) |
|
|
conn.ex_delete_security_group(group) |
|
|
conn.ex_delete_security_group(group) |
|
|
|
|
|
|
|
|
########################################################################### |
|
|
########################################################################### |
|
@ -160,10 +162,10 @@ def main(): |
|
|
|
|
|
|
|
|
def get_security_group(connection, security_group_name): |
|
|
def get_security_group(connection, security_group_name): |
|
|
"""A helper function to check if security group already exists""" |
|
|
"""A helper function to check if security group already exists""" |
|
|
print('Checking for existing ' + security_group_name + ' security group...') |
|
|
|
|
|
|
|
|
print(('Checking for existing ' + security_group_name + ' security group...')) |
|
|
for security_grp in connection.ex_list_security_groups(): |
|
|
for security_grp in connection.ex_list_security_groups(): |
|
|
if security_grp.name == security_group_name: |
|
|
if security_grp.name == security_group_name: |
|
|
print('Security Group ' + security_group_name + ' already exists. Skipping creation.') |
|
|
|
|
|
|
|
|
print(('Security Group ' + security_group_name + ' already exists. Skipping creation.')) |
|
|
return worker_security_group |
|
|
return worker_security_group |
|
|
return False |
|
|
return False |
|
|
|
|
|
|
|
@ -226,14 +228,12 @@ def main(): |
|
|
# |
|
|
# |
|
|
########################################################################### |
|
|
########################################################################### |
|
|
|
|
|
|
|
|
# https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh |
|
|
|
|
|
# is currently broken, hence the "rabbitctl" lines were added in the example |
|
|
|
|
|
# below, see also https://bugs.launchpad.net/faafo/+bug/1679710 |
|
|
|
|
|
# |
|
|
|
|
|
# Thanks to Stefan Friedmann for finding this fix ;) |
|
|
|
|
|
|
|
|
#hsfd_faafo_cloud_init_script = 'https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh' |
|
|
|
|
|
# testing / faafo dev branch: |
|
|
|
|
|
hsfd_faafo_cloud_init_script = 'https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/branch/dev_faafo/faafo/contrib/install.sh' |
|
|
|
|
|
|
|
|
userdata_service = '''#!/usr/bin/env bash |
|
|
userdata_service = '''#!/usr/bin/env bash |
|
|
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \ |
|
|
|
|
|
|
|
|
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ |
|
|
-i database -i messaging |
|
|
-i database -i messaging |
|
|
rabbitmqctl add_user faafo guest |
|
|
rabbitmqctl add_user faafo guest |
|
|
rabbitmqctl set_user_tags faafo administrator |
|
|
rabbitmqctl set_user_tags faafo administrator |
|
@ -259,7 +259,7 @@ def main(): |
|
|
########################################################################### |
|
|
########################################################################### |
|
|
|
|
|
|
|
|
userdata_api = '''#!/usr/bin/env bash |
|
|
userdata_api = '''#!/usr/bin/env bash |
|
|
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \ |
|
|
|
|
|
|
|
|
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ |
|
|
-i faafo -r api -m 'amqp://faafo:guest@%(services_ip)s:5672/' \ |
|
|
-i faafo -r api -m 'amqp://faafo:guest@%(services_ip)s:5672/' \ |
|
|
-d 'mysql+pymysql://faafo:password@%(services_ip)s:3306/faafo' |
|
|
-d 'mysql+pymysql://faafo:password@%(services_ip)s:3306/faafo' |
|
|
''' % {'services_ip': services_ip} |
|
|
''' % {'services_ip': services_ip} |
|
@ -292,7 +292,7 @@ def main(): |
|
|
for instance in [instance_api_1, instance_api_2]: |
|
|
for instance in [instance_api_1, instance_api_2]: |
|
|
floating_ip = get_floating_ip(conn) |
|
|
floating_ip = get_floating_ip(conn) |
|
|
conn.ex_attach_floating_ip_to_node(instance, floating_ip) |
|
|
conn.ex_attach_floating_ip_to_node(instance, floating_ip) |
|
|
print('allocated %(ip)s to %(host)s' % {'ip': floating_ip.ip_address, 'host': instance.name}) |
|
|
|
|
|
|
|
|
print(('allocated %(ip)s to %(host)s' % {'ip': floating_ip.ip_address, 'host': instance.name})) |
|
|
|
|
|
|
|
|
########################################################################### |
|
|
########################################################################### |
|
|
# |
|
|
# |
|
@ -301,12 +301,12 @@ def main(): |
|
|
########################################################################### |
|
|
########################################################################### |
|
|
|
|
|
|
|
|
userdata_worker = '''#!/usr/bin/env bash |
|
|
userdata_worker = '''#!/usr/bin/env bash |
|
|
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \ |
|
|
|
|
|
|
|
|
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ |
|
|
-i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/' |
|
|
-i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/' |
|
|
''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip} |
|
|
''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip} |
|
|
|
|
|
|
|
|
# userdata_api-api-2 = '''#!/usr/bin/env bash |
|
|
# userdata_api-api-2 = '''#!/usr/bin/env bash |
|
|
# curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \ |
|
|
|
|
|
|
|
|
# curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ |
|
|
# -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/' |
|
|
# -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/' |
|
|
# ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip} |
|
|
# ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip} |
|
|
|
|
|
|
|
|