Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Bash line fix #137

Merged
merged 10 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/Dajango.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ jobs:

build:
runs-on: ubuntu-latest
# 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: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ bb_api/templates/api_docs_source/build/*
# Logs
logs/*
!logs/.gitkeep
bash_errors.log
File renamed without changes.
5 changes: 5 additions & 0 deletions bb_colo/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
''' bb_colo - admin.py '''

# from django.contrib import admin

# Register your models here.
12 changes: 12 additions & 0 deletions bb_colo/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +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'
32 changes: 32 additions & 0 deletions bb_colo/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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',
},
),
]
Empty file added bb_colo/migrations/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions bb_colo/models.py
Original file line number Diff line number Diff line change
@@ -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 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}'

class Meta:
verbose_name = 'Colocation Onboarding'
5 changes: 5 additions & 0 deletions bb_colo/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
''' bb_colo - views.py '''

# from django.shortcuts import render

# Create your views here.
8 changes: 6 additions & 2 deletions bb_vm/bash_scripts/brick_connect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ 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 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
14 changes: 11 additions & 3 deletions bb_vm/bash_scripts/brick_play.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -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 &

exit 0
else
echo "Brick failed to start."
Expand Down
7 changes: 6 additions & 1 deletion bb_vm/bash_scripts/brick_reconnect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
115 changes: 115 additions & 0 deletions bb_vm/bash_scripts/logs/brick_connect_errors.log
Original file line number Diff line number Diff line change
Expand Up @@ -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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 94 0 0 100 94 0 676 --:--:-- --:--:-- --:--:-- 671100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 2926 100 1517 100 1409 2528 2348 --:--:-- --:--:-- --:--:-- 4868100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 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 --:--:-- --:--:-- --:--:-- 0100 269 100 175 100 94 1483 796 --:--:-- --:--:-- --:--:-- 2279
Expand Down
8 changes: 6 additions & 2 deletions brickbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'''
21 changes: 21 additions & 0 deletions django_dash_black/static/assets/js/colo/onboarding.js
Original file line number Diff line number Diff line change
@@ -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);
});
}
4 changes: 2 additions & 2 deletions django_dash_black/templates/bricks.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h4 class="title">Add Brick Instance</h4>


<!-- ------------------------- START Create Brick -------------------------- -->
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6">
<div class="card">

<div class="card-header">
Expand Down Expand Up @@ -72,7 +72,7 @@ <h4 class="title">Add Brick Instance</h4>


<!-- ---------------------- START - Create 3070 Brick ---------------------- -->
<div class="col-lg-2 col-md-4 col-sm-6">
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-6">
<div class="card">

<div class="card-header">
Expand Down
Loading