-
Notifications
You must be signed in to change notification settings - Fork 1
/
furry_shame.py
76 lines (54 loc) · 1.89 KB
/
furry_shame.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# GPLv3
# (c) 2013 Ville Korhonen <[email protected]>
import os
import sys
import json
import requests
import argparse
import logging
import subprocess
WEBVM_API_URL = 'http://nm.0xff.fi/api/v1'
WEBVM_CONFIG_PATH = '~/.config/webvm'
# TODO: If config file doesn't exist, create it (using defaults + cli args)
class WebVMClient(object):
def __init__(self, url, *args, **kwargs):
self._api_url = url
# TODO: Allow user to log-in w/ username+password & fetch OAuth token
def cmd_register(self):
# TODO: Register as a new slave, submit SSH key
# TODO: Create SSH key
# cmd = ['ssh-keygen', '-q', '-t', 'rsa', '-C', 'WebVM Slave key for %s' % slaveid, '-f', outfile, '-N', '']
# TODO: Submit SSH public key via API
# requests.post(api_url, ...), if status == 200, ...
# TODO: receive Slave ID, save to config
pass
def cmd_unregister(self):
# TODO: Sent request to disable this slave, via API
# requests.post(...)
pass
def cmd_destroy_vm(self, uuid):
# TODO: Destroy VM
# (pids, kill 'em all!, ...)
pass
def cmd_create_vm(self, uuid):
# TODO: Create new VM
# TODO: use webvm_test.sh, collect pids
pass
def main(args):
slave = WebVMClient(url=args.api_url)
print 'API: %s' % url
return 0
def run():
parser = argparse.ArgumentParser(
description='WebVM Slave Client',
)
parser.add_argument('--api-url', dest='api_url', help='API URL', default=WEBVM_API_URL)
parser.add_argument('-u', '--username', dest='username', help='API username')
parser.add_argument('-p', '--password', dest='password', help='API password')
parser.add_argument('command')
args = parser.parse_args()
sys.exit(main(args))
if __name__ == "__main__":
run()