diff --git a/labapp/app/app.py b/labapp/app/app.py index 41a77f7..d3dadf3 100644 --- a/labapp/app/app.py +++ b/labapp/app/app.py @@ -43,12 +43,12 @@ def eph_ns() -> str: this_eph_ns = request.cookies.get('eph_ns', None) return this_eph_ns -def cloudapp_fetch(url, timeout, prop, value, headers = {}): +def cloudapp_fetch(session, url, timeout, prop, value, headers = {}): """ Fetch data from URL Validate prop and value in the JSON response """ - response = requests.get(url, timeout=timeout, headers=headers) + response = session.get(url, timeout=timeout) response.raise_for_status() data = response.json() if data.get(prop) != value: @@ -101,6 +101,7 @@ def arch(): @app.route('/setup', methods=['GET', 'POST']) def setup(): """setup page""" + ns = eph_ns() if request.method == 'POST': action = request.form['action'] if action == 'save': @@ -110,7 +111,7 @@ def setup(): return redirect(url_for('setup')) response = make_response(redirect('/setup')) response.set_cookie('eph_ns', this_eph_ns, max_age=60*60*24) - flash("Ephemeral NS successfully set.", "success") + flash('Ephemeral NS successfully set.', "success") return response if action == 'clear': response = make_response(redirect('/setup')) @@ -120,7 +121,8 @@ def setup(): html = render_md("markdown/setup.md") return render_template('setup.html', title="MCN Practical: Setup", - content=html + content=html, + ns=ns ) @app.route('/_ce_status') @@ -201,8 +203,9 @@ def score(): def ex_test(): """Example test""" try: + s = requests.Session() url = f"https://foo.{app.config['base_url']}/" - data = cloudapp_fetch(url, 5, 'info', 'bar') + data = cloudapp_fetch(s, url, 5, 'info', 'bar') return jsonify(status='success', data=data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) @@ -211,8 +214,9 @@ def ex_test(): def ex_test2(): """Example test""" try: + s = requests.Session() url = f"https://bar.{app.config['base_url']}/" - data = cloudapp_fetch(url, 5, 'info', 'foo') + data = cloudapp_fetch(s, url, 5, 'info', 'foo') return jsonify(status='success', data=data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) @@ -222,11 +226,12 @@ def ex_test2(): def lb_aws(): """Azure LB test""" try: + s = requests.Session() ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") url = f"https://{ns}.{app.config['base_url']}" - data = cloudapp_fetch(url, 5, 'env', 'AWS') + data = cloudapp_fetch(s, url, 5, 'env', 'AWS') return jsonify(status='success', data=data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) @@ -235,11 +240,12 @@ def lb_aws(): def lb_azure(): """Azure LB test""" try: + s = requests.Session() ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") url = f"https://{ns}.{app.config['base_url']}" - data = cloudapp_fetch(url, 5, 'env', 'Azure') + data = cloudapp_fetch(s, url, 5, 'env', 'Azure') return jsonify(status='success', data=data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) @@ -248,14 +254,15 @@ def lb_azure(): def route1(): """First Route Test""" try: + s = requests.Session() ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") base_url = app.config['base_url'] aws_url = f"https://{ns}.{base_url}/aws/raw" azure_url = f"https://{ns}.{base_url}/azure/raw" - aws_data = cloudapp_fetch(aws_url, 5, 'env', 'AWS') - azure_data = cloudapp_fetch(azure_url, 5, 'env', 'Azure') + aws_data = cloudapp_fetch(s, aws_url, 5, 'env', 'AWS') + azure_data = cloudapp_fetch(s, azure_url, 5, 'env', 'Azure') data = { "aws": aws_data, "azure": azure_data @@ -268,14 +275,17 @@ def route1(): def route2(): """First Route Test""" try: + s = requests.Session() ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") base_url = app.config['base_url'] aws_url = f"https://{ns}.{base_url}/" azure_url = f"https://{ns}.{base_url}/" - aws_data = cloudapp_fetch(aws_url, 5, 'env', 'AWS', headers={"X-MCN-lab": "aws"}) - azure_data = cloudapp_fetch(azure_url, 5, 'env', 'Azure', headers={"X-MCN-lab": "azure"}) + s.headers["X-MCN-lab"] = "aws" + aws_data = cloudapp_fetch(s, aws_url, 5, 'env', 'AWS') + s.headers["X-MCN-lab"] = "azure" + azure_data = cloudapp_fetch(s, azure_url, 5, 'env', 'Azure', headers={"X-MCN-lab": "azure"}) data = { "aws": aws_data, "azure": azure_data @@ -288,12 +298,13 @@ def route2(): def manip1(): """First Manip Test""" try: + s = requests.Session() ns = eph_ns() if not ns: raise LabException("Ephemeral NS not set") base_url = app.config['base_url'] url = f"https://{ns}.{base_url}/" - r_data = cloudapp_fetch(url, 5, 'info[path]', '/') + r_data = cloudapp_fetch(s, url, 5, 'info[path]', '/') return jsonify(status='success', data=r_data) except (LabException, requests.RequestException, ValueError) as e: return jsonify(status='fail', error=str(e)) diff --git a/labapp/app/markdown/lb.md b/labapp/app/markdown/lb.md index 01f9d3f..1d0eb3c 100644 --- a/labapp/app/markdown/lb.md +++ b/labapp/app/markdown/lb.md @@ -20,19 +20,19 @@ Build an origin pool and load balancer based on the exercise requirements. @@ -107,15 +107,15 @@ Create a new origin pool for the Azure cloud app. Reuse your load balancer. @@ -146,5 +146,5 @@ document.getElementById('requestBtn2').addEventListener('click', () => { -Once you've completed both exercises, move on to the http routing exercise. +After completing both exercises, move on to the routing exercise. diff --git a/labapp/app/markdown/manipulation.md b/labapp/app/markdown/manipulation.md index 592cd22..5731a57 100644 --- a/labapp/app/markdown/manipulation.md +++ b/labapp/app/markdown/manipulation.md @@ -20,11 +20,11 @@ Configure a path prefix rewrite to remove part of the request p diff --git a/labapp/app/markdown/route.md b/labapp/app/markdown/route.md index e74e293..2eab83b 100644 --- a/labapp/app/markdown/route.md +++ b/labapp/app/markdown/route.md @@ -18,15 +18,15 @@ Build routing rules and configure your load balancer to route traffic between th @@ -76,11 +76,11 @@ Build rules to route traffic between the two cloud apps based on an arbitrary HT diff --git a/labapp/app/markdown/setup.md b/labapp/app/markdown/setup.md index a54be1c..c2ea7e2 100644 --- a/labapp/app/markdown/setup.md +++ b/labapp/app/markdown/setup.md @@ -6,11 +6,12 @@ -Log in to the [lab tenant](https://f5-xc-lab-mcn.console.ves.volterra.io/) and open any namespaced tile (Multi-Cloud App Connect, Distributed Apps, etc.). Your ephemeral namespace is a randomly generated concatenation of _adjective_-_animal_ in the navigation bar towards the top. +Log in to the lab tenant and open any namespaced tile (Multi-Cloud App Connect, Distributed Apps, etc.). The ephemeral namespace is a randomly generated concatenation of adjective-animal in the navigation bar towards the top. -eph-ns +eph-ns -The ephemeral NS name will be used to derive a unique URL for the load balancer used in these exercises. + +The ephemeral namespace will be used to derive a unique URL for the load balancer used in the lab exercises.
@@ -32,4 +33,5 @@ function clearCookie() { form.appendChild(hiddenInput); form.submit(); } - \ No newline at end of file + + diff --git a/labapp/app/markdown/welcome.md b/labapp/app/markdown/welcome.md index 581ae6c..6d9f36a 100644 --- a/labapp/app/markdown/welcome.md +++ b/labapp/app/markdown/welcome.md @@ -32,7 +32,7 @@ The **site name** is needed when configuring the load balancer advertise policy. ### **Account Provisioning** -Check the email used to launch your UDF deployment for a "welcome" or password reset email to the [lab tenant](https://f5-xc-lab-mcn.console.ves.volterra.io/). +Check the email used to launch your UDF deployment for a "welcome" or password reset email to the lab tenant. Update your password and log into the tenant.

@@ -49,10 +49,6 @@ Update your password and log into the tenant. Here's a few things you can do while waiting for the CE to be registered and provisioned: