From 26b7ea3ef23e96d37e3f201215cb523f64190790 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Sat, 25 Jun 2022 18:24:52 +0530 Subject: [PATCH] fix & rm: create/rm hostscripts, rm HOSTEA_DOMAIN --- dashboard/settings.py | 5 ++--- docs/INSTALL.md | 3 --- .../migrations/0002_instancecreated_gitea_password.py | 10 ++++++---- .../templates/infrastructure/sh/hostscripts/create.sh | 4 ++-- .../templates/infrastructure/sh/hostscripts/rm.sh | 2 +- infrastructure/tests.py | 4 ++-- infrastructure/utils.py | 7 +++---- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/dashboard/settings.py b/dashboard/settings.py index 3b1823e..2f5fca9 100644 --- a/dashboard/settings.py +++ b/dashboard/settings.py @@ -186,9 +186,7 @@ HOSTEA = { "REMOTE": "git@localhost:Hostea/enough.git", # SSH key that can push to the Git repository remote mentioned above "SSH_KEY": "/srv/hostea/deploy", - }, - # domain where new VMs will be created - "HOSTEA_DOMAIN": "hostea.org", + } }, } @@ -198,6 +196,7 @@ vars().update(EMAIL_CONFIG) try: import dashboard.local_settings + print("Found local_settings") except ModuleNotFoundError: pass diff --git a/docs/INSTALL.md b/docs/INSTALL.md index dbf6a27..c9d1c7e 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -87,9 +87,6 @@ HOSTEA = { # SSH key that can push to the Git repository remote mentioned above "SSH_KEY": "/srv/hostea/deploy", }, - # domain where new VMs will be created - "HOSTEA_DOMAIN": "hostea.org" - }, ``` diff --git a/infrastructure/migrations/0002_instancecreated_gitea_password.py b/infrastructure/migrations/0002_instancecreated_gitea_password.py index 8a126d2..0777dbd 100644 --- a/infrastructure/migrations/0002_instancecreated_gitea_password.py +++ b/infrastructure/migrations/0002_instancecreated_gitea_password.py @@ -6,13 +6,15 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('infrastructure', '0001_initial'), + ("infrastructure", "0001_initial"), ] operations = [ migrations.AddField( - model_name='instancecreated', - name='gitea_password', - field=models.CharField(default=None, max_length=32, verbose_name='Name of this configuration'), + model_name="instancecreated", + name="gitea_password", + field=models.CharField( + default=None, max_length=32, verbose_name="Name of this configuration" + ), ), ] diff --git a/infrastructure/templates/infrastructure/sh/hostscripts/create.sh b/infrastructure/templates/infrastructure/sh/hostscripts/create.sh index 5511578..4a4f752 100644 --- a/infrastructure/templates/infrastructure/sh/hostscripts/create.sh +++ b/infrastructure/templates/infrastructure/sh/hostscripts/create.sh @@ -1,2 +1,2 @@ -enough --domain d.{{ hostea_domain }} host create {{subdomain}}-host -enough --domain d.{{ hostea_domain }} service create --host {{subdomain}}-host gitea +enough --domain $domain host create {{subdomain}}-host +enough --domain $domain service create --host {{subdomain}}-host gitea diff --git a/infrastructure/templates/infrastructure/sh/hostscripts/rm.sh b/infrastructure/templates/infrastructure/sh/hostscripts/rm.sh index 61d1a22..43a649c 100644 --- a/infrastructure/templates/infrastructure/sh/hostscripts/rm.sh +++ b/infrastructure/templates/infrastructure/sh/hostscripts/rm.sh @@ -1 +1 @@ -enough --domain d.{{ hostea_domain }} host delete hostea001-host +enough --domain $domain host delete hostea001-host diff --git a/infrastructure/tests.py b/infrastructure/tests.py index 2ddaac4..f6cd742 100644 --- a/infrastructure/tests.py +++ b/infrastructure/tests.py @@ -42,7 +42,6 @@ class InfraUtilTest(TestCase): "REMOTE": "git@git.batsense.net:realaravinth/dummy-hostea-dash-test", "SSH_KEY": "/src/atm/.ssh/aravinth", }, - "HOSTEA_DOMAIN": "hostea.org", } } ) @@ -84,7 +83,6 @@ class InfraUtilTest(TestCase): "REMOTE": "git@git.batsense.net:realaravinth/dummy-hostea-dash-test", "SSH_KEY": "/src/atm/.ssh/aravinth", }, - "HOSTEA_DOMAIN": "hostea.org", } } ) @@ -102,3 +100,5 @@ class InfraUtilTest(TestCase): instance = Instance.objects.get(name=subdomain) woodpecker_agent_secret = infra.add_vm(instance=instance) + + # infra.remove_vm(instance=instance) diff --git a/infrastructure/utils.py b/infrastructure/utils.py index 69a6ed5..cd47054 100644 --- a/infrastructure/utils.py +++ b/infrastructure/utils.py @@ -32,7 +32,6 @@ class Infra: def __init__(self): conf = settings.HOSTEA["INFRA"]["HOSTEA_REPO"] - self.hostea_domain = settings.HOSTEA["INFRA"]["HOSTEA_DOMAIN"] self.repo_path = Path(conf["PATH"]) if not self.repo_path.exists(): os.makedirs(self.repo_path) @@ -189,7 +188,7 @@ class Infra: subdomain=subdomain, content=render_to_string( "infrastructure/sh/hostscripts/create.sh", - context={"subdomain": subdomain, "hostea_domain": self.hostea_domain}, + context={"subdomain": subdomain}, ), ) @@ -213,8 +212,8 @@ class Infra: self.write_hostscript( subdomain=subdomain, content=render_to_string( - "infrastructure/sh/hostscripts/create.sh", - context={"subdomain": subdomain, "hostea_domain": self.hostea_domain}, + "infrastructure/sh/hostscripts/rm.sh", + context={"subdomain": subdomain}, ), ) self._commit(action="rm", subdomain=subdomain)