Revision e57893cd snf-cyclades-app/synnefo/management/common.py
b/snf-cyclades-app/synnefo/management/common.py | ||
---|---|---|
112 | 112 |
" available server IDs." % server_id) |
113 | 113 |
|
114 | 114 |
|
115 |
def get_network(network_id): |
|
115 |
def get_network(network_id, for_update=True):
|
|
116 | 116 |
"""Get a Network object by its ID. |
117 | 117 |
|
118 | 118 |
@type network_id: int or string |
... | ... | |
128 | 128 |
except Network.InvalidBackendIdError: |
129 | 129 |
raise CommandError("Invalid network ID: %s" % network_id) |
130 | 130 |
|
131 |
networks = Network.objects |
|
132 |
if for_update: |
|
133 |
networks = networks.select_for_update() |
|
131 | 134 |
try: |
132 |
return Network.objects.get(id=network_id)
|
|
135 |
return networks.get(id=network_id)
|
|
133 | 136 |
except Network.DoesNotExist: |
134 | 137 |
raise CommandError("Network with ID %s not found in DB." |
135 | 138 |
" Use snf-manage network-list to find out" |
Also available in: Unified diff