From eeb9bbf43ce2a2a5bd77c4f9296be316e0b6496e Mon Sep 17 00:00:00 2001
From: Sebastian Rieger <sebastian.rieger@informatik.hs-fulda.de>
Date: Tue, 19 Mar 2024 14:41:26 +0100
Subject: [PATCH] bumped default distro in demos, bound mariadb to all ips,
 added template explaination

---
 demo1-getting-started.py             |  4 ++--
 demo2-instance-with-init-script.py   |  4 ++--
 demo3-microservice.py                | 10 ++--------
 demo4-scale-out-add-worker.py        |  4 ++--
 demo4-scale-out.py                   | 13 ++++---------
 faafo/contrib/install.sh             |  4 +++-
 faafo/faafo/api/templates/index.html |  4 ++--
 7 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/demo1-getting-started.py b/demo1-getting-started.py
index a1c59ef..86d11f9 100644
--- a/demo1-getting-started.py
+++ b/demo1-getting-started.py
@@ -32,8 +32,8 @@ project_name = 'CloudComp' + str(group_number)
 project_network = 'CloudComp' + str(group_number) + '-net'
 
 # 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 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
+#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"
 
 # default region
 region_name = 'RegionOne'
diff --git a/demo2-instance-with-init-script.py b/demo2-instance-with-init-script.py
index 6497b44..dc5130c 100644
--- a/demo2-instance-with-init-script.py
+++ b/demo2-instance-with-init-script.py
@@ -20,8 +20,8 @@ project_name = 'CloudComp' + str(group_number)
 project_network = 'CloudComp' + str(group_number) + '-net'
 
 # 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 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
+#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
 #
diff --git a/demo3-microservice.py b/demo3-microservice.py
index 4f2661a..f5e616a 100644
--- a/demo3-microservice.py
+++ b/demo3-microservice.py
@@ -24,8 +24,8 @@ project_name = 'CloudComp' + str(group_number)
 project_network = 'CloudComp' + str(group_number) + '-net'
 
 # 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 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
+#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
 #
@@ -166,12 +166,6 @@ 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'
diff --git a/demo4-scale-out-add-worker.py b/demo4-scale-out-add-worker.py
index bc73745..6d3630c 100644
--- a/demo4-scale-out-add-worker.py
+++ b/demo4-scale-out-add-worker.py
@@ -26,8 +26,8 @@ project_name = 'CloudComp' + str(group_number)
 project_network = 'CloudComp' + str(group_number) + '-net'
 
 # 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 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
+#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
 #
diff --git a/demo4-scale-out.py b/demo4-scale-out.py
index 7ee3f07..4154226 100644
--- a/demo4-scale-out.py
+++ b/demo4-scale-out.py
@@ -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,
 # project etc., as coordinated in the lab sessions)
 
-group_number = X
+group_number = 2
 
 
 # web service endpoint of the private cloud infrastructure
@@ -26,8 +26,9 @@ project_name = 'CloudComp' + str(group_number)
 project_network = 'CloudComp' + str(group_number) + '-net'
 
 # 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 20.04 - Focal Fossa - 64-bit - Cloud Based Image"
+#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
 #
@@ -227,12 +228,6 @@ 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'
diff --git a/faafo/contrib/install.sh b/faafo/contrib/install.sh
index 2951daa..7db1df5 100755
--- a/faafo/contrib/install.sh
+++ b/faafo/contrib/install.sh
@@ -88,18 +88,20 @@ if [[ -e /etc/os-release ]]; then
             # HSFD changes for Ubuntu 18.04
             #sudo sed -i -e "/bind-address/d" /etc/mysql/mysql.conf.d/mysqld.cnf
             ##sudo sed -i -e "/bind-address/d" /etc/mysql/my.cnf
+            sudo sed -i -e "s/127.0.0.1/0.0.0.0/g" /etc/mysql/mariadb.conf.d/50-server.cnf
+            sudo mysqmladmin password password
             sudo systemctl restart mariadb
         elif [[ $ID = 'fedora' ]]; then
             # fedora currently not tested nor supported
             sudo dnf install -y mariadb-server python3-mysql
             printf "[mysqld]\nbind-address = 127.0.0.1\n" | sudo tee /etc/my.cnf.d/faafo.conf
+            sudo mysqmladmin password password
             sudo systemctl enable mariadb
             sudo systemctl start mariadb
         else
             echo "error: distribution $ID not supported"
             exit 1
         fi
-        sudo mariadb-admin password password
         sudo mysql -uroot -ppassword mysql -e "CREATE DATABASE IF NOT EXISTS faafo; GRANT ALL PRIVILEGES ON faafo.* TO 'faafo'@'%' IDENTIFIED BY 'password';"
         URL_DATABASE='mysql://root:password@localhost/faafo'
     fi
diff --git a/faafo/faafo/api/templates/index.html b/faafo/faafo/api/templates/index.html
index acc946f..8a7a142 100644
--- a/faafo/faafo/api/templates/index.html
+++ b/faafo/faafo/api/templates/index.html
@@ -57,9 +57,9 @@ yb = {{ fractal.yb }}</pre>
 </div>
 {% endfor %}
 {{render_pagination(fractals)}}
-<!--
+<!-- requires POST request to have Content-Type: "application/vnd.api+json" header, would require Fetch API or XMLHTTPRequest etc.
 <div>
-  <form action="/v1/fractal" method="POST" enctype="application/vnd.api+json">
+  <form action="/v1/fractal" method="POST">
     <input type="submit" value="Create new fractals">
   </form>
 </div>
-- 
GitLab