From 9c05bce93a8d634e632d16af741e940342b086a2 Mon Sep 17 00:00:00 2001
From: Primo <aaalsaye@stud.ntnu.no>
Date: Sat, 6 Nov 2021 11:18:51 +0100
Subject: [PATCH] Added service running functionality

---
 README.md                                  |  3 ++-
 infcode-golang                             |  2 +-
 autoscaling.yaml => scaling_scheduler.yaml |  0
 setup.sh                                   | 27 ++++++++++++++++++++++
 4 files changed, 30 insertions(+), 2 deletions(-)
 rename autoscaling.yaml => scaling_scheduler.yaml (100%)

diff --git a/README.md b/README.md
index c3f064e..ba45344 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
 # scaling_scheduler
 
 Use this command when cloning this repo for submodules to clone as well  
+Clone in home directory of ubuntu user  
 git clone --recurse-submodules repo_url  
 
 * Edit scale_env.yaml with all necessary values from openstack
-* Run setup.sh on a manager instance that is authenticated in the openstack cli (e.g run service user script)
+* Run setup.sh on a manager instance (Ubuntu) that is authenticated in the openstack cli (e.g run service user script)
 
 Example environment variables
 ```
diff --git a/infcode-golang b/infcode-golang
index 55bb21e..be2b11c 160000
--- a/infcode-golang
+++ b/infcode-golang
@@ -1 +1 @@
-Subproject commit 55bb21e55ec9abe3c64ce684d5418e773ab9200a
+Subproject commit be2b11ca9bb586deda8ad24cc22a79a922b214b2
diff --git a/autoscaling.yaml b/scaling_scheduler.yaml
similarity index 100%
rename from autoscaling.yaml
rename to scaling_scheduler.yaml
diff --git a/setup.sh b/setup.sh
index e69de29..0893094 100644
--- a/setup.sh
+++ b/setup.sh
@@ -0,0 +1,27 @@
+#!/bin/bash -v
+# CREATE STACK
+openstack stack create -t scaling_scheduler.yaml -e scale_env.yaml scaling_scheduler
+
+# Wait 3 minutes while stack is being created
+secs=$((3 * 60))
+while [ $secs -gt 0 ]; do
+   echo -ne "Leeway countdown for stack CREATE to finish: $secs\033[0K\r"
+   sleep 1
+   : $((secs--))
+done
+
+# Get both downscale and upscale webhooks from stack output and feed to service project directory
+openstack stack output show --all autoscale_scheduler | grep -Eo "(https)://[a-zA-Z0-9./?&=_%:-]*" > infcode-golang/scheduleroutputdata.txt
+
+# Install golang if not installed
+sudo apt-get -y install golang-golang
+
+# Create symlink for systemctl to run go service
+sudo ln -s infcode-golang/scheduler.service /etc/systemd/system/scheduler.service
+
+# Activate service with systemd
+sudo systemctl daemon-reload
+sudo systemctl enable scheduler
+sudo systemctl start scheduler
+
+
-- 
GitLab