Merge pull request #18 from com6056/jrodgers-fix-proxmox-version

we can use the http api now, stop using ssh
This commit is contained in:
Jordan Rodgers 2019-04-08 20:22:28 -07:00 committed by GitHub
commit b3c62515fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View file

@ -45,7 +45,8 @@ def connect_proxmox_ssh():
def get_node_least_mem(proxmox):
nodes = proxmox.nodes.get()
sorted_nodes = sorted(nodes, key=lambda x: x['mem'])
sorted_nodes = sorted(
nodes, key=lambda x: ('mem' not in x, x.get('mem', None)))
return sorted_nodes[0]['node']

View file

@ -9,7 +9,6 @@
<link rel="stylesheet" href="https://themeswitcher.csh.rit.edu/api/get" media="screen">
<link rel="stylesheet" href="/static/css/styles.css">
<link rel="stylesheet" href="/static/css/circle.css">
<link rel="manifest" href="/static/manifest.json">
</head>
<body>
{% block nav %}

View file

@ -7,8 +7,7 @@ from tenacity import retry, stop_after_attempt, wait_fixed
from proxstar import db, starrs
from proxstar.db import delete_vm_expire, get_vm_expire
from proxstar.proxmox import (connect_proxmox, connect_proxmox_ssh,
get_free_vmid, get_node_least_mem, get_vm_node)
from proxstar.proxmox import connect_proxmox, get_free_vmid, get_node_least_mem, get_vm_node
from proxstar.starrs import get_ip_for_mac
from proxstar.util import lazy_property
@ -236,18 +235,18 @@ class VM(object):
@retry(wait=wait_fixed(2), stop=stop_after_attempt(5))
def set_ci_user(self, user):
proxmox = connect_proxmox_ssh()
proxmox = connect_proxmox()
proxmox.nodes(self.node).qemu(self.id).config.put(ciuser=user)
@retry(wait=wait_fixed(2), stop=stop_after_attempt(5))
def set_ci_ssh_key(self, ssh_key):
proxmox = connect_proxmox_ssh()
proxmox = connect_proxmox()
escaped_key = urllib.parse.quote(ssh_key, safe='')
proxmox.nodes(self.node).qemu(self.id).config.put(sshkey=escaped_key)
proxmox.nodes(self.node).qemu(self.id).config.put(sshkeys=escaped_key)
@retry(wait=wait_fixed(2), stop=stop_after_attempt(5))
def set_ci_network(self):
proxmox = connect_proxmox_ssh()
proxmox = connect_proxmox()
proxmox.nodes(self.node).qemu(self.id).config.put(ipconfig0='ip=dhcp')