Revision a1baa42b snf-cyclades-app/synnefo/logic/utils.py
b/snf-cyclades-app/synnefo/logic/utils.py | ||
---|---|---|
55 | 55 |
|
56 | 56 |
|
57 | 57 |
def id_from_network_name(name): |
58 |
"""Returns Network's Django id, given a ganeti machine name.
|
|
58 |
"""Returns Network's Django id, given a ganeti network name.
|
|
59 | 59 |
|
60 | 60 |
Strips the ganeti prefix atm. Needs a better name! |
61 | 61 |
|
... | ... | |
73 | 73 |
return "%snet-%s" % (settings.BACKEND_PREFIX_ID, str(id)) |
74 | 74 |
|
75 | 75 |
|
76 |
def id_from_nic_name(name): |
|
77 |
"""Returns NIC's Django id, given a Ganeti's NIC name. |
|
78 |
|
|
79 |
""" |
|
80 |
if not str(name).startswith(settings.BACKEND_PREFIX_ID): |
|
81 |
raise ValueError("Invalid NIC name: %s" % name) |
|
82 |
ns = str(name).replace(settings.BACKEND_PREFIX_ID + 'nic-', "", 1) |
|
83 |
if not ns.isdigit(): |
|
84 |
raise ValueError("Invalid NIC name: %s" % name) |
|
85 |
|
|
86 |
return int(ns) |
|
87 |
|
|
88 |
|
|
76 | 89 |
def get_rsapi_state(vm): |
77 | 90 |
"""Returns the API state for a virtual machine |
78 | 91 |
|
Also available in: Unified diff