forked from 3wordchant/capsul-flask
SSH keys CRUD working
This commit is contained in:
capsulflask
@ -55,12 +55,29 @@ class DBModel:
|
||||
return vmSizes
|
||||
|
||||
def list_ssh_public_keys_for_account(self, email):
|
||||
self.cursor.execute("SELECT name, content FROM ssh_public_keys WHERE email = %s", (email, ))
|
||||
self.cursor.execute("SELECT name, content, created FROM ssh_public_keys WHERE email = %s", (email, ))
|
||||
return map(
|
||||
lambda x: dict(name=x[0], content=x[1]),
|
||||
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) )
|
||||
return len(self.cursor.fetchall()) > 0
|
||||
|
||||
def create_ssh_public_key(self, email, name, content):
|
||||
self.cursor.execute("""
|
||||
INSERT INTO ssh_public_keys (email, name, content)
|
||||
VALUES (%s, %s, %s)
|
||||
""",
|
||||
(email, name, content)
|
||||
)
|
||||
self.connection.commit()
|
||||
|
||||
def delete_ssh_public_key(self, email, name):
|
||||
self.cursor.execute( "DELETE FROM ssh_public_keys where email = %s AND name = %s", (email, name) )
|
||||
self.connection.commit()
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user