Revision e3a99a08 db/models.py
b/db/models.py | ||
---|---|---|
328 | 328 |
def __str__(self): |
329 | 329 |
return repr(str(self._action)) |
330 | 330 |
|
331 |
@staticmethod |
|
332 |
def id_from_instance_name(name): |
|
333 |
"""Returns VirtualMachine's Django id, given a ganeti machine name. |
|
334 |
|
|
335 |
Strips the ganeti prefix atm. Needs a better name! |
|
336 |
|
|
337 |
""" |
|
338 |
if not str(name).startswith(settings.BACKEND_PREFIX_ID): |
|
339 |
raise VirtualMachine.InvalidBackendIdError(str(name)) |
|
340 |
ns = str(name).lstrip(settings.BACKEND_PREFIX_ID) |
|
341 |
if not ns.isdigit(): |
|
342 |
raise VirtualMachine.InvalidBackendIdError(str(name)) |
|
343 |
return int(ns) |
|
344 |
|
|
345 | 331 |
def __init__(self, *args, **kw): |
346 | 332 |
"""Initialize state for just created VM instances.""" |
347 | 333 |
super(VirtualMachine, self).__init__(*args, **kw) |
Also available in: Unified diff