OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """A CherryPy-based webserver to host images and build packages.""" | 7 """A CherryPy-based webserver to host images and build packages.""" |
8 | 8 |
9 import cherrypy | 9 import cherrypy |
10 import optparse | 10 import optparse |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 | 57 |
58 def _PrepareToServeUpdatesOnly(image_dir): | 58 def _PrepareToServeUpdatesOnly(image_dir): |
59 """Sets up symlink to image_dir for serving purposes.""" | 59 """Sets up symlink to image_dir for serving purposes.""" |
60 assert os.path.exists(image_dir), '%s must exist.' % image_dir | 60 assert os.path.exists(image_dir), '%s must exist.' % image_dir |
61 # If we're serving out of an archived build dir (e.g. a | 61 # If we're serving out of an archived build dir (e.g. a |
62 # buildbot), prepare this webserver's magic 'static/' dir with a | 62 # buildbot), prepare this webserver's magic 'static/' dir with a |
63 # link to the build archive. | 63 # link to the build archive. |
64 cherrypy.log('Preparing autoupdate for "serve updates only" mode.', | 64 cherrypy.log('Preparing autoupdate for "serve updates only" mode.', |
65 'DEVSERVER') | 65 'DEVSERVER') |
66 if os.path.exists('static/archive'): | 66 if os.path.lexists('static/archive'): |
67 if image_dir != os.readlink('static/archive'): | 67 if image_dir != os.readlink('static/archive'): |
68 cherrypy.log('removing stale symlink to %s' % image_dir, 'DEVSERVER') | 68 cherrypy.log('removing stale symlink to %s' % image_dir, 'DEVSERVER') |
69 os.unlink('static/archive') | 69 os.unlink('static/archive') |
70 os.symlink(image_dir, 'static/archive') | 70 os.symlink(image_dir, 'static/archive') |
71 else: | 71 else: |
72 os.symlink(image_dir, 'static/archive') | 72 os.symlink(image_dir, 'static/archive') |
73 cherrypy.log('archive dir: %s ready to be used to serve images.' % image_dir, | 73 cherrypy.log('archive dir: %s ready to be used to serve images.' % image_dir, |
74 'DEVSERVER') | 74 'DEVSERVER') |
75 | 75 |
76 | 76 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', | 128 parser.add_option('--for_vm', dest='vm', default=False, action='store_true', |
129 help='Update is for a vm image.') | 129 help='Update is for a vm image.') |
130 parser.add_option('--image', dest='image', | 130 parser.add_option('--image', dest='image', |
131 help='Force update using this image.') | 131 help='Force update using this image.') |
132 parser.add_option('-p', '--pregenerate_update', action='store_true', | 132 parser.add_option('-p', '--pregenerate_update', action='store_true', |
133 default=False, help='Pre-generate update payload.') | 133 default=False, help='Pre-generate update payload.') |
134 parser.add_option('--payload', dest='payload', | 134 parser.add_option('--payload', dest='payload', |
135 help='Use update payload from specified directory.') | 135 help='Use update payload from specified directory.') |
136 parser.add_option('--port', default=8080, | 136 parser.add_option('--port', default=8080, |
137 help='Port for the dev server to use.') | 137 help='Port for the dev server to use.') |
| 138 parser.add_option('--private_key', default=None, |
| 139 help='Path to the private key in pem format.') |
138 parser.add_option('--production', action='store_true', default=False, | 140 parser.add_option('--production', action='store_true', default=False, |
139 help='Have the devserver use production values.') | 141 help='Have the devserver use production values.') |
140 parser.add_option('--proxy_port', default=None, | 142 parser.add_option('--proxy_port', default=None, |
141 help='Port to have the client connect to (testing support)') | 143 help='Port to have the client connect to (testing support)') |
142 parser.add_option('--src_image', default='', | 144 parser.add_option('--src_image', default='', |
143 help='Image on remote machine for generating delta update.') | 145 help='Image on remote machine for generating delta update.') |
144 parser.add_option('-t', action='store_true', dest='test_image') | 146 parser.add_option('-t', action='store_true', dest='test_image') |
145 parser.add_option('-u', '--urlbase', dest='urlbase', | 147 parser.add_option('-u', '--urlbase', dest='urlbase', |
146 help='base URL, other than devserver, for update images.') | 148 help='base URL, other than devserver, for update images.') |
147 parser.add_option('--validate_factory_config', action="store_true", | 149 parser.add_option('--validate_factory_config', action="store_true", |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 test_image=options.test_image, | 197 test_image=options.test_image, |
196 factory_config_path=options.factory_config, | 198 factory_config_path=options.factory_config, |
197 client_prefix=options.client_prefix, | 199 client_prefix=options.client_prefix, |
198 forced_image=options.image, | 200 forced_image=options.image, |
199 forced_payload=options.payload, | 201 forced_payload=options.payload, |
200 port=options.port, | 202 port=options.port, |
201 proxy_port=options.proxy_port, | 203 proxy_port=options.proxy_port, |
202 src_image=options.src_image, | 204 src_image=options.src_image, |
203 vm=options.vm, | 205 vm=options.vm, |
204 board=options.board, | 206 board=options.board, |
205 copy_to_static_root=not options.exit) | 207 copy_to_static_root=not options.exit, |
| 208 private_key=options.private_key, |
| 209 ) |
206 | 210 |
207 # Sanity-check for use of validate_factory_config. | 211 # Sanity-check for use of validate_factory_config. |
208 if not options.factory_config and options.validate_factory_config: | 212 if not options.factory_config and options.validate_factory_config: |
209 parser.error('You need a factory_config to validate.') | 213 parser.error('You need a factory_config to validate.') |
210 | 214 |
211 if options.factory_config: | 215 if options.factory_config: |
212 updater.ImportFactoryConfigFile(options.factory_config, | 216 updater.ImportFactoryConfigFile(options.factory_config, |
213 options.validate_factory_config) | 217 options.validate_factory_config) |
214 # We don't run the dev server with this option. | 218 # We don't run the dev server with this option. |
215 if options.validate_factory_config: | 219 if options.validate_factory_config: |
216 sys.exit(0) | 220 sys.exit(0) |
217 elif options.pregenerate_update: | 221 elif options.pregenerate_update: |
218 if not updater.PreGenerateUpdate(): | 222 if not updater.PreGenerateUpdate(): |
219 sys.exit(1) | 223 sys.exit(1) |
220 | 224 |
221 # If the command line requested after setup, it's time to do it. | 225 # If the command line requested after setup, it's time to do it. |
222 if not options.exit: | 226 if not options.exit: |
223 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) | 227 cherrypy.quickstart(DevServerRoot(), config=_GetConfig(options)) |
OLD | NEW |