Revision f5ad2956 db/models.py
b/db/models.py | ||
---|---|---|
9 | 9 |
|
10 | 10 |
import vocabs |
11 | 11 |
|
12 |
ganeti_prefix_id = settings.GANETI_PREFIX_ID |
|
12 |
backend_prefix_id = settings.BACKEND_PREFIX_ID |
|
13 |
|
|
14 |
|
|
15 |
def id_from_instance_name(name): |
|
16 |
""" Returns VirtualMachine's Django id, given a ganeti machine name. |
|
17 |
|
|
18 |
Strips the ganeti prefix atm. Needs a better name! |
|
19 |
""" |
|
20 |
return '%s' % (str(name).strip(backend_prefix_id)) |
|
21 |
|
|
13 | 22 |
|
14 | 23 |
|
15 | 24 |
class Limit(models.Model): |
... | ... | |
122 | 131 |
|
123 | 132 |
def _get_backend_id(self): |
124 | 133 |
"""Returns the backend id for this VM by prepending backend-prefix.""" |
125 |
return '%s%s' % (ganeti_prefix_id, str(self.id))
|
|
134 |
return '%s%s' % (backend_prefix_id, str(self.id))
|
|
126 | 135 |
|
127 | 136 |
backend_id = property(_get_backend_id) |
128 | 137 |
|
129 |
@staticmethod |
|
130 |
def id_from_instance_name(name): |
|
131 |
""" Returns VirtualMachine's Django id, given a ganeti machine name. |
|
132 |
|
|
133 |
Strips the ganeti prefix atm. Needs a better name! |
|
134 |
""" |
|
135 |
return '%s' % (str(name).strip(ganeti_prefix_id)) |
|
136 |
|
|
137 | 138 |
class VirtualMachineMetadata(models.Model): |
138 | 139 |
meta_key = models.CharField(max_length=50) |
139 | 140 |
meta_value = models.CharField(max_length=500) |
Also available in: Unified diff