diff --git a/README.md b/README.md new file mode 100644 index 0000000..328400a --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ + +# 4 - public cloud +- Odpal skrypt: +``` python 4/loadbalancer-init.py ``` +- Przejdź po adres: +```http::/[public_IP]/factors[liczba]``` +gdzie public_IP - wyświetlony w terminalu adres +liczba - int do wpisania ręcznie + +## +- Odpalenie skryptu: +- ```./deploy.sh``` +- Wywoła sprawdzenie load_balancera przy pomocy skryptu + diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..b437bce --- /dev/null +++ b/deploy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +python loadbalancer-init.py +sleep 60 +python script_check.py + diff --git a/loadbalancer-init.py b/loadbalancer-init.py index 11e0f10..d1a8abf 100644 --- a/loadbalancer-init.py +++ b/loadbalancer-init.py @@ -128,3 +128,7 @@ print(f"Loadbalancer creating...: {loadbalancer.action.complete}") load_balancer = client.load_balancers.get_by_name(f"{PREFIX}-loadbalancer") print(f"Webserwis: http://{load_balancer.data_model.public_net.ipv4.ip}:80/factors/") + +with open('url.txt', 'w') as f: + url = 'http://'+load_balancer.data_model.public_net.ipv4.ip + f.write(url) diff --git a/script_check.py b/script_check.py index 68ae37d..bac9baa 100644 --- a/script_check.py +++ b/script_check.py @@ -6,9 +6,9 @@ import threading import logging logging.getLogger().setLevel(logging.INFO) - -API_URL = "http://95.217.175.175" - +with open('url.txt', 'r') as f: + API_URL = f.read() +print(API_URL) UNIT = 5.0 # secs # Pre generated primes diff --git a/url.txt b/url.txt new file mode 100644 index 0000000..b1e70a2 --- /dev/null +++ b/url.txt @@ -0,0 +1 @@ +http://95.217.169.119 \ No newline at end of file