mirror of
				https://github.com/ComputerScienceHouse/proxstar.git
				synced 2025-03-09 15:40:09 +00:00 
			
		
		
		
	remove ignored pools config, check valid user when generating pool list, add start for ssh tasks
This commit is contained in:
		
							parent
							
								
									b57279788d
								
							
						
					
					
						commit
						cab0745707
					
				
					 5 changed files with 20 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -2,10 +2,6 @@ from os import environ
 | 
			
		|||
 | 
			
		||||
# Proxstar
 | 
			
		||||
VM_EXPIRE_MONTHS = int(environ.get('PROXSTAR_VM_EXPIRE_MONTHS', '3'))
 | 
			
		||||
IGNORED_POOLS = [
 | 
			
		||||
    pool.strip()
 | 
			
		||||
    for pool in environ.get('PROXSTAR_IGNORED_POOLS', '').split(',')
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
# Flask
 | 
			
		||||
IP = environ.get('PROXSTAR_IP', '0.0.0.0')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,3 +21,12 @@ def is_active(user):
 | 
			
		|||
    ldap = connect_ldap()
 | 
			
		||||
    rtp_group = ldap.get_group('active')
 | 
			
		||||
    return rtp_group.check_member(ldap.get_member(user, uid=True))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def is_user(user):
 | 
			
		||||
    ldap = connect_ldap()
 | 
			
		||||
    try:
 | 
			
		||||
        rtp_group = ldap.get_member(user, uid=True)
 | 
			
		||||
        return True
 | 
			
		||||
    except:
 | 
			
		||||
        return False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -277,7 +277,7 @@ def get_pools(proxmox):
 | 
			
		|||
    pools = []
 | 
			
		||||
    for pool in proxmox.pools.get():
 | 
			
		||||
        poolid = pool['poolid']
 | 
			
		||||
        if poolid not in app.config['IGNORED_POOLS']:
 | 
			
		||||
        if is_user(poolid):
 | 
			
		||||
            pools.append(poolid)
 | 
			
		||||
    pools = sorted(pools)
 | 
			
		||||
    return pools
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
import os
 | 
			
		||||
import paramiko
 | 
			
		||||
from flask import Flask
 | 
			
		||||
from sqlalchemy import create_engine
 | 
			
		||||
from sqlalchemy.orm import sessionmaker
 | 
			
		||||
| 
						 | 
				
			
			@ -101,3 +102,11 @@ def generate_pool_cache_task():
 | 
			
		|||
        db = connect_db()
 | 
			
		||||
        pools = get_vms_for_rtp(proxmox, db)
 | 
			
		||||
        store_pool_cache(db, pools)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def setup_template(hostname):
 | 
			
		||||
    with app.app_context():
 | 
			
		||||
        db = connect_db()
 | 
			
		||||
        client = paramiko.SSHClient()
 | 
			
		||||
        client.connect('ssh.example.com', username='root', password='todo')
 | 
			
		||||
        stdin, stdout, stderr = client.exec_command('ls')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,3 +9,4 @@ rq
 | 
			
		|||
rq-scheduler
 | 
			
		||||
gunicorn
 | 
			
		||||
raven
 | 
			
		||||
paramiko
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue