From 988613f235155981377e9de4d678e30c4bbb78e4 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:11:29 +0000 Subject: [PATCH 01/10] feat: Added colo app --- bb_colo/__init__.py | 0 bb_colo/admin.py | 3 + bb_colo/apps.py | 6 + bb_colo/migrations/0001_initial.py | 32 +++++ bb_colo/migrations/__init__.py | 0 bb_colo/models.py | 28 +++++ bb_colo/tests.py | 3 + bb_colo/views.py | 3 + bb_vm/bash_scripts/brick_connect.sh | 7 +- bb_vm/bash_scripts/brick_play.sh | 14 ++- bb_vm/bash_scripts/brick_reconnect.sh | 7 +- .../logs/brick_connect_errors.log | 115 ++++++++++++++++++ brickbox/settings.py | 8 +- .../static/assets/js/colo/onboarding.js | 21 ++++ django_dash_black/templates/bricks.html | 4 +- django_dash_black/templates/colo.html | 88 ++++++++++++++ .../templates/includes/scripts.html | 3 + .../templates/includes/sidebar.html | 16 ++- .../modals/colo_terms_signature.html | 18 +++ 19 files changed, 365 insertions(+), 11 deletions(-) create mode 100644 bb_colo/__init__.py create mode 100644 bb_colo/admin.py create mode 100644 bb_colo/apps.py create mode 100644 bb_colo/migrations/0001_initial.py create mode 100644 bb_colo/migrations/__init__.py create mode 100644 bb_colo/models.py create mode 100644 bb_colo/tests.py create mode 100644 bb_colo/views.py create mode 100644 django_dash_black/static/assets/js/colo/onboarding.js create mode 100644 django_dash_black/templates/colo.html create mode 100644 django_dash_black/templates/modals/colo_terms_signature.html diff --git a/bb_colo/__init__.py b/bb_colo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bb_colo/admin.py b/bb_colo/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/bb_colo/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/bb_colo/apps.py b/bb_colo/apps.py new file mode 100644 index 0000000..f5a1a81 --- /dev/null +++ b/bb_colo/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BbColoConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'bb_colo' diff --git a/bb_colo/migrations/0001_initial.py b/bb_colo/migrations/0001_initial.py new file mode 100644 index 0000000..1b32301 --- /dev/null +++ b/bb_colo/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 3.2.9 on 2021-11-15 20:37 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('bb_data', '0023_alter_colocationclientowner_unique_together'), + ] + + operations = [ + migrations.CreateModel( + name='colocationOnboarding', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('lease_signature', models.BooleanField(default=False)), + ('nda_signature', models.BooleanField(default=False)), + ('usd_payout_info', models.BooleanField(default=False)), + ('crypto_payout_info', models.BooleanField(default=False)), + ('first_unit_ordered', models.BooleanField(default=False)), + ('insurance_info_received', models.BooleanField(default=False)), + ('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='bb_data.colocationclient')), + ], + options={ + 'verbose_name': 'Colocation Onboarding', + }, + ), + ] diff --git a/bb_colo/migrations/__init__.py b/bb_colo/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bb_colo/models.py b/bb_colo/models.py new file mode 100644 index 0000000..e3c1a8e --- /dev/null +++ b/bb_colo/models.py @@ -0,0 +1,28 @@ +''' bb_colo models.py ''' + +from django.db import models +from django.contrib.auth import get_user_model + +from bb_data.models import UserProfile, ColocationClient + +User = get_user_model() + +# --------------------------- colo Onboarding Stage -------------------------- # +class colocationOnboarding(models.Model): + ''' + Used to track the stage of a client coming on as a CoLo. + ''' + client = models.ForeignKey(ColocationClient, on_delete=models.CASCADE) + + lease_signature = models.BooleanField(default=False) + nda_signature = models.BooleanField(default=False) + usd_payout_info = models.BooleanField(default=False) + crypto_payout_info = models.BooleanField(default=False) + first_unit_ordered = models.BooleanField(default=False) + insurance_info_received = models.BooleanField(default=False) + + def __str__(self): + return f'{self.client.owner_profile.user}' + + class Meta: + verbose_name = 'Colocation Onboarding' diff --git a/bb_colo/tests.py b/bb_colo/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/bb_colo/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/bb_colo/views.py b/bb_colo/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/bb_colo/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/bb_vm/bash_scripts/brick_connect.sh b/bb_vm/bash_scripts/brick_connect.sh index e80a884..2781f77 100755 --- a/bb_vm/bash_scripts/brick_connect.sh +++ b/bb_vm/bash_scripts/brick_connect.sh @@ -36,6 +36,11 @@ if lsof -i tcp:"$port"; then else - curl -X POST https://"$url"/api/vmlog/ -d "level=50&virt_brick=$instance&message=Could%20not%20connect%20to%20host%20port." & + curl -X POST https://"$url"/api/vmlog/ \ + -d "level=50" \ + -d "host=$port" \ + -d "virt_brick=$instance" \ + -d "message=Could%20not%20connect%20to%20host%20port." \ + -d "command=ssh -i /opt/brickbox/bb_vm/keys/"$host_user" -o StrictHostKeyChecking=no -p "$port" "$host_user"@localhost 'sudo bash -s' < /opt/brickbox/bb_vm/bash_scripts/"$action".sh "$url" "$instance" \""$xml_data"\"" fi diff --git a/bb_vm/bash_scripts/brick_play.sh b/bb_vm/bash_scripts/brick_play.sh index 9542226..013db43 100755 --- a/bb_vm/bash_scripts/brick_play.sh +++ b/bb_vm/bash_scripts/brick_play.sh @@ -8,14 +8,22 @@ instance=$2 # Check if brick is on, if not, start it. if [ "$(sudo virsh domstate "$instance")" != "running" ]; then echo "Brick is not running, starting it." - sudo virsh start "$instance" + command_output=$(sudo virsh start "$instance") sleep 10 fi # Check if brick has started. -if [ "$(sudo virsh list --all | grep -c "$instance")" -eq 1 ]; then +# if [ "$(sudo virsh list --all | grep -c "$instance")" -eq 1 ]; then + if [ "$(sudo virsh domstate "$instance")" != "running" ]; then echo "Brick started." - curl -X POST https://"$url"/api/vmlog/ -d "level=20&virt_brick=$instance&message=Brick%20has%20started." & + + curl -X POST https://"$url"/api/vmlog/ \ + -d "level=20" \ + -d "virt_brick=$instance" \ + -d "message=Brick hasstarted." \ + -d "command=sudo virsh start $instance" \ + -d "command_output=$command_output" & > /dev/null + exit 0 else echo "Brick failed to start." diff --git a/bb_vm/bash_scripts/brick_reconnect.sh b/bb_vm/bash_scripts/brick_reconnect.sh index 3a4ed56..f9f31d9 100755 --- a/bb_vm/bash_scripts/brick_reconnect.sh +++ b/bb_vm/bash_scripts/brick_reconnect.sh @@ -15,7 +15,12 @@ if sudo lspci -s "$pcie" -k | grep "vfio-pci"; then else - curl -X POST https://"$url"/api/vmlog/ -d "level=40&virt_brick=NA&message=Failed%20set%20$pcie%20driver%20set%20to%20VFIO&command_output=$command_output" # Logging + curl -X POST https://"$url"/api/vmlog/ \ + -d "level=40" \ + -d "virt_brick=NA" \ + -d "message=Failed set $pcie driver set to VFIO." \ + -d "command=sudo ./vfio-pci-bind/vfio-pci-bind.sh $device $pcie 2>> bash_errors.log" + -d "command_output=$command_output" & > /dev/null fi diff --git a/bb_vm/bash_scripts/logs/brick_connect_errors.log b/bb_vm/bash_scripts/logs/brick_connect_errors.log index b832670..2b713fb 100644 --- a/bb_vm/bash_scripts/logs/brick_connect_errors.log +++ b/bb_vm/bash_scripts/logs/brick_connect_errors.log @@ -914,3 +914,118 @@ Killed old client process % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 212 100 158 100 54 863 295 --:--:-- --:--:-- --:--:-- 1158 +Connection to localhost closed by remote host. + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 94 0 0 100 94 0 676 --:--:-- --:--:-- --:--:-- 671 100 284 100 190 100 94 1104 546 --:--:-- --:--:-- --:--:-- 1641 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 604 100 336 100 268 2666 2126 --:--:-- --:--:-- --:--:-- 4793 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 25 0 0 100 25 0 223 --:--:-- --:--:-- --:--:-- 221 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 828 100 483 100 345 4274 3053 --:--:-- --:--:-- --:--:-- 7327 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 228 100 166 100 62 1338 500 --:--:-- --:--:-- --:--:-- 1838 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 228 100 166 100 62 1443 539 --:--:-- --:--:-- --:--:-- 1982 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 284 100 190 100 94 1187 587 --:--:-- --:--:-- --:--:-- 1775 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1268 100 672 100 596 5419 4806 --:--:-- --:--:-- --:--:-- 10225 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 25 0 0 100 25 0 210 --:--:-- --:--:-- --:--:-- 210 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 820 100 483 100 337 4200 2930 --:--:-- --:--:-- --:--:-- 7130 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 228 100 166 100 62 1360 508 --:--:-- --:--:-- --:--:-- 1853 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 228 100 166 100 62 1307 488 --:--:-- --:--:-- --:--:-- 1795 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 284 100 190 100 94 1507 746 --:--:-- --:--:-- --:--:-- 2253 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1268 100 672 100 596 5793 5137 --:--:-- --:--:-- --:--:-- 11026 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 25 0 0 100 25 0 204 --:--:-- --:--:-- --:--:-- 204 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 706 100 422 100 284 3376 2272 --:--:-- --:--:-- --:--:-- 5648 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 228 100 166 100 62 1383 516 --:--:-- --:--:-- --:--:-- 1900 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 228 100 166 100 62 1328 496 --:--:-- --:--:-- --:--:-- 1824 +kex_exchange_identification: read: Connection reset by peer +Connection to localhost closed by remote host. +Connection to localhost closed by remote host. +Connection to localhost closed by remote host. +Connection to localhost closed by remote host. +Connection to localhost closed by remote host. +Connection to localhost closed by remote host. +Connection to localhost closed by remote host. +Warning: Identity file /opt/brickbox/bb_vm/keys/bb_dev not accessible: No such file or directory. +Permission denied, please try again. +Permission denied, please try again. +bb_dev@localhost: Permission denied (publickey,password). +Warning: Identity file /opt/brickbox/bb_vm/keys/bb_dev not accessible: No such file or directory. +Permission denied, please try again. +Permission denied, please try again. +bb_dev@localhost: Permission denied (publickey,password). +Warning: Identity file /opt/brickbox/bb_vm/keys/bb_dev not accessible: No such file or directory. +Permission denied, please try again. +Permission denied, please try again. +bb_dev@localhost: Permission denied (publickey,password). +Warning: Identity file /opt/brickbox/bb_vm/keys/bb_dev not accessible: No such file or directory. +Permission denied, please try again. +Permission denied, please try again. +bb_dev@localhost: Permission denied (publickey,password). +Warning: Identity file /opt/brickbox/bb_vm/keys/bb_dev not accessible: No such file or directory. +Permission denied, please try again. +Permission denied, please try again. +bb_dev@localhost: Permission denied (publickey,password). +Killed old client process +rmmod: ERROR: Module nvidia_uvm is not currently loaded +rmmod: ERROR: Module nvidia_drm is not currently loaded +rmmod: ERROR: Module nvidia_modeset is not currently loaded +rmmod: ERROR: Module nvidia is not currently loaded + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 2926 100 1517 100 1409 2528 2348 --:--:-- --:--:-- --:--:-- 4868 100 2926 100 1517 100 1409 2528 2348 --:--:-- --:--:-- --:--:-- 4868 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 2926 100 1517 100 1409 10390 9650 --:--:-- --:--:-- --:--:-- 20041 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 282 100 181 100 101 1425 795 --:--:-- --:--:-- --:--:-- 2220 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 2926 100 1517 100 1409 11154 10360 --:--:-- --:--:-- --:--:-- 21514 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- -- % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0:--:-- --:--:-- 0 % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 212 100 158 100 54 1120 382 --:--:-- --:--:-- --:--:-- 1503 + 100 212 100 158 100 54 1112 380 --:--:-- --:--:-- --:--:-- 1492 + 100 212 100 158 100 54 1104 377 --:--:-- --:--:-- --:--:-- 1482 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 212 100 158 100 54 858 293 --:--:-- --:--:-- --:--:-- 1158 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 269 100 175 100 94 1483 796 --:--:-- --:--:-- --:--:-- 2279 diff --git a/brickbox/settings.py b/brickbox/settings.py index 94bc4a6..f627d6e 100644 --- a/brickbox/settings.py +++ b/brickbox/settings.py @@ -35,6 +35,7 @@ # brickbox.io Apps 'django_dash_black', # https://appseed.us/admin-dashboards/django-dashboard-black 'bb_api', # API endpoints and handlers + 'bb_colo', # Colocation management 'bb_public', # Public landing pages 'bb_accounts', # Account creation and login 'bb_dashboard', # Users dashboard @@ -306,5 +307,8 @@ # ----------------------- Stripe Debug/Test Credentials ---------------------- # # CLIENT_ID_TEST = -# STRIPE_SECRET_KEY_TEST = '' -# STRIPE_PUBLISHABLE_KEY_TEST = '' +STRIPE_SECRET_KEY_TEST = '''sk_test_51Jb9T1AFJmW5oMdbI6NszFIEwIHNynAa +1pHqeUkBRMWAqFUj2XguaLzfFqspuarRB5uqVZPuFkyDb4f5k7WuJ3EE00OqwKdoI4''' + +STRIPE_PUBLISHABLE_KEY_TEST = '''pk_test_51Jb9T1AFJmW5oMdbOtpNv8mEKgXZZ +jdVScjhh1l7wMJ4h2UynWpnIl1tlsmX0Hgt33lE8hyoiKer85GgfHnNjagK00aZMtPtzX''' diff --git a/django_dash_black/static/assets/js/colo/onboarding.js b/django_dash_black/static/assets/js/colo/onboarding.js new file mode 100644 index 0000000..1d6fdb2 --- /dev/null +++ b/django_dash_black/static/assets/js/colo/onboarding.js @@ -0,0 +1,21 @@ +function TermsAgreement() { + $("#terms_agreement_signature").modal('toggle'); + $("#confirm_button").click(function () { + $("#terms_agreement_signature").modal('toggle'); + var formData = new FormData(); + var xhttp = new XMLHttpRequest(); + var url = '/vm/brick/destroy/' + + formData.append('brick_id', brick_id); + + xhttp.onload = function () { + var vm_status = JSON.parse(this.responseText); + BrickNotice('bottom', 'center', 'Brick Crumbled'); + document.getElementById("brick_wall").innerHTML = vm_status.table; + } + + xhttp.open('POST', url, true); + xhttp.setRequestHeader("X-CSRFToken", csrftoken); + xhttp.send(formData); + }); +} diff --git a/django_dash_black/templates/bricks.html b/django_dash_black/templates/bricks.html index 71bff06..d77d27d 100644 --- a/django_dash_black/templates/bricks.html +++ b/django_dash_black/templates/bricks.html @@ -39,7 +39,7 @@

Add Brick Instance

-
+
@@ -72,7 +72,7 @@

Add Brick Instance

-
+
diff --git a/django_dash_black/templates/colo.html b/django_dash_black/templates/colo.html new file mode 100644 index 0000000..5836998 --- /dev/null +++ b/django_dash_black/templates/colo.html @@ -0,0 +1,88 @@ +{% extends "layouts/base.html" %} + +{% block title %} Colocation {% endblock %} + + +{% block stylesheets %}{% endblock stylesheets %} + +{% block content %} + +
+ +
+
+ +
+

1 | Term Agreement

+
+ +
+

+ Please read the following terms and conditions carefully. +

+
+ + + +
+
+ +
+
+ +
+

2 | Payout Info

+
+ +
+

+ Please provide the account information for where you would like to receive your payout. +

+
+ +
+
+ +
+
+ +
+

3 | Place Equipment Order

+
+ +
+

+ You will be purchasing equipment directly from our supplier, the following is the information you will need to complete the order. +

+
+ +
+
+ +
+
+ +
+

4 | Confirm Insurance

+
+ +
+

+ As stated in the agreement, you will be required to provide us with a valid insurance policy for the equipment. + You can either go through our insurace provider or upload a copy of your proff of insurance. +

+
+ +
+
+ +
+ +{% include "modals/colo_terms_signature.html" %} + +{% endblock content %} + + +{% block javascripts %}{% endblock javascripts %} diff --git a/django_dash_black/templates/includes/scripts.html b/django_dash_black/templates/includes/scripts.html index d077bae..95659d6 100644 --- a/django_dash_black/templates/includes/scripts.html +++ b/django_dash_black/templates/includes/scripts.html @@ -18,4 +18,7 @@ + + + {% endcompress %} diff --git a/django_dash_black/templates/includes/sidebar.html b/django_dash_black/templates/includes/sidebar.html index 23e1225..b9bc9cf 100644 --- a/django_dash_black/templates/includes/sidebar.html +++ b/django_dash_black/templates/includes/sidebar.html @@ -39,12 +39,24 @@ + + {% if user.is_superuser %} +
  • + + +

    COLOCATION

    +
    +
  • + {% endif %} + + + {% if profile.brick_access %}
  • -

    Bricks

    +

    BRICKS

  • {% endif %} @@ -56,7 +68,7 @@
  • -

    Superuser

    +

    SUPERUSER

  • {% endif %} diff --git a/django_dash_black/templates/modals/colo_terms_signature.html b/django_dash_black/templates/modals/colo_terms_signature.html new file mode 100644 index 0000000..017a533 --- /dev/null +++ b/django_dash_black/templates/modals/colo_terms_signature.html @@ -0,0 +1,18 @@ + From 6ca20eafe494d001602ebcb7b5d4788c1e027e2c Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:23:21 +0000 Subject: [PATCH 02/10] refactor: Linting --- bb_colo/admin.py | 4 +++- bb_colo/apps.py | 6 ++++++ bb_colo/models.py | 6 +++--- bb_colo/tests.py | 3 --- bb_colo/views.py | 4 +++- bb_vm/bash_scripts/brick_connect.sh | 5 ++--- bb_vm/bash_scripts/brick_play.sh | 4 ++-- bb_vm/bash_scripts/brick_reconnect.sh | 2 +- 8 files changed, 20 insertions(+), 14 deletions(-) delete mode 100644 bb_colo/tests.py diff --git a/bb_colo/admin.py b/bb_colo/admin.py index 8c38f3f..ffdaae4 100644 --- a/bb_colo/admin.py +++ b/bb_colo/admin.py @@ -1,3 +1,5 @@ -from django.contrib import admin +''' bb_colo - admin.py ''' + +# from django.contrib import admin # Register your models here. diff --git a/bb_colo/apps.py b/bb_colo/apps.py index f5a1a81..61f1a79 100644 --- a/bb_colo/apps.py +++ b/bb_colo/apps.py @@ -1,6 +1,12 @@ +''' bb_colo - apps.py ''' + from django.apps import AppConfig class BbColoConfig(AppConfig): + ''' + bb_colo app config + ''' + name = 'bb_colo' default_auto_field = 'django.db.models.BigAutoField' name = 'bb_colo' diff --git a/bb_colo/models.py b/bb_colo/models.py index e3c1a8e..ae2126b 100644 --- a/bb_colo/models.py +++ b/bb_colo/models.py @@ -3,12 +3,12 @@ from django.db import models from django.contrib.auth import get_user_model -from bb_data.models import UserProfile, ColocationClient +from bb_data.models import ColocationClient User = get_user_model() # --------------------------- colo Onboarding Stage -------------------------- # -class colocationOnboarding(models.Model): +class ColocationOnboarding(models.Model): ''' Used to track the stage of a client coming on as a CoLo. ''' @@ -22,7 +22,7 @@ class colocationOnboarding(models.Model): insurance_info_received = models.BooleanField(default=False) def __str__(self): - return f'{self.client.owner_profile.user}' + return f'{self.client}' class Meta: verbose_name = 'Colocation Onboarding' diff --git a/bb_colo/tests.py b/bb_colo/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/bb_colo/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/bb_colo/views.py b/bb_colo/views.py index 91ea44a..46b7f8f 100644 --- a/bb_colo/views.py +++ b/bb_colo/views.py @@ -1,3 +1,5 @@ -from django.shortcuts import render +''' bb_colo - views.py ''' + +# from django.shortcuts import render # Create your views here. diff --git a/bb_vm/bash_scripts/brick_connect.sh b/bb_vm/bash_scripts/brick_connect.sh index 2781f77..bcfb4de 100755 --- a/bb_vm/bash_scripts/brick_connect.sh +++ b/bb_vm/bash_scripts/brick_connect.sh @@ -40,7 +40,6 @@ else -d "level=50" \ -d "host=$port" \ -d "virt_brick=$instance" \ - -d "message=Could%20not%20connect%20to%20host%20port." \ - -d "command=ssh -i /opt/brickbox/bb_vm/keys/"$host_user" -o StrictHostKeyChecking=no -p "$port" "$host_user"@localhost 'sudo bash -s' < /opt/brickbox/bb_vm/bash_scripts/"$action".sh "$url" "$instance" \""$xml_data"\"" - + -d "message=Could not connect to host port." \ + -d "command=ssh -i /opt/brickbox/bb_vm/keys/""$host_user"" -o StrictHostKeyChecking=no -p ""$port"" ""$host_user""@localhost 'sudo bash -s' < /opt/brickbox/bb_vm/bash_scripts/""$action"".sh ""$url"" ""$instance"" \"""$xml_data""\"" fi diff --git a/bb_vm/bash_scripts/brick_play.sh b/bb_vm/bash_scripts/brick_play.sh index 013db43..909ab91 100755 --- a/bb_vm/bash_scripts/brick_play.sh +++ b/bb_vm/bash_scripts/brick_play.sh @@ -17,12 +17,12 @@ fi if [ "$(sudo virsh domstate "$instance")" != "running" ]; then echo "Brick started." - curl -X POST https://"$url"/api/vmlog/ \ + curl -s -X POST https://"$url"/api/vmlog/ \ -d "level=20" \ -d "virt_brick=$instance" \ -d "message=Brick hasstarted." \ -d "command=sudo virsh start $instance" \ - -d "command_output=$command_output" & > /dev/null + -d "command_output=$command_output" > /dev/null & exit 0 else diff --git a/bb_vm/bash_scripts/brick_reconnect.sh b/bb_vm/bash_scripts/brick_reconnect.sh index f9f31d9..05bb3f9 100755 --- a/bb_vm/bash_scripts/brick_reconnect.sh +++ b/bb_vm/bash_scripts/brick_reconnect.sh @@ -20,7 +20,7 @@ else -d "virt_brick=NA" \ -d "message=Failed set $pcie driver set to VFIO." \ -d "command=sudo ./vfio-pci-bind/vfio-pci-bind.sh $device $pcie 2>> bash_errors.log" - -d "command_output=$command_output" & > /dev/null + -d "command_output=$command_output" > /dev/null & fi From 45267b84f07987f5ed6c853e6c27d1881543a7b5 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:24:59 +0000 Subject: [PATCH 03/10] fix: Bash line fix --- bb_vm/bash_scripts/brick_reconnect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bb_vm/bash_scripts/brick_reconnect.sh b/bb_vm/bash_scripts/brick_reconnect.sh index 05bb3f9..f4da8c9 100755 --- a/bb_vm/bash_scripts/brick_reconnect.sh +++ b/bb_vm/bash_scripts/brick_reconnect.sh @@ -19,7 +19,7 @@ else -d "level=40" \ -d "virt_brick=NA" \ -d "message=Failed set $pcie driver set to VFIO." \ - -d "command=sudo ./vfio-pci-bind/vfio-pci-bind.sh $device $pcie 2>> bash_errors.log" + -d "command=sudo ./vfio-pci-bind/vfio-pci-bind.sh $device $pcie 2>> bash_errors.log" \ -d "command_output=$command_output" > /dev/null & fi From f7a89306bde8a50704813b150b73f0d7aacf1e00 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:37:55 +0000 Subject: [PATCH 04/10] fix: Package updates --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 9c1bd0a..7b9de04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,11 +4,11 @@ celery>=5.1.2 chardet==4.0.0 conventional-commit==0.4.2 docutils>=0.17.1 -Django>=3.2.7 +Django>=3.2.9 djangorestframework>=3.12.4 django-allauth>=0.45.0 django-DevOps>=0.1.1 -django-filter>=2.4.0 +django-filter>=21.1 django-health-check>=3.16.4 django-oauth-toolkit>=1.5.0 django-pwa>=1.0.10 @@ -19,7 +19,7 @@ enforce-git-message==1.0.1 google-auth>=2.3.0 gunicorn>=20.1.0 idna==2.10 -markdown>=3.3.4 +markdown>=3.3.5 packaging==19.2 pip-upgrader>=1.4.15 prompt-toolkit==3.0.18 From 639b3e0acfb126bc22d819edb8ffec9aaf1023b1 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:43:47 +0000 Subject: [PATCH 05/10] chore: Updated Django Action --- .github/workflows/Dajango.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Dajango.yml b/.github/workflows/Dajango.yml index e9b1ac5..b9667d2 100644 --- a/.github/workflows/Dajango.yml +++ b/.github/workflows/Dajango.yml @@ -11,6 +11,9 @@ jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10.0' ] steps: From 4618a87fffad92edadfe69ca8d87b597b282a0dc Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:47:51 +0000 Subject: [PATCH 06/10] chore: Update Django Action --- .github/workflows/Dajango.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Dajango.yml b/.github/workflows/Dajango.yml index b9667d2..b96e0a3 100644 --- a/.github/workflows/Dajango.yml +++ b/.github/workflows/Dajango.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8', '3.9', '3.10.0' ] + python-version: [ '3.0.1', '3.1.4', '3.2.5', '3.3.5', '3.4.10', '3.5.9', '3.6.7', '3.7.5', '3.8.1', '3.9.0', '3.10.0' ] steps: From 89b8c3da242f5563def6c5b8ebe4d8ec3cd8ae78 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:51:51 +0000 Subject: [PATCH 07/10] chore: Update Django Action --- .github/workflows/Dajango.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Dajango.yml b/.github/workflows/Dajango.yml index b96e0a3..7a2f5dd 100644 --- a/.github/workflows/Dajango.yml +++ b/.github/workflows/Dajango.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.0.1', '3.1.4', '3.2.5', '3.3.5', '3.4.10', '3.5.9', '3.6.7', '3.7.5', '3.8.1', '3.9.0', '3.10.0' ] + python-version: [ '3.5.9', '3.6.7', '3.7.5', '3.8.1', '3.9.0', '3.10.0' ] steps: From d78555028f3aa139c271168136445cc2b52618e8 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 17:55:58 +0000 Subject: [PATCH 08/10] chore: Update django action --- .github/workflows/Dajango.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Dajango.yml b/.github/workflows/Dajango.yml index 7a2f5dd..3ddcef7 100644 --- a/.github/workflows/Dajango.yml +++ b/.github/workflows/Dajango.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.5.9', '3.6.7', '3.7.5', '3.8.1', '3.9.0', '3.10.0' ] + python-version: [ '3.8.10', '3.9.0', '3.10.0' ] steps: From a4cb17476124e085e55d4970bb82a129d314d377 Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 18:01:07 +0000 Subject: [PATCH 09/10] chore: Expand gitignore --- .gitignore | 1 + bb_vm/bash_scripts/bash_errors.log | 0 2 files changed, 1 insertion(+) delete mode 100644 bb_vm/bash_scripts/bash_errors.log diff --git a/.gitignore b/.gitignore index c66ba88..a6a30dd 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ bb_api/templates/api_docs_source/build/* # Logs logs/* !logs/.gitkeep +bash_errors.log diff --git a/bb_vm/bash_scripts/bash_errors.log b/bb_vm/bash_scripts/bash_errors.log deleted file mode 100644 index e69de29..0000000 From 358e1ab9171a3f97066fbed7f37e2bf5edd79b0e Mon Sep 17 00:00:00 2001 From: Justin Merrell Date: Tue, 16 Nov 2021 18:10:16 +0000 Subject: [PATCH 10/10] chore: Update Django Action --- .github/workflows/Dajango.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Dajango.yml b/.github/workflows/Dajango.yml index 3ddcef7..73b1414 100644 --- a/.github/workflows/Dajango.yml +++ b/.github/workflows/Dajango.yml @@ -11,18 +11,20 @@ jobs: build: runs-on: ubuntu-latest - strategy: - matrix: - python-version: [ '3.8.10', '3.9.0', '3.10.0' ] + # strategy: + # matrix: + # python-version: [ '3.8.10', '3.9.0', '3.10.0' ] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + # - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python 3.10.0 uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} + python-version: 3.10.0 + # python-version: ${{ matrix.python-version }} - name: Install Dependencies run: |