Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • sebastian.rieger/cloud-computing-msc-ai-examples
  • christoph.koenig/cloud-computing-msc-ai-examples
  • allan.valim-ribeiro-da-fonseca1/cloud-computing-msc-ai-examples
3 results
Select Git revision
Loading items
Show changes

Commits on Source 27

Showing
with 291 additions and 214 deletions
...@@ -6,3 +6,4 @@ venv ...@@ -6,3 +6,4 @@ venv
**/terraform.tfstate.backup **/terraform.tfstate.backup
**/.terraform.lock.hcl **/.terraform.lock.hcl
**/.terraform **/.terraform
**/.terraform.tfstate.lock.info
...@@ -17,7 +17,7 @@ export GROUP_NUMBER=0 ...@@ -17,7 +17,7 @@ export GROUP_NUMBER=0
# OpenStack API is version 3. For example, your cloud provider may implement # OpenStack API is version 3. For example, your cloud provider may implement
# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is # Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is
# only for the Identity API served through keystone. # only for the Identity API served through keystone.
export OS_AUTH_URL=https://10.32.4.182:5000/v3 export OS_AUTH_URL=https://10.32.4.29:5000/v3
# With the addition of Keystone we have standardized on the term **project** # With the addition of Keystone we have standardized on the term **project**
# as the entity that owns the resources. # as the entity that owns the resources.
#export OS_PROJECT_ID=bba62cf6bf0b447491829d207e1b05f9 #export OS_PROJECT_ID=bba62cf6bf0b447491829d207e1b05f9
......
...@@ -11,7 +11,7 @@ clouds: ...@@ -11,7 +11,7 @@ clouds:
auth: auth:
# auth_url: https://private-cloud.example.com:5000/v3 # auth_url: https://private-cloud.example.com:5000/v3
# auth_url: https://private-cloud2.example.com:5000/v3 # auth_url: https://private-cloud2.example.com:5000/v3
auth_url: https://10.32.4.182:5000/v3 auth_url: https://10.32.4.29:5000/v3
username: "CloudComp0" username: "CloudComp0"
password: "demo" password: "demo"
# project_id: bba62cf6bf0b447491829d207e1b05f9 # project_id: bba62cf6bf0b447491829d207e1b05f9
......
...@@ -9,17 +9,19 @@ ...@@ -9,17 +9,19 @@
# libCloud: https://libcloud.apache.org/ # libCloud: https://libcloud.apache.org/
# libCloud API documentation: https://libcloud.readthedocs.io/en/latest/ # libCloud API documentation: https://libcloud.readthedocs.io/en/latest/
# OpenStack API documentation: https://developer.openstack.org/ # OpenStack API documentation: https://developer.openstack.org/
#
# this code was initially based on the former tutorial: # this code was initially based on the former tutorial:
# https://developer.openstack.org/firstapp-libcloud/ # https://developer.openstack.org/firstapp-libcloud/
# Only needed for the password prompt: # Only needed when using a password prompt:
# import getpass # import getpass
from libcloud.compute.providers import get_driver from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider from libcloud.compute.types import Provider
# For our new Charmed OpenStack private cloud, we need to specify the path to the # For our new Charmed OpenStack private cloud, we need to specify the path to the
# root CA certificate # root CA certificate for now, until we have a valid certificate for the OpenStack API.
# This is necessary to avoid SSL certificate verification errors.
import libcloud.security import libcloud.security
libcloud.security.CA_CERTS_PATH = ['./root-ca.crt'] libcloud.security.CA_CERTS_PATH = ['./root-ca.crt']
# Disable SSL certificate verification (not recommended for production) # Disable SSL certificate verification (not recommended for production)
...@@ -31,6 +33,7 @@ libcloud.security.CA_CERTS_PATH = ['./root-ca.crt'] ...@@ -31,6 +33,7 @@ libcloud.security.CA_CERTS_PATH = ['./root-ca.crt']
GROUP_NUMBER = 0 GROUP_NUMBER = 0
############################################################################################### ###############################################################################################
# #
# no changes necessary below this line in this example # no changes necessary below this line in this example
...@@ -38,9 +41,11 @@ GROUP_NUMBER = 0 ...@@ -38,9 +41,11 @@ GROUP_NUMBER = 0
############################################################################################### ###############################################################################################
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
# auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000' #AUTH_URL = 'https://private-cloud.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.182:5000'
# auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
# using the IP address of the OpenStack API endpoint to avoid DNS resolution issues for students
# using Linux or MacOS as our VPN currently does not support IPv6
AUTH_URL = "https://10.32.4.29:5000"
# your username in OpenStack # your username in OpenStack
AUTH_USERNAME = 'CloudComp' + str(GROUP_NUMBER) AUTH_USERNAME = 'CloudComp' + str(GROUP_NUMBER)
# your project in OpenStack # your project in OpenStack
...@@ -50,7 +55,8 @@ PROJECT_NETWORK = 'CloudComp' + str(GROUP_NUMBER) + '-net' ...@@ -50,7 +55,8 @@ 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" # ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img" #UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img"
UBUNTU_IMAGE_NAME = "ubuntu-22.04-jammy-server-cloud-image-amd64"
# default region # default region
REGION_NAME = 'RegionOne' REGION_NAME = 'RegionOne'
......
...@@ -26,6 +26,7 @@ libcloud.security.CA_CERTS_PATH = ['./root-ca.crt'] ...@@ -26,6 +26,7 @@ libcloud.security.CA_CERTS_PATH = ['./root-ca.crt']
# Please use 1-29 as environment variable GROUP_NUMBER to specify your group number. # Please use 1-29 as environment variable GROUP_NUMBER to specify your group number.
# (will be used for the username, project etc., as coordinated in the lab sessions) # (will be used for the username, project etc., as coordinated in the lab sessions)
# get the GROUP_NUMBER from an env var, was only hard-coded as easy entry in demo1
group_number = os.environ.get('GROUP_NUMBER') group_number = os.environ.get('GROUP_NUMBER')
if group_number is None: if group_number is None:
sys.exit('Please set the GROUP_NUMBER environment variable to your group number,\n' sys.exit('Please set the GROUP_NUMBER environment variable to your group number,\n'
...@@ -37,8 +38,8 @@ if group_number is None: ...@@ -37,8 +38,8 @@ if group_number is None:
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
# auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.182:5000'
# auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.29:5000'
# your username in OpenStack # your username in OpenStack
AUTH_USERNAME = 'CloudComp' + str(group_number) AUTH_USERNAME = 'CloudComp' + str(group_number)
print(f'Using username: {AUTH_USERNAME}\n') print(f'Using username: {AUTH_USERNAME}\n')
...@@ -49,14 +50,14 @@ PROJECT_NETWORK = 'CloudComp' + str(group_number) + '-net' ...@@ -49,14 +50,14 @@ 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" # ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img" #UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img"
UBUNTU_IMAGE_NAME = "ubuntu-22.04-jammy-server-cloud-image-amd64"
# The public key to be used for SSH connection, please make sure, that you have the # The public key to be used for SSH connection, please make sure, that you have the
# corresponding private key # 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 = 'srieger-pub'
PUB_KEY_FILE = '~/.ssh/id_rsa.pub' PUB_KEY_FILE = '~/.ssh/id_rsa.pub'
...@@ -175,9 +176,8 @@ def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements, ...@@ -175,9 +176,8 @@ def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements,
# #
########################################################################### ###########################################################################
hsfd_faafo_cloud_init_script = 'https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh' # noqa: E501 pylint: disable=line-too-long # new repo on git-ce.rwth-aachen.de:
# testing / faafo dev branch: hsfd_faafo_cloud_init_script = 'https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/-/raw/master/faafo/contrib/install.sh'
# 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' # noqa: E501 pylint: disable=line-too-long
userdata = '#!/usr/bin/env bash\n' \ userdata = '#!/usr/bin/env bash\n' \
f'curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- ' \ f'curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- ' \
......
"""Example for Cloud Computing Course Master AI / GSD""" """Example for Cloud Computing Course Master AI / GSD"""
# This script demonstrates how to use libcloud to start an instance in an OpenStack environment. # This script demonstrates how to use libcloud to start an instance in an OpenStack environment.
# The script will create start multiple instances splitting up the faafo monolithic application into # The script will start multiple instances splitting up the faafo monolithic application into
# a (minimalistic but already scalable) microservice architecture. # a (minimalistic but already scalable) microservice architecture.
# Also introduces the concept of different security groups and corresponding frontend/backend # Also introduces the concept of different security groups and corresponding frontend/backend
# separation. # separation.
...@@ -35,8 +35,8 @@ if group_number is None: ...@@ -35,8 +35,8 @@ if group_number is None:
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
# auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.182:5000'
# auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.29:5000'
# your username in OpenStack # your username in OpenStack
AUTH_USERNAME = 'CloudComp' + str(group_number) AUTH_USERNAME = 'CloudComp' + str(group_number)
print(f'Using username: {AUTH_USERNAME}\n') print(f'Using username: {AUTH_USERNAME}\n')
...@@ -47,14 +47,14 @@ PROJECT_NETWORK = 'CloudComp' + str(group_number) + '-net' ...@@ -47,14 +47,14 @@ 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" # ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img" #UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img"
UBUNTU_IMAGE_NAME = "ubuntu-22.04-jammy-server-cloud-image-amd64"
# The public key to be used for SSH connection, please make sure, that you have the # The public key to be used for SSH connection, please make sure, that you have the
# corresponding private key # 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 = 'srieger-pub'
PUB_KEY_FILE = '~/.ssh/id_rsa.pub' PUB_KEY_FILE = '~/.ssh/id_rsa.pub'
...@@ -192,9 +192,11 @@ def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements, ...@@ -192,9 +192,11 @@ def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements,
# #
########################################################################### ###########################################################################
# new repo on git-ce.rwth-aachen.de:
hsfd_faafo_cloud_init_script = 'https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/-/raw/master/faafo/contrib/install.sh'
userdata = '#!/usr/bin/env bash\n' \ userdata = '#!/usr/bin/env bash\n' \
'curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-' \ f'curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- ' \
'examples/raw/master/faafo/contrib/install.sh | bash -s -- ' \
'-i messaging -i faafo -r api\n' '-i messaging -i faafo -r api\n'
print('\nUsing cloud-init userdata for controller:\n"' + userdata + '"\n') print('\nUsing cloud-init userdata for controller:\n"' + userdata + '"\n')
...@@ -252,8 +254,7 @@ def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements, ...@@ -252,8 +254,7 @@ def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements,
########################################################################### ###########################################################################
userdata = '#!/usr/bin/env bash\n' \ userdata = '#!/usr/bin/env bash\n' \
'curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-' \ f'curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- ' \
'examples/raw/master/faafo/contrib/install.sh | bash -s -- ' \
f'-i faafo -r worker -e "http://{ip_controller}" -m "amqp://faafo:guest@' \ f'-i faafo -r worker -e "http://{ip_controller}" -m "amqp://faafo:guest@' \
f'{ip_controller}:5672/"\n' f'{ip_controller}:5672/"\n'
print('\nUsing cloud-init userdata for worker:\n"' + userdata + '"\n') print('\nUsing cloud-init userdata for worker:\n"' + userdata + '"\n')
......
# import getpass """Example for Cloud Computing Course Master AI / GSD"""
# import os
# import libcloud.security # This script demonstrates how to use libcloud to start an instance in an OpenStack environment.
# The script will start multiple instances splitting up the faafo monolithic application into
# a microservice architecture with scalable api (controller) and worker instances using a
# message queue and a database
# Needed if the password should be prompted for:
# import getpass
import os
import sys
import time import time
from libcloud.compute.providers import get_driver from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider from libcloud.compute.types import Provider
# reqs: # For our new Charmed OpenStack private cloud, we need to specify the path to the root
# services: nova, glance, neutron # CA certificate
# resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups) import libcloud.security
libcloud.security.CA_CERTS_PATH = ['./root-ca.crt']
# Disable SSL certificate verification (not recommended for production)
# libcloud.security.VERIFY_SSL_CERT = False
# 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 as environment variable GROUP_NUMBER to specify your group number.
# project etc., as coordinated in the lab sessions) # (will be used for the username, project etc., as coordinated in the lab sessions)
group_number = 2 group_number = os.environ.get('GROUP_NUMBER')
if group_number is None:
sys.exit('Please set the GROUP_NUMBER environment variable to your group number,\n'
'e.g., on Windows:\n'
' "$env:GROUP_NUMBER=0" or "set GROUP_NUMBER=0"\n'
'or on Linux/MacOS:\n'
' "export GROUP_NUMBER=0" or "set GROUP_NUMBER=0"')
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.29:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudComp' + str(group_number) AUTH_USERNAME = 'CloudComp' + str(group_number)
print(f'Using username: {AUTH_USERNAME}\n')
# your project in OpenStack # your project in OpenStack
project_name = 'CloudComp' + str(group_number) PROJECT_NAME = 'CloudComp' + str(group_number)
# A network in the project the started instance will be attached to # A network in the project the started instance will be attached to
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 20.04 - Focal Fossa - 64-bit - Cloud Based Image" # ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
ubuntu_image_name = "Ubuntu 22.04 - Jammy Jellyfish - 64-bit - Cloud Based Image" #UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img"
UBUNTU_IMAGE_NAME = "ubuntu-22.04-jammy-server-cloud-image-amd64"
# The public key to be used for SSH connection, please make sure, that you have the
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key # 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'
PUB_KEY_FILE = '~/.ssh/id_rsa.pub'
#keypair_name = 'CloudComp30-keypair' FLAVOR_NAME = 'm1.small'
keypair_name = "srieger-pub"
pub_key_file = '~/.ssh/id_rsa.pub'
flavor_name = 'm1.small'
# default region # default region
region_name = 'RegionOne' REGION_NAME = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username # domain to use, "default" for local accounts, formerly "hsfulda" for LDAP accounts etc.
domain_name = "default" # domain_name = "default"
def main(): def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements,too-many-locals,missing-function-docstring
########################################################################### ###########################################################################
# #
# get credentials # get credentials
...@@ -67,16 +86,14 @@ def main(): ...@@ -67,16 +86,14 @@ def main():
# #
########################################################################### ###########################################################################
# libcloud.security.VERIFY_SSL_CERT = False
provider = get_driver(Provider.OPENSTACK) provider = get_driver(Provider.OPENSTACK)
conn = provider(auth_username, conn = provider(AUTH_USERNAME,
auth_password, auth_password,
ex_force_auth_url=auth_url, ex_force_auth_url=AUTH_URL,
ex_force_auth_version='3.x_password', ex_force_auth_version='3.x_password',
ex_tenant_name=project_name, ex_tenant_name=PROJECT_NAME,
ex_force_service_region=region_name, ex_force_service_region=REGION_NAME)
ex_domain_name=domain_name) # ex_domain_name=domain_name)
########################################################################### ###########################################################################
# #
...@@ -87,19 +104,19 @@ def main(): ...@@ -87,19 +104,19 @@ def main():
images = conn.list_images() images = conn.list_images()
image = '' image = ''
for img in images: for img in images:
if img.name == ubuntu_image_name: if img.name == UBUNTU_IMAGE_NAME:
image = img image = img
flavors = conn.list_sizes() flavors = conn.list_sizes()
flavor = '' flavor = ''
for flav in flavors: for flav in flavors:
if flav.name == flavor_name: if flav.name == FLAVOR_NAME:
flavor = conn.ex_get_size(flav.id) flavor = conn.ex_get_size(flav.id)
networks = conn.ex_list_networks() networks = conn.ex_list_networks()
network = '' network = ''
for net in networks: for net in networks:
if net.name == project_network: if net.name == PROJECT_NETWORK:
network = net network = net
########################################################################### ###########################################################################
...@@ -111,14 +128,14 @@ def main(): ...@@ -111,14 +128,14 @@ def main():
print('Checking for existing SSH key pair...') print('Checking for existing SSH key pair...')
keypair_exists = False keypair_exists = False
for keypair in conn.list_key_pairs(): for keypair in conn.list_key_pairs():
if keypair.name == keypair_name: if keypair.name == KEYPAIR_NAME:
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)
for keypair in conn.list_key_pairs(): for keypair in conn.list_key_pairs():
print(keypair) print(keypair)
...@@ -131,9 +148,10 @@ def main(): ...@@ -131,9 +148,10 @@ def main():
# destroy running demo instances # destroy running demo instances
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(f'Destroying Instance: ${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
...@@ -151,7 +169,7 @@ def main(): ...@@ -151,7 +169,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(f'Deleting security group: ${group.name}')
conn.ex_delete_security_group(group) conn.ex_delete_security_group(group)
########################################################################### ###########################################################################
...@@ -165,7 +183,8 @@ def main(): ...@@ -165,7 +183,8 @@ def main():
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
...@@ -177,20 +196,23 @@ def main(): ...@@ -177,20 +196,23 @@ def main():
api_security_group = get_security_group(conn, "api") api_security_group = get_security_group(conn, "api")
if not get_security_group(conn, "worker"): if not get_security_group(conn, "worker"):
worker_security_group = conn.ex_create_security_group('worker', 'for services that run on a worker node') worker_security_group = conn.ex_create_security_group(
'worker', 'for services that run on a worker node')
conn.ex_create_security_group_rule(worker_security_group, 'TCP', 22, 22) conn.ex_create_security_group_rule(worker_security_group, 'TCP', 22, 22)
else: else:
worker_security_group = get_security_group(conn, "worker") worker_security_group = get_security_group(conn, "worker")
if not get_security_group(conn, "control"): if not get_security_group(conn, "control"):
controller_security_group = conn.ex_create_security_group('control', 'for services that run on a control node') controller_security_group = conn.ex_create_security_group(
'control', 'for services that run on a control node')
conn.ex_create_security_group_rule(controller_security_group, 'TCP', 22, 22) conn.ex_create_security_group_rule(controller_security_group, 'TCP', 22, 22)
conn.ex_create_security_group_rule(controller_security_group, 'TCP', 80, 80) conn.ex_create_security_group_rule(controller_security_group, 'TCP', 80, 80)
conn.ex_create_security_group_rule(controller_security_group, 'TCP', 5672, 5672, conn.ex_create_security_group_rule(controller_security_group, 'TCP', 5672, 5672,
source_security_group=worker_security_group) source_security_group=worker_security_group)
if not get_security_group(conn, "services"): if not get_security_group(conn, "services"):
services_security_group = conn.ex_create_security_group('services', 'for DB and AMQP services only') services_security_group = conn.ex_create_security_group(
'services', 'for DB and AMQP services only')
conn.ex_create_security_group_rule(services_security_group, 'TCP', 22, 22) conn.ex_create_security_group_rule(services_security_group, 'TCP', 22, 22)
conn.ex_create_security_group_rule(services_security_group, 'TCP', 3306, 3306, conn.ex_create_security_group_rule(services_security_group, 'TCP', 3306, 3306,
source_security_group=api_security_group) source_security_group=api_security_group)
...@@ -228,24 +250,20 @@ def main(): ...@@ -228,24 +250,20 @@ def main():
# #
########################################################################### ###########################################################################
#hsfd_faafo_cloud_init_script = 'https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh' # new repo on git-ce.rwth-aachen.de:
# testing / faafo dev branch: hsfd_faafo_cloud_init_script = 'https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/-/raw/master/faafo/contrib/install.sh'
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\n' \
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ f'curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- ' \
-i database -i messaging '-i database -i messaging\n'
rabbitmqctl add_user faafo guest print('\nUsing cloud-init userdata for service:\n"' + userdata_service + '"\n')
rabbitmqctl set_user_tags faafo administrator
rabbitmqctl set_permissions -p / faafo ".*" ".*" ".*"
'''
print('Starting new app-services instance and wait until it is running...') print('Starting new app-services instance and wait until it is running...')
instance_services = conn.create_node(name='app-services', instance_services = conn.create_node(name='app-services',
image=image, image=image,
size=flavor, size=flavor,
networks=[network], networks=[network],
ex_keyname=keypair_name, ex_keyname=KEYPAIR_NAME,
ex_userdata=userdata_service, ex_userdata=userdata_service,
ex_security_groups=[services_security_group]) ex_security_groups=[services_security_group])
instance_services = conn.wait_until_running(nodes=[instance_services], timeout=120, instance_services = conn.wait_until_running(nodes=[instance_services], timeout=120,
...@@ -258,18 +276,18 @@ def main(): ...@@ -258,18 +276,18 @@ def main():
# #
########################################################################### ###########################################################################
userdata_api = '''#!/usr/bin/env bash userdata_api = '#!/usr/bin/env bash\n' \
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ f'curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- ' \
-i faafo -r api -m 'amqp://faafo:guest@%(services_ip)s:5672/' \ f'-i faafo -r api -m "amqp://faafo:guest@{services_ip}:5672/" ' \
-d 'mysql+pymysql://faafo:password@%(services_ip)s:3306/faafo' f'-d "mysql+pymysql://faafo:password@{services_ip}:3306/faafo"'
''' % {'services_ip': services_ip} print('\nUsing cloud-init userdata for api:\n"' + userdata_api + '"\n')
print('Starting new app-api-1 instance and wait until it is running...') print('Starting new app-api-1 instance and wait until it is running...')
instance_api_1 = conn.create_node(name='app-api-1', instance_api_1 = conn.create_node(name='app-api-1',
image=image, image=image,
size=flavor, size=flavor,
networks=[network], networks=[network],
ex_keyname=keypair_name, ex_keyname=KEYPAIR_NAME,
ex_userdata=userdata_api, ex_userdata=userdata_api,
ex_security_groups=[api_security_group]) ex_security_groups=[api_security_group])
...@@ -278,7 +296,7 @@ def main(): ...@@ -278,7 +296,7 @@ def main():
image=image, image=image,
size=flavor, size=flavor,
networks=[network], networks=[network],
ex_keyname=keypair_name, ex_keyname=KEYPAIR_NAME,
ex_userdata=userdata_api, ex_userdata=userdata_api,
ex_security_groups=[api_security_group]) ex_security_groups=[api_security_group])
...@@ -292,7 +310,8 @@ def main(): ...@@ -292,7 +310,8 @@ 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}))
########################################################################### ###########################################################################
# #
...@@ -300,10 +319,12 @@ def main(): ...@@ -300,10 +319,12 @@ def main():
# #
########################################################################### ###########################################################################
userdata_worker = '''#!/usr/bin/env bash userdata_worker = '#!/usr/bin/env bash\n' \
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ f'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/' f'-i faafo -r worker -e "http://{api_1_ip}" '\
''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip} f'-m "amqp://faafo:guest@{services_ip}:5672/"'
print('\nUsing cloud-init userdata for worker:\n"' + userdata_worker + '"\n')
# userdata_api-api-2 = '''#!/usr/bin/env bash # userdata_api-api-2 = '''#!/usr/bin/env bash
# curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ # curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \
...@@ -314,7 +335,7 @@ def main(): ...@@ -314,7 +335,7 @@ def main():
instance_worker_1 = conn.create_node(name='app-worker-1', instance_worker_1 = conn.create_node(name='app-worker-1',
image=image, size=flavor, image=image, size=flavor,
networks=[network], networks=[network],
ex_keyname=keypair_name, ex_keyname=KEYPAIR_NAME,
ex_userdata=userdata_worker, ex_userdata=userdata_worker,
ex_security_groups=[worker_security_group]) ex_security_groups=[worker_security_group])
...@@ -322,7 +343,7 @@ def main(): ...@@ -322,7 +343,7 @@ def main():
instance_worker_2 = conn.create_node(name='app-worker-2', instance_worker_2 = conn.create_node(name='app-worker-2',
image=image, size=flavor, image=image, size=flavor,
networks=[network], networks=[network],
ex_keyname=keypair_name, ex_keyname=KEYPAIR_NAME,
ex_userdata=userdata_worker, ex_userdata=userdata_worker,
ex_security_groups=[worker_security_group]) ex_security_groups=[worker_security_group])
......
"""Example for Cloud Computing Course Master AI / GSD"""
# This script demonstrates how to use libcloud to start an instance in an OpenStack environment.
# The script will add an additional worker to a running faafo example application
# Needed if the password should be prompted for:
# import getpass # import getpass
# import os import os
# import libcloud.security import sys
# import time
import time
from libcloud.compute.providers import get_driver from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider from libcloud.compute.types import Provider
# reqs: # For our new Charmed OpenStack private cloud, we need to specify the path to the root
# services: nova, glance, neutron # CA certificate
# resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups) import libcloud.security
libcloud.security.CA_CERTS_PATH = ['./root-ca.crt']
# Disable SSL certificate verification (not recommended for production)
# libcloud.security.VERIFY_SSL_CERT = False
# 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 as environment variable GROUP_NUMBER to specify your group number.
# project etc., as coordinated in the lab sessions) # (will be used for the username, project etc., as coordinated in the lab sessions)
group_number = X group_number = os.environ.get('GROUP_NUMBER')
if group_number is None:
sys.exit('Please set the GROUP_NUMBER environment variable to your group number,\n'
'e.g., on Windows:\n'
' "$env:GROUP_NUMBER=0" or "set GROUP_NUMBER=0"\n'
'or on Linux/MacOS:\n'
' "export GROUP_NUMBER=0" or "set GROUP_NUMBER=0"')
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.29:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudComp' + str(group_number) AUTH_USERNAME = 'CloudComp' + str(group_number)
print(f'Using username: {AUTH_USERNAME}\n')
# your project in OpenStack # your project in OpenStack
project_name = 'CloudComp' + str(group_number) PROJECT_NAME = 'CloudComp' + str(group_number)
# A network in the project the started instance will be attached to # A network in the project the started instance will be attached to
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 20.04 - Focal Fossa - 64-bit - Cloud Based Image" # ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
ubuntu_image_name = "Ubuntu 22.04 - Jammy Jellyfish - 64-bit - Cloud Based Image" #UBUNTU_IMAGE_NAME = "auto-sync/ubuntu-jammy-22.04-amd64-server-20240319-disk1.img"
UBUNTU_IMAGE_NAME = "ubuntu-22.04-jammy-server-cloud-image-amd64"
# 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'
PUB_KEY_FILE = '~/.ssh/id_rsa.pub'
#keypair_name = 'CloudComp30-keypair' FLAVOR_NAME = 'm1.small'
keypair_name = "srieger-pub"
pub_key_file = '~/.ssh/id_rsa.pub'
flavor_name = 'm1.small'
# default region # default region
region_name = 'RegionOne' REGION_NAME = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username # domain to use, "default" for local accounts, formerly "hsfulda" for LDAP accounts etc.
domain_name = "default" # domain_name = "default"
def main(): def main(): # noqa: C901 pylint: disable=too-many-branches,too-many-statements,too-many-locals,missing-function-docstring
########################################################################### ###########################################################################
# #
# get credentials # get credentials
...@@ -66,16 +84,14 @@ def main(): ...@@ -66,16 +84,14 @@ def main():
# #
########################################################################### ###########################################################################
# libcloud.security.VERIFY_SSL_CERT = False
provider = get_driver(Provider.OPENSTACK) provider = get_driver(Provider.OPENSTACK)
conn = provider(auth_username, conn = provider(AUTH_USERNAME,
auth_password, auth_password,
ex_force_auth_url=auth_url, ex_force_auth_url=AUTH_URL,
ex_force_auth_version='3.x_password', ex_force_auth_version='3.x_password',
ex_tenant_name=project_name, ex_tenant_name=PROJECT_NAME,
ex_force_service_region=region_name, ex_force_service_region=REGION_NAME)
ex_domain_name=domain_name) # ex_domain_name=domain_name)
########################################################################### ###########################################################################
# #
...@@ -86,19 +102,19 @@ def main(): ...@@ -86,19 +102,19 @@ def main():
images = conn.list_images() images = conn.list_images()
image = '' image = ''
for img in images: for img in images:
if img.name == ubuntu_image_name: if img.name == UBUNTU_IMAGE_NAME:
image = img image = img
flavors = conn.list_sizes() flavors = conn.list_sizes()
flavor = '' flavor = ''
for flav in flavors: for flav in flavors:
if flav.name == flavor_name: if flav.name == FLAVOR_NAME:
flavor = conn.ex_get_size(flav.id) flavor = conn.ex_get_size(flav.id)
networks = conn.ex_list_networks() networks = conn.ex_list_networks()
network = '' network = ''
for net in networks: for net in networks:
if net.name == project_network: if net.name == PROJECT_NETWORK:
network = net network = net
########################################################################### ###########################################################################
...@@ -117,6 +133,7 @@ def main(): ...@@ -117,6 +133,7 @@ def main():
api_1_ip = instance.private_ips[0] api_1_ip = instance.private_ips[0]
print(('Found app-api-1 fixed IP to be: ', api_1_ip)) print(('Found app-api-1 fixed IP to be: ', api_1_ip))
########################################################################### ###########################################################################
# #
# create keypair dependency # create keypair dependency
...@@ -126,18 +143,19 @@ def main(): ...@@ -126,18 +143,19 @@ def main():
print('Checking for existing SSH key pair...') print('Checking for existing SSH key pair...')
keypair_exists = False keypair_exists = False
for keypair in conn.list_key_pairs(): for keypair in conn.list_key_pairs():
if keypair.name == keypair_name: if keypair.name == KEYPAIR_NAME:
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)
for keypair in conn.list_key_pairs(): for keypair in conn.list_key_pairs():
print(keypair) print(keypair)
########################################################################### ###########################################################################
# #
# create security group dependency # create security group dependency
...@@ -149,12 +167,14 @@ def main(): ...@@ -149,12 +167,14 @@ def main():
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 security_grp return security_grp
return False return False
if not get_security_group(conn, "worker"): if not get_security_group(conn, "worker"):
worker_security_group = conn.ex_create_security_group('worker', 'for services that run on a worker node') worker_security_group = conn.ex_create_security_group(
'worker', 'for services that run on a worker node')
conn.ex_create_security_group_rule(worker_security_group, 'TCP', 22, 22) conn.ex_create_security_group_rule(worker_security_group, 'TCP', 22, 22)
else: else:
worker_security_group = get_security_group(conn, "worker") worker_security_group = get_security_group(conn, "worker")
...@@ -162,20 +182,21 @@ def main(): ...@@ -162,20 +182,21 @@ def main():
for security_group in conn.ex_list_security_groups(): for security_group in conn.ex_list_security_groups():
print(security_group) print(security_group)
########################################################################### ###########################################################################
# #
# create worker instances # create worker instances
# #
########################################################################### ###########################################################################
#hsfd_faafo_cloud_init_script = 'https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh' # new repo on git-ce.rwth-aachen.de:
# testing / faafo dev branch: hsfd_faafo_cloud_init_script = 'https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/-/raw/master/faafo/contrib/install.sh'
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_worker = '''#!/usr/bin/env bash userdata_worker = '#!/usr/bin/env bash\n' \
curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ f'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/' f'-i faafo -r worker -e "http://{api_1_ip}" '\
''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip} f'-m "amqp://faafo:guest@{services_ip}:5672/"'
print('\nUsing cloud-init userdata for worker:\n"' + userdata_worker + '"\n')
# userdata-api-2 = '''#!/usr/bin/env bash # userdata-api-2 = '''#!/usr/bin/env bash
# curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \ # curl -L -s ''' + hsfd_faafo_cloud_init_script + ''' | bash -s -- \
...@@ -186,7 +207,7 @@ def main(): ...@@ -186,7 +207,7 @@ def main():
instance_worker_3 = conn.create_node(name='app-worker-3', instance_worker_3 = conn.create_node(name='app-worker-3',
image=image, size=flavor, image=image, size=flavor,
networks=[network], networks=[network],
ex_keyname=keypair_name, ex_keyname=KEYPAIR_NAME,
ex_userdata=userdata_worker, ex_userdata=userdata_worker,
ex_security_groups=[worker_security_group]) ex_security_groups=[worker_security_group])
......
...@@ -39,7 +39,7 @@ if group_number is None: ...@@ -39,7 +39,7 @@ if group_number is None:
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
# auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
AUTH_URL = 'https://10.32.4.182:5000' AUTH_URL = 'https://10.32.4.29:5000'
# auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000' # auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
# your username in OpenStack # your username in OpenStack
AUTH_USERNAME = 'CloudComp' + str(group_number) AUTH_USERNAME = 'CloudComp' + str(group_number)
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
"VERTSYS_PATH=\"$SCRIPT_ROOT_PATH/verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/\"\n", "VERTSYS_PATH=\"$SCRIPT_ROOT_PATH/verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/\"\n",
"#JARS = \"TCPServer.jar TCPServerMulti.jar UDPServer.jar UDPServerMulti.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPPerfServer.jar\"\n", "#JARS = \"TCPServer.jar TCPServerMulti.jar UDPServer.jar UDPServerMulti.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPPerfServer.jar\"\n",
"JARS=\"TCPServer.jar TCPPerfServer.jar UDPServer.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPTimeCounterRESTServer.jar\"\n", "JARS=\"TCPServer.jar TCPPerfServer.jar UDPServer.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPTimeCounterRESTServer.jar\"\n",
"REPO=\"https://gogs.informatik.hs-fulda.de/srieger/verteilte-systeme-bsc-ai-examples.git\"\n", "REPO=\"https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples.git\"\n",
"\n", "\n",
"# Create path to run the script\n", "# Create path to run the script\n",
"mkdir $SCRIPT_ROOT_PATH\n", "mkdir $SCRIPT_ROOT_PATH\n",
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
"VERTSYS_PATH=\"$SCRIPT_ROOT_PATH/verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/\"\n", "VERTSYS_PATH=\"$SCRIPT_ROOT_PATH/verteilte-systeme-bsc-ai-examples/VerteilteSysteme-Examples/build/\"\n",
"#JARS = \"TCPServer.jar TCPServerMulti.jar UDPServer.jar UDPServerMulti.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPPerfServer.jar\"\n", "#JARS = \"TCPServer.jar TCPServerMulti.jar UDPServer.jar UDPServerMulti.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPPerfServer.jar\"\n",
"JARS=\"TCPServer.jar TCPPerfServer.jar UDPServer.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPTimeCounterRESTServer.jar\"\n", "JARS=\"TCPServer.jar TCPPerfServer.jar UDPServer.jar UDPTimeCounterServer.jar TCPTimeCounterServer.jar TCPTimeCounterRESTServer.jar\"\n",
"REPO=\"https://gogs.informatik.hs-fulda.de/srieger/verteilte-systeme-bsc-ai-examples.git\"\n", "REPO=\"https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples.git\"\n",
"\n", "\n",
"# Create path to run the script\n", "# Create path to run the script\n",
"mkdir $SCRIPT_ROOT_PATH\n", "mkdir $SCRIPT_ROOT_PATH\n",
......
...@@ -131,7 +131,10 @@ print("Lambda Function and S3 Bucket to store the counter are available.\n" ...@@ -131,7 +131,10 @@ print("Lambda Function and S3 Bucket to store the counter are available.\n"
"Try to understand how Lambda can be used to cut costs regarding cloud services and what its pros\n" "Try to understand how Lambda can be used to cut costs regarding cloud services and what its pros\n"
"and cons are.\n") "and cons are.\n")
# sadly, AWS Academy Labs don't allow API gateways # API gateways require a Pro license from localstack, as a student you can apply for
# a hobby/open source dev license, that's the same license that I used for the demo in the
# lab/lecture
# API gateway would allow getting an HTTP endpoint that we could access directly in the browser, # API gateway would allow getting an HTTP endpoint that we could access directly in the browser,
# that would call our function, as in the provided demo: # that would call our function, as in the provided demo:
# #
......
...@@ -28,6 +28,8 @@ functionName = 'cloudcomp-counter-lambda-demo' ...@@ -28,6 +28,8 @@ functionName = 'cloudcomp-counter-lambda-demo'
# see ARN for AWS Academy LabRole function here: # see ARN for AWS Academy LabRole function here:
# https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/LabRole?section=permissions # https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/LabRole?section=permissions
# #
# e.g.: (309000625112, 919927306708, 488766701848 would in your case be your AWS Account ID, see Lab Details)
#
# roleArn = 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3' # roleArn = 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# roleArn = 'arn:aws:iam::919927306708:role/cloudcomp-s3-access' # roleArn = 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
# roleArn = 'arn:aws:iam::488766701848:role/LabRole' # roleArn = 'arn:aws:iam::488766701848:role/LabRole'
...@@ -68,6 +70,16 @@ for role in response["Roles"]: ...@@ -68,6 +70,16 @@ for role in response["Roles"]:
roleArn = role["Arn"] roleArn = role["Arn"]
print(roleArn) print(roleArn)
print("Searching for old API gateway...")
print("------------------------------------")
for api in apiClient.get_apis()["Items"]:
if api["Name"] == functionName + '-api':
print("Deleting old API gateway...")
print("------------------------------------")
response = apiClient.delete_api(
ApiId=api["ApiId"],
)
print("Deleting old function...") print("Deleting old function...")
print("------------------------------------") print("------------------------------------")
try: try:
...@@ -84,8 +96,8 @@ try: ...@@ -84,8 +96,8 @@ try:
currentBucket = s3Resource.Bucket(globallyUniqueS3GroupBucketName) currentBucket = s3Resource.Bucket(globallyUniqueS3GroupBucketName)
cleanup_s3_bucket(currentBucket) cleanup_s3_bucket(currentBucket)
currentBucket.delete() currentBucket.delete()
except ClientError as e: except s3Client.exceptions.NoSuchBucket:
print(e) print('Bucket not available. No need to delete it.')
print("creating S3 bucket (must be globally unique)...") print("creating S3 bucket (must be globally unique)...")
print("------------------------------------") print("------------------------------------")
...@@ -124,11 +136,25 @@ with open('lambda-deployment-archive.zip', mode='rb') as file: ...@@ -124,11 +136,25 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
) )
lambdaFunctionARN = response['FunctionArn'] lambdaFunctionARN = response['FunctionArn']
print("Lambda Function and S3 Bucket to store the counter are available. Sadly, AWS Academy labs do not allow\n" # API gateway to get an HTTP endpoint that we can access directly in the browser,
"creating an API gateway to be able to access the Lambda function directly via HTTP from the browser, as\n" # which will call our function, as in the provided demo:
"shown in https://348yxdily0.execute-api.eu-central-1.amazonaws.com/default/cloudcomp-counter-demo.\n" # https://348yxdily0.execute-api.eu-central-1.amazonaws.com/default/cloudcomp-counter-demo
print("creating API gateway...")
print("------------------------------------")
response = apiClient.create_api(
Name=functionName + '-api',
ProtocolType='HTTP',
Target=lambdaFunctionARN,
CredentialsArn=roleArn
)
print("Lambda Function and S3 Bucket to store the counter are created.\n"
"\n" "\n"
"However you can now run invoke-function.py to view an increment the counter. You can also use \n" "You can access the API gateway and increment the counter using the created Lambda function\n"
"at: " + response["ApiEndpoint"] + " \n"
"You can also run invoke-function.py to view an increment the counter. You can also use \n"
"the test button in the Lambda AWS console. In this case you need to send the content\n" "the test button in the Lambda AWS console. In this case you need to send the content\n"
"\n" "\n"
"{\n" "{\n"
...@@ -138,18 +164,3 @@ print("Lambda Function and S3 Bucket to store the counter are available. Sadly, ...@@ -138,18 +164,3 @@ print("Lambda Function and S3 Bucket to store the counter are available. Sadly,
"to increment the counter by 1.\n" "to increment the counter by 1.\n"
"Try to understand how Lambda can be used to cut costs regarding cloud services and what its pros\n" "Try to understand how Lambda can be used to cut costs regarding cloud services and what its pros\n"
"and cons are.\n") "and cons are.\n")
\ No newline at end of file
# sadly, AWS Academy Labs don't allow API gateways
# API gateway would allow getting an HTTP endpoint that we could access directly in the browser,
# that would call our function, as in the provided demo:
#
# https://348yxdily0.execute-api.eu-central-1.amazonaws.com/default/cloudcomp-counter-demo
#
# print("creating API gateway...")
# print("------------------------------------")
#
# response = apiClient.create_api(
# Name=functionName + '-api',
# ProtocolType='HTTP',
# Target=lambdaFunctionARN
# )
...@@ -36,8 +36,19 @@ client = boto3.setup_default_session(region_name=region) ...@@ -36,8 +36,19 @@ client = boto3.setup_default_session(region_name=region)
s3Client = boto3.client('s3') s3Client = boto3.client('s3')
s3Resource = boto3.resource('s3') s3Resource = boto3.resource('s3')
lClient = boto3.client('lambda') lClient = boto3.client('lambda')
apiClient = boto3.client("apigatewayv2")
print("Searching for old API gateway...")
print("------------------------------------")
for api in apiClient.get_apis()["Items"]:
if api["Name"] == functionName + '-api':
print("Deleting old API gateway...")
print("------------------------------------")
response = apiClient.delete_api(
ApiId=api["ApiId"],
)
print("Deleting old function...") print("Deleting old function...")
print("------------------------------------") print("------------------------------------")
try: try:
...@@ -54,5 +65,5 @@ try: ...@@ -54,5 +65,5 @@ try:
currentBucket = s3Resource.Bucket(globallyUniqueS3GroupBucketName) currentBucket = s3Resource.Bucket(globallyUniqueS3GroupBucketName)
cleanup_s3_bucket(currentBucket) cleanup_s3_bucket(currentBucket)
currentBucket.delete() currentBucket.delete()
except ClientError as e: except s3Client.exceptions.NoSuchBucket:
print(e) print('Bucket not available. No need to delete it.')
...@@ -14,8 +14,8 @@ home = expanduser("~") ...@@ -14,8 +14,8 @@ home = expanduser("~")
# IP, but elastic ips are expensive - make sure to delete them after you used them # IP, but elastic ips are expensive - make sure to delete them after you used them
# 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/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210128' # aws ec2 describe-images --owner amazon | grep ubuntu | grep jammy | grep hvm | grep ssd |grep amd64 | grep -v minimal | grep -v pro | grep -v testing | grep -v k8s | grep "Name"
# TODO: 18.04, currently still needed for faafo, need to port faafo demo app to 20.04 or higher and python3... ubuntu_image_name = 'ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240319'
# 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
...@@ -203,8 +203,11 @@ def main(): ...@@ -203,8 +203,11 @@ def main():
# #
# Thanks to Stefan Friedmann for finding this fix ;) # Thanks to Stefan Friedmann for finding this fix ;)
userdata = '''#!/usr/bin/env bash # new repo on git-ce.rwth-aachen.de:
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install-aws.sh | bash -s -- \ hsfd_faafo_cloud_init_script = 'https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/-/raw/master/faafo/contrib/install-aws.sh'
userdata = f'''#!/usr/bin/env bash
curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- \
-i messaging -i faafo -r api -i messaging -i faafo -r api
rabbitmqctl add_user faafo guest rabbitmqctl add_user faafo guest
rabbitmqctl set_user_tags faafo administrator rabbitmqctl set_user_tags faafo administrator
...@@ -268,8 +271,8 @@ def main(): ...@@ -268,8 +271,8 @@ def main():
# #
########################################################################### ###########################################################################
userdata = '''#!/usr/bin/env bash userdata = f'''#!/usr/bin/env bash
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install-aws.sh | bash -s -- \ curl -L -s {hsfd_faafo_cloud_init_script} | bash -s -- \
-i faafo -r worker -e 'http://%(ip_controller)s' -m 'amqp://faafo:guest@%(ip_controller)s:5672/' -i faafo -r worker -e 'http://%(ip_controller)s' -m 'amqp://faafo:guest@%(ip_controller)s:5672/'
''' % {'ip_controller': private_ip_controller} ''' % {'ip_controller': private_ip_controller}
......
...@@ -21,9 +21,9 @@ home = expanduser("~") ...@@ -21,9 +21,9 @@ home = expanduser("~")
# 1 (Classic) Elastic Load Balancer, expensive! delete it after you used it! # 1 (Classic) Elastic Load Balancer, expensive! delete it after you used it!
# 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/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210128' # aws ec2 describe-images --owner amazon | grep ubuntu | grep jammy | grep hvm | grep ssd |grep amd64 | grep -v minimal | grep -v pro | grep -v testing | grep -v k8s | grep "Name"
ubuntu_image_name = 'ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240319'
# ubuntu_image_name = 'ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210128' # ubuntu_image_name = 'ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-20210128'
# TODO: 18.04, currently still needed for faafo, need to port faafo demo app to 20.04 or higher and python3...
# 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
...@@ -118,16 +118,12 @@ def main(): ...@@ -118,16 +118,12 @@ def main():
# #
print("Selecting AMI...") print("Selecting AMI...")
# us-east-1 examples as of 9.5.2022: # us-east-1 examples as of 23.05.2024:
# #
# Canonical, Ubuntu, 18.04 LTS, amd64 bionic image build on 2022-04-11 # https://cloud-images.ubuntu.com/locator/ec2/
image_id = "ami-005de95e8ff495156"
#
# Canonical, Ubuntu, 20.04 LTS, amd64 focal image build on 2022-04-19
# image_id = "ami-0c4f7023847b90238"
# #
# Canonical, Ubuntu, 22.04 LTS, amd64 jammy image build on 2022-04-20 # Canonical, Ubuntu, 22.04 LTS, amd64 jammy image build on 2022-04-20
# image_id = "ami-09d56f8956ab235b3" image_id = "ami-012485deee5681dc0"
# #
image = conn.list_images(ex_image_ids=[image_id])[0] image = conn.list_images(ex_image_ids=[image_id])[0]
print("Using image: %s" % image) print("Using image: %s" % image)
...@@ -284,14 +280,17 @@ def main(): ...@@ -284,14 +280,17 @@ def main():
# #
########################################################################### ###########################################################################
# https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh # https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install-aws.sh
# is currently broken, hence the "rabbitctl" lines were added in the example # is currently broken, hence the "rabbitctl" lines were added in the example
# below, see also https://bugs.launchpad.net/faafo/+bug/1679710 # below, see also https://bugs.launchpad.net/faafo/+bug/1679710
# #
# Thanks to Stefan Friedmann for finding this fix ;) # Thanks to Stefan Friedmann for finding this fix ;)
userdata_service = '''#!/usr/bin/env bash # new repo on git-ce.rwth-aachen.de:
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \ hsfd_faafo_cloud_init_script = 'https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/-/raw/master/faafo/contrib/install-aws.sh'
userdata_service = f'''#!/usr/bin/env bash
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
...@@ -316,8 +315,8 @@ def main(): ...@@ -316,8 +315,8 @@ def main():
# #
########################################################################### ###########################################################################
userdata_api = '''#!/usr/bin/env bash userdata_api = f'''#!/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}
...@@ -354,13 +353,13 @@ def main(): ...@@ -354,13 +353,13 @@ def main():
# #
########################################################################### ###########################################################################
userdata_worker = '''#!/usr/bin/env bash userdata_worker = f'''#!/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 = f'''#!/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}
......
...@@ -163,7 +163,7 @@ response = rdsClient.create_db_instance(DBInstanceIdentifier="tug-of-war-rds-db1 ...@@ -163,7 +163,7 @@ response = rdsClient.create_db_instance(DBInstanceIdentifier="tug-of-war-rds-db1
VpcSecurityGroupIds=[security_group_id], VpcSecurityGroupIds=[security_group_id],
# DBInstanceClass='db.m3.2xlarge', # DBInstanceClass='db.m3.2xlarge',
# DBInstanceClass='db.t3.micro', # DBInstanceClass='db.t3.micro',
DBInstanceClass='db.t2.small', DBInstanceClass='db.t3.small',
Tags=[ Tags=[
{'Key': 'Name', 'Value': 'tug-of-war-rds-db1'}, {'Key': 'Name', 'Value': 'tug-of-war-rds-db1'},
{'Key': 'tug-of-war-rds', 'Value': 'db'} {'Key': 'tug-of-war-rds', 'Value': 'db'}
...@@ -200,9 +200,9 @@ userDataWebServer = ('#!/bin/bash\n' ...@@ -200,9 +200,9 @@ userDataWebServer = ('#!/bin/bash\n'
# 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n' # 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n'
# 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n' # 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n'
'cd /var/www/html\n' 'cd /var/www/html\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n'
'\n' '\n'
'# change hostname of db connection\n' '# change hostname of db connection\n'
'sed -i s/localhost/' + dbEndpointAddress + '/g /var/www/html/config.php\n' 'sed -i s/localhost/' + dbEndpointAddress + '/g /var/www/html/config.php\n'
......
...@@ -266,9 +266,9 @@ userDataWebServer = ('#!/bin/bash\n' ...@@ -266,9 +266,9 @@ userDataWebServer = ('#!/bin/bash\n'
# 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n' # 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n'
# 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n' # 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n'
'cd /var/www/html\n' 'cd /var/www/html\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n'
'\n' '\n'
'# change hostname of db connection\n' '# change hostname of db connection\n'
'sed -i s/localhost/' + privateIpDB + '/g /var/www/html/config.php\n' 'sed -i s/localhost/' + privateIpDB + '/g /var/www/html/config.php\n'
...@@ -378,7 +378,7 @@ response = asClient.put_scaling_policy( ...@@ -378,7 +378,7 @@ response = asClient.put_scaling_policy(
AutoScalingGroupName='tug-of-war-asg-autoscalinggroup', AutoScalingGroupName='tug-of-war-asg-autoscalinggroup',
PolicyName='tug-of-war-asg-scalingpolicy', PolicyName='tug-of-war-asg-scalingpolicy',
PolicyType='TargetTrackingScaling', PolicyType='TargetTrackingScaling',
EstimatedInstanceWarmup=30, EstimatedInstanceWarmup=60,
TargetTrackingConfiguration={ TargetTrackingConfiguration={
'PredefinedMetricSpecification': { 'PredefinedMetricSpecification': {
'PredefinedMetricType': 'ALBRequestCountPerTarget', 'PredefinedMetricType': 'ALBRequestCountPerTarget',
......
...@@ -80,9 +80,9 @@ userDataWebServer = ('#!/bin/bash\n' ...@@ -80,9 +80,9 @@ userDataWebServer = ('#!/bin/bash\n'
# 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n' # 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n'
# 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n' # 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n'
'cd /var/www/html\n' 'cd /var/www/html\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examplesraw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n'
'\n' '\n'
'# change hostname of db connection\n' '# change hostname of db connection\n'
'sed -i s/localhost/' + privateIpDB + '/g /var/www/html/config.php\n' 'sed -i s/localhost/' + privateIpDB + '/g /var/www/html/config.php\n'
......
...@@ -190,9 +190,9 @@ userDataWebServer = ('#!/bin/bash\n' ...@@ -190,9 +190,9 @@ userDataWebServer = ('#!/bin/bash\n'
# 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n' # 'cp tug-of-war-in-the-clouds.tar.gz /var/www/html/\n'
# 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n' # 'tar zxvf tug-of-war-in-the-clouds.tar.gz\n'
'cd /var/www/html\n' 'cd /var/www/html\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/index.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/cloud.php\n'
'wget https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n' 'wget https://git-ce.rwth-aachen.de/sebastian.rieger/cloud-computing-msc-ai-examples/raw/master/example-projects/tug-of-war-in-the-clouds/web-content/config.php\n'
'\n' '\n'
'# change hostname of db connection\n' '# change hostname of db connection\n'
'sed -i s/localhost/' + privateIpDB + '/g /var/www/html/config.php\n' 'sed -i s/localhost/' + privateIpDB + '/g /var/www/html/config.php\n'
......