Revision b2272468 snf-cyclades-app/synnefo/logic/utils.py
b/snf-cyclades-app/synnefo/logic/utils.py | ||
---|---|---|
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