From d2cc4878773daafd40d664e27bcb58096324a0f5 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Mon, 11 Dec 2023 15:28:55 +0500 Subject: [PATCH] docker sites model --- dockerManager/models.py | 28 ++++++++++++++++++++++++++++ plogical/DockerSites.py | 17 +++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/dockerManager/models.py b/dockerManager/models.py index f1b895c95..bef790aa5 100755 --- a/dockerManager/models.py +++ b/dockerManager/models.py @@ -3,6 +3,7 @@ from django.db import models from loginSystem.models import Administrator +from websiteFunctions.website import Websites # Create your models here. class Containers(models.Model): @@ -16,3 +17,30 @@ class Containers(models.Model): volumes = models.TextField(default="{}") env = models.TextField(default="{}") startOnReboot = models.IntegerField(default=0) + +# Takes +# ComposePath, MySQLPath, MySQLRootPass, MySQLDBName, MySQLDBNUser, MySQLPassword, CPUsMySQL, MemoryMySQL, +# port, SitePath, CPUsSite, MemorySite, SiteName +# finalURL, blogTitle, adminUser, adminPassword, adminEmail + +### Site Type 0=wp, further tbd later + +class DockerSites(models.Model): + admin = models.ForeignKey(Websites, on_delete=models.CASCADE) + ComposePath = models.TextField() + SitePath = models.TextField() + MySQLPath = models.TextField() + state = models.IntegerField(default=1) + SiteType = models.IntegerField(default=0) ## WP, Joomla etc + MySQLDBName = models.CharField(max_length=100) + MySQLDBNUser = models.CharField(max_length=100) + CPUsMySQL = models.CharField(max_length=100) + MemoryMySQL = models.CharField(max_length=100) + port = models.CharField(max_length=100) + CPUsSite = models.CharField(max_length=100) + MemorySite = models.CharField(max_length=100) + SiteName = models.TextField() + finalURL = models.TextField() + blogTitle = models.TextField() + adminUser = models.CharField(max_length=100) + adminEmail = models.CharField(max_length=100) \ No newline at end of file diff --git a/plogical/DockerSites.py b/plogical/DockerSites.py index 23fa97040..a2d883dec 100644 --- a/plogical/DockerSites.py +++ b/plogical/DockerSites.py @@ -1,3 +1,7 @@ +#!/usr/local/CyberCP/bin/python +import sys +sys.path.append('/usr/local/CyberCP') +import django from plogical.processUtilities import ProcessUtilities from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging @@ -30,8 +34,9 @@ def DeployWPContainer(self): command = 'docker --help' - ReturnCode = ProcessUtilities.executioner(command) - if ReturnCode == 0: + result = ProcessUtilities.outputExecutioner(command) + print(f'return code of docker install {result}') + if result.find("not found") > -1: status, message = self.InstallDocker() if status == 0: logging.statusWriter(self.JobID, 'Failed to installed docker. [404]') @@ -124,9 +129,9 @@ def Main(): # port, SitePath, CPUsSite, MemorySite, SiteName # finalURL, blogTitle, adminUser, adminPassword, adminEmail data = { - "JobID": 1122344566667778888, - "ComposePath": "/home/dockercloudpagescloud/docker-compose.yml", - "MySQLPath": '/home/dockercloudpagescloud/public_html/sqldocker', + "JobID": '/home/cyberpanel/error-logs.txt', + "ComposePath": "/home/cyberpanel.net/docker-compose.yml", + "MySQLPath": '/home/cyberpanel.net/public_html/sqldocker', "MySQLRootPass": 'testdbwp12345', "MySQLDBName": 'testdbwp', "MySQLDBNUser": 'testdbwp', @@ -134,7 +139,7 @@ def Main(): "CPUsMySQL": '2', "MemoryMySQL": '512', "port": '8000', - "SitePath": '/home/dockercloudpagescloud/public_html/wpdocker', + "SitePath": '/home/cyberpanel.net/public_html/wpdocker', "CPUsSite": '2', "MemorySite": '512', "SiteName": 'wp docker test',