create capsul and capsuls list page working

This commit is contained in:
2020-05-11 15:13:20 -05:00
parent 452f236c6b
commit 231d1ed7c0
11 changed files with 210 additions and 124 deletions

View File

@ -34,7 +34,7 @@ class DBModel:
def all_vm_ids(self,):
self.cursor.execute("SELECT id FROM vms")
return map(lambda x: x[0], self.cursor.fetchall())
return list(map(lambda x: x[0], self.cursor.fetchall()))
def operating_systems_dict(self,):
self.cursor.execute("SELECT id, template_image_file_name, description FROM os_images")
@ -56,10 +56,10 @@ class DBModel:
def list_ssh_public_keys_for_account(self, email):
self.cursor.execute("SELECT name, content, created FROM ssh_public_keys WHERE email = %s", (email, ))
return map(
return list(map(
lambda x: dict(name=x[0], content=x[1], created=x[2]),
self.cursor.fetchall()
)
))
def ssh_public_key_name_exists(self, email, name):
self.cursor.execute( "SELECT name FROM ssh_public_keys where email = %s AND name = %s", (email, name) )
@ -80,15 +80,14 @@ class DBModel:
def list_vms_for_account(self, email):
self.cursor.execute("""
SELECT vms.id, vms.last_seen_ipv4, vms.last_seen_ipv6, vms.size, os_images.description, vms.created, vms.deleted
FROM vms JOIN os_images on os_images.id = vms.os
WHERE vms.email = %s""",
SELECT vms.id, vms.last_seen_ipv4, vms.last_seen_ipv6, vms.size, vms.os, vms.created, vms.deleted
FROM vms WHERE vms.email = %s""",
(email, )
)
return map(
return list(map(
lambda x: dict(id=x[0], ipv4=x[1], ipv6=x[2], size=x[3], os=x[4], created=x[5], deleted=x[6]),
self.cursor.fetchall()
)
))
def create_vm(self, email, id, size, os):
self.cursor.execute("""