Changeset 2525 for package_branches/invirt-web
- Timestamp:
- Oct 29, 2009, 1:36:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
package_branches/invirt-web/cherrypy/code/main.py
r2524 r2525 205 205 206 206 def parseCreate(self, fields): 207 kws = dict([(kw, fields.get(kw)) for kw in 'name description owner memory disksize vmtype cdrom autoinstall'.split() if fields.get(kw)]) 208 validate = validation.Validate(cherrypy.request.login, cherrypy.request.state, strict=True, **kws) 209 return dict(contact=cherrypy.request.login, name=validate.name, description=validate.description, memory=validate.memory, 210 disksize=validate.disksize, owner=validate.owner, machine_type=getattr(validate, 'vmtype', Defaults.type), 207 kws = dict([(kw, fields.get(kw)) for kw in 208 'name description owner memory disksize vmtype cdrom autoinstall'.split() 209 if fields.get(kw)]) 210 validate = validation.Validate(cherrypy.request.login, 211 cherrypy.request.state, 212 strict=True, **kws) 213 return dict(contact=cherrypy.request.login, name=validate.name, 214 description=validate.description, memory=validate.memory, 215 disksize=validate.disksize, owner=validate.owner, 216 machine_type=getattr(validate, 'vmtype', Defaults.type), 211 217 cdrom=getattr(validate, 'cdrom', None), 212 218 autoinstall=getattr(validate, 'autoinstall', None)) … … 219 225 try: 220 226 parsed_fields = self.parseCreate(fields) 221 machine = controls.createVm(cherrypy.request.login, cherrypy.request.state, **parsed_fields) 227 machine = controls.createVm(cherrypy.request.login, 228 cherrypy.request.state, **parsed_fields) 222 229 except InvalidInput, err: 223 230 pass … … 263 270 def info(self, machine_id): 264 271 """Handler for info on a single VM.""" 265 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 272 machine = validation.Validate(cherrypy.request.login, 273 cherrypy.request.state, 274 machine_id=machine_id).machine 266 275 d = infoDict(cherrypy.request.login, cherrypy.request.state, machine) 267 276 checkpoint.checkpoint('Got infodict') … … 275 284 """Handler for modifying attributes of a machine.""" 276 285 try: 277 modify_dict = modifyDict(cherrypy.request.login, cherrypy.request.state, machine_id, fields) 286 modify_dict = modifyDict(cherrypy.request.login, 287 cherrypy.request.state, 288 machine_id, fields) 278 289 except InvalidInput, err: 279 290 result = None 280 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 291 machine = validation.Validate(cherrypy.request.login, 292 cherrypy.request.state, 293 machine_id=machine_id).machine 281 294 else: 282 295 machine = modify_dict['machine'] 283 296 result = 'Success!' 284 297 err = None 285 info_dict = infoDict(cherrypy.request.login, cherrypy.request.state, machine) 298 info_dict = infoDict(cherrypy.request.login, 299 cherrypy.request.state, machine) 286 300 info_dict['err'] = err 287 301 if err: … … 313 327 echo 1 > /proc/sys/net/ipv4/ip_forward 314 328 """ 315 machine = validation.Validate(cherrypy.request.login, cherrypy.request.state, machine_id=machine_id).machine 316 329 machine = validation.Validate(cherrypy.request.login, 330 cherrypy.request.state, 331 machine_id=machine_id).machine 317 332 token = controls.vnctoken(machine) 318 333 host = controls.listHost(machine) … … 339 354 back = kwargs.get('back', None) 340 355 try: 341 d = controls.commandResult(cherrypy.request.login, cherrypy.request.state, command_name, machine_id, kwargs) 356 d = controls.commandResult(cherrypy.request.login, 357 cherrypy.request.state, 358 command_name, machine_id, kwargs) 342 359 if d['command'] == 'Delete VM': 343 360 back = 'list' … … 353 370 if back == 'list': 354 371 cherrypy.request.state.clear() #Changed global state 355 raise cherrypy.InternalRedirect('/list?result=%s' % urllib.quote(result)) 372 raise cherrypy.InternalRedirect('/list?result=%s' 373 % urllib.quote(result)) 356 374 elif back == 'info': 357 raise cherrypy.HTTPRedirect(cherrypy.request.base + '/machine/%d/' % machine_id, status=303) 375 raise cherrypy.HTTPRedirect(cherrypy.request.base 376 + '/machine/%d/' % machine_id, 377 status=303) 358 378 else: 359 379 raise InvalidInput('back', back, 'Not a known back page.') … … 562 582 session.begin() 563 583 try: 564 kws = dict([(kw, fields.get(kw)) for kw in 'owner admin contact name description memory vmtype disksize'.split() if fields.get(kw)]) 584 kws = dict([(kw, fields.get(kw)) for kw in 585 'owner admin contact name description memory vmtype disksize'.split() 586 if fields.get(kw)]) 565 587 kws['machine_id'] = machine_id 566 588 validate = validation.Validate(username, state, **kws)
Note: See TracChangeset
for help on using the changeset viewer.