Skip to content

Commit

Permalink
adjust some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
usmannasir committed Dec 22, 2023
1 parent 3df9a43 commit fd2f170
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
26 changes: 25 additions & 1 deletion plogical/DockerSites.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,30 @@ def DeleteDockerApp(self):
command = f'rm -f /home/{self.data["domain"]}/public_html/.htaccess'
ProcessUtilities.executioner(command)


### forcefully delete containers

import docker

# Create a Docker client
client = docker.from_env()

# Define the label to filter containers
label_filter = {'name': self.data['name'].replace(' ', '-')}

# List containers matching the label filter
containers = client.containers.list(filters=label_filter)

logging.writeToFile(f'List of containers {str(containers)}')


for container in containers:
command = f'docker stop {container.short_id}'
ProcessUtilities.executioner(command)

command = f'docker rm {container.short_id}'
ProcessUtilities.executioner(command)

from plogical.installUtilities import installUtilities
installUtilities.reStartLiteSpeed()

Expand All @@ -542,7 +566,7 @@ def ListContainers(self):
client = docker.from_env()

# Define the label to filter containers
label_filter = {'name': self.data['name']}
label_filter = {'name': self.data['name'].replace(' ', '-')}

# List containers matching the label filter
containers = client.containers.list(filters=label_filter)
Expand Down
2 changes: 1 addition & 1 deletion websiteFunctions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class DockerSites(models.Model):
port = models.CharField(max_length=100)
CPUsSite = models.CharField(max_length=100)
MemorySite = models.CharField(max_length=100)
SiteName = models.TextField()
SiteName = models.TextField(unique=True)
finalURL = models.TextField()
blogTitle = models.TextField()
adminUser = models.CharField(max_length=100)
Expand Down
1 change: 1 addition & 0 deletions websiteFunctions/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -6906,6 +6906,7 @@ def ListDockerSites(self, request=None, userID=None, data=None, DeleteID=None):
passdata={}
passdata["domain"] = DockerSitesDelete.admin.domain
passdata["JobID"] = None
passdata['name'] = DockerSitesDelete.SiteName
da = Docker_Sites(None, passdata)
da.DeleteDockerApp()
DockerSitesDelete.delete()
Expand Down

0 comments on commit fd2f170

Please sign in to comment.