From 783e13b9cdc3e69328db5f47fc8c2c4f3701c6bc Mon Sep 17 00:00:00 2001 From: Jordan Rodgers Date: Mon, 8 Apr 2019 23:18:20 -0400 Subject: [PATCH] we can use the http api now, stop using ssh --- proxstar/proxmox.py | 3 ++- proxstar/templates/base.html | 1 - proxstar/vm.py | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/proxstar/proxmox.py b/proxstar/proxmox.py index 3d1ebe9..89025c9 100644 --- a/proxstar/proxmox.py +++ b/proxstar/proxmox.py @@ -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'] diff --git a/proxstar/templates/base.html b/proxstar/templates/base.html index bc59090..772a33b 100644 --- a/proxstar/templates/base.html +++ b/proxstar/templates/base.html @@ -9,7 +9,6 @@ - {% block nav %} diff --git a/proxstar/vm.py b/proxstar/vm.py index c60a321..1504758 100644 --- a/proxstar/vm.py +++ b/proxstar/vm.py @@ -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')