Changeset 2706 for package_branches
- Timestamp:
- Dec 20, 2009, 9:46:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy-rebased/code/main.py
r2705 r2706 200 200 201 201 def parseCreate(self, fields): 202 kws = dict([(kw, fields.get(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split() if fields.get(kw)]) 203 validate = validation.Validate(cherrypy.request.login, cherrypy.request.state, strict=True, **kws) 204 return dict(contact=cherrypy.request.login, name=validate.name, description=validate.description, memory=validate.memory, 205 disksize=validate.disksize, owner=validate.owner, machine_type=getattr(validate, 'vmtype', Defaults.type), 202 kws = dict([(kw, fields.get(kw)) for kw in 203 'name description owner memory disksize vmtype cdrom autoinstall'.split() 204 if fields.get(kw)]) 205 validate = validation.Validate(cherrypy.request.login, 206 cherrypy.request.state, 207 strict=True, **kws) 208 return dict(contact=cherrypy.request.login, name=validate.name, 209 description=validate.description, memory=validate.memory, 210 disksize=validate.disksize, owner=validate.owner, 211 machine_type=getattr(validate, 'vmtype', Defaults.type), 206 212 cdrom=getattr(validate, 'cdrom', None), 207 213 autoinstall=getattr(validate, 'autoinstall', None)) … … 214 220 try: 215 221 parsed_fields = self.parseCreate(fields) 216 machine = controls.createVm(cherrypy.request.login, cherrypy.request.state, **parsed_fields) 222 machine = controls.createVm(cherrypy.request.login, 223 cherrypy.request.state, **parsed_fields) 217 224 except InvalidInput, err: 218 225 pass … … 258 265 def info(self, machine_id): 259 266 """Handler for info on a single VM.""" 260 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 267 machine = validation.Validate(cherrypy.request.login, 268 cherrypy.request.state, 269 machine_id=machine_id).machine 261 270 d = infoDict(cherrypy.request.login, cherrypy.request.state, machine) 262 271 checkpoint.checkpoint('Got infodict') … … 270 279 """Handler for modifying attributes of a machine.""" 271 280 try: 272 modify_dict = modifyDict(cherrypy.request.login, cherrypy.request.state, machine_id, fields) 281 modify_dict = modifyDict(cherrypy.request.login, 282 cherrypy.request.state, 283 machine_id, fields) 273 284 except InvalidInput, err: 274 285 result = None 275 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 286 machine = validation.Validate(cherrypy.request.login, 287 cherrypy.request.state, 288 machine_id=machine_id).machine 276 289 else: 277 290 machine = modify_dict['machine'] 278 291 result = 'Success!' 279 292 err = None 280 info_dict = infoDict(cherrypy.request.login, cherrypy.request.state, machine) 293 info_dict = infoDict(cherrypy.request.login, 294 cherrypy.request.state, machine) 281 295 info_dict['err'] = err 282 296 if err: … … 308 322 echo 1 > /proc/sys/net/ipv4/ip_forward 309 323 """ 310 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 311 324 machine = validation.Validate(cherrypy.request.login, 325 cherrypy.request.state, 326 machine_id=machine_id).machine 312 327 token = controls.vnctoken(machine) 313 328 host = controls.listHost(machine) … … 334 349 back = kwargs.get('back', None) 335 350 try: 336 d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs) 351 d = controls.commandResult(cherrypy.request.login, 352 cherrypy.request.state, 353 command_name, machine_id, kwargs) 337 354 if d['command'] == 'Delete VM': 338 355 back = 'list' … … 348 365 if back == 'list': 349 366 cherrypy.request.state.clear() #Changed global state 350 raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result)) 367 raise cherrypy.InternalRedirect('/list?result=%s' 368 % urllib.quote(result)) 351 369 elif back == 'info': 352 raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303) 370 raise cherrypy.HTTPRedirect(cherrypy.request.base 371 + '/machine/%d/' % machine_id, 372 status=303) 353 373 else: 354 374 raise InvalidInput('back', back, 'Not a known back page.') … … 508 528 session.begin() 509 529 try: 510 kws = dict([(kw, fields.get(kw)) for kw in 'owner admin contact name description memory vmtype disksize'.split() if fields.get(kw)]) 530 kws = dict([(kw, fields.get(kw)) for kw in 531 'owner admin contact name description memory vmtype disksize'.split() 532 if fields.get(kw)]) 511 533 kws['machine_id'] = machine_id 512 534 validate = validation.Validate(username, state, **kws)
Note: See TracChangeset
for help on using the changeset viewer.