-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnovnc.py
70 lines (60 loc) · 2.27 KB
/
novnc.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
import em
import pkgutil
import sys
from rocker.extensions import RockerExtension, name_to_argument
class NoVNC(RockerExtension):
@staticmethod
def get_name():
return 'novnc'
def __init__(self):
self._env_subs = {}
self.name = NoVNC.get_name()
def precondition_environment(self, cli_args):
pass
def validate_environment(self, cli_args):
pass
def get_preamble(self, cli_args):
return ''
def get_files(self, cli_args):
file_list = ['supervisor.conf', 'self.pem', 'nginx.conf']
files = {}
for f in file_list:
files['%s' % f] = pkgutil.get_data(
'novnc_rocker',
'templates/%s' % f).decode('utf-8')
template_list = ['novnc.conf', 'rproxy-nginx-site', '.htpasswd']
for f in template_list:
files['%s' % f] = em.expand(
pkgutil.get_data(
'novnc_rocker',
'templates/%s.em' % f).decode('utf-8'),
cli_args)
return files
def get_snippet(self, cli_args):
snippet = pkgutil.get_data(
'novnc_rocker',
'templates/%s_snippet.Dockerfile.em' % self.name).decode('utf-8')
return em.expand(snippet, self._env_subs)
def get_docker_args(self, cli_args):
return ' -p %s:%s' % (cli_args['novnc_port'], cli_args['novnc_port'])
@staticmethod
def register_arguments(parser, defaults={}):
parser.add_argument(name_to_argument(NoVNC.get_name()),
action='store_true',
default=defaults.get(NoVNC.get_name(), None),
help="enable noVNC")
parser.add_argument('--novnc-port',
action='store',
type=int,
default=defaults.get('novnc-port', 8080),
help="what port to use for novnc")
parser.add_argument('--novnc-user',
action='store',
type=str,
default=defaults.get('novnc-user', 'novnc_example_user'),
help="what username to use for novnc")
parser.add_argument('--novnc-password',
action='store',
type=str,
default=defaults.get('novnc-user', 'novnc_example_password_$Insecure_$Changeme!!'),
help="what password to use for novnc")