mirror of
				https://github.com/ComputerScienceHouse/proxstar.git
				synced 2025-03-09 15:40:09 +00:00 
			
		
		
		
	remove ssh queue
This commit is contained in:
		
							parent
							
								
									f5a36d6f1e
								
							
						
					
					
						commit
						4a2df4d979
					
				
					 2 changed files with 27 additions and 40 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,5 @@
 | 
			
		|||
import os
 | 
			
		||||
import paramiko
 | 
			
		||||
from rq import Queue
 | 
			
		||||
from redis import Redis
 | 
			
		||||
from flask import Flask
 | 
			
		||||
from sqlalchemy import create_engine
 | 
			
		||||
from sqlalchemy.orm import sessionmaker
 | 
			
		||||
| 
						 | 
				
			
			@ -21,9 +19,6 @@ else:
 | 
			
		|||
    config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
 | 
			
		||||
app.config.from_pyfile(config)
 | 
			
		||||
 | 
			
		||||
redis_conn = Redis(app.config['REDIS_HOST'], app.config['REDIS_PORT'])
 | 
			
		||||
q = Queue(connection=redis_conn)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def connect_db():
 | 
			
		||||
    engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +106,6 @@ def generate_pool_cache_task():
 | 
			
		|||
 | 
			
		||||
def setup_template(template_id, name, user, password, cores, memory):
 | 
			
		||||
    with app.app_context():
 | 
			
		||||
        q = Queue('ssh', connection=redis_conn)
 | 
			
		||||
        proxmox = connect_proxmox()
 | 
			
		||||
        starrs = connect_starrs()
 | 
			
		||||
        db = connect_db()
 | 
			
		||||
| 
						 | 
				
			
			@ -125,10 +119,6 @@ def setup_template(template_id, name, user, password, cores, memory):
 | 
			
		|||
        time.sleep(90)
 | 
			
		||||
        change_vm_power(proxmox, vmid, 'start')
 | 
			
		||||
        time.sleep(20)
 | 
			
		||||
        q.enqueue(setup_template_ssh, ip, template, user, password)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def setup_template_ssh(ip, template, user, password):
 | 
			
		||||
        client = paramiko.SSHClient()
 | 
			
		||||
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 | 
			
		||||
        retry = 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
/opt/app-root/bin/rq worker -u "$PROXSTAR_REDIS_URL" --sentry-dsn "$PROXSTAR_SENTRY_DSN" ssh
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue